Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[object store refactor 1/n] Introduce IAllocator and PlasmaAllocator #17307

Merged
merged 2 commits into from
Jul 31, 2021

Conversation

scv119
Copy link
Contributor

@scv119 scv119 commented Jul 24, 2021

Problem

There are two major issues with plasma store:

  • Lack of unit/integration tests.
  • Complicate interactions between components.
    Which makes the IO layer unstable & vulnerable to race conditions & slow to develop.

Goal

The goal is to make local object management unit testable, easy to extend, and hide implementation detail from the upper layer.

Phase 1: Unit test all major components:

  • Refactor current plasma store into following unit testable components: MmapAllocator / GarbageCollector / ObjectLifetimeManager/GetRequestQueue /CreateRequestQueue/Object Transfer Manager
  • Refactor object transfer code path (object manager unit-testable), add unit test and integration test (in cpp).

This is the first PR that refactors object store. Next PR #17313

Specifically in this PR, we creates IAllocator interface thats allocates mmaped memories, and refactor the PlasmaAllocator to implement this interface.

Test Plan

-[x] existing tests
-[ ] on demand stress tests
-[x] more unit test coming in follow up PR #17313

Note: I'm trying out stack PRs in ray-project/test-wheels branch so that we can get signals from CI, so we need merge PRs in sequence.

@scv119 scv119 added @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. do-not-merge Do not merge this PR! labels Jul 24, 2021
@scv119 scv119 force-pushed the test-wheels/introduce-allocator branch 2 times, most recently from 8bb8d09 to ae21707 Compare July 24, 2021 03:19
@scv119 scv119 removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Jul 26, 2021
@scv119 scv119 removed the do-not-merge Do not merge this PR! label Jul 26, 2021
Copy link
Contributor

@rkooo567 rkooo567 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! Most of comments are comment updates.

BUILD.bazel Outdated Show resolved Hide resolved
src/ray/object_manager/object_manager.cc Show resolved Hide resolved
src/ray/object_manager/plasma/common.h Show resolved Hide resolved
src/ray/object_manager/plasma/eviction_policy.h Outdated Show resolved Hide resolved
src/ray/object_manager/plasma/malloc.h Outdated Show resolved Hide resolved
@@ -64,10 +65,22 @@ ray::ObjectID GetCreateRequestObjectId(const std::vector<uint8_t> &message) {
return ray::ObjectID::FromBinary(request->object_id()->str());
}

void ToPlasmaObject(const ObjectTableEntry &entry, PlasmaObject *object,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just return the Plasma object instead of accepting mutable arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some subtlety at the caller of ToPlasmaObject. Let's defer that to follow up PRs.

src/ray/object_manager/plasma/store.cc Outdated Show resolved Hide resolved
void *pointer = PlasmaAllocator::Memalign(
kBlockSize, PlasmaAllocator::GetFootprintLimit() - 256 * sizeof(size_t));
RAY_CHECK(pointer != nullptr);
// TODO(scv119): this leaks details of PlasmaAlloctor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just fix it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is fixed in next PR!

src/ray/object_manager/plasma/store_runner.cc Outdated Show resolved Hide resolved
src/ray/object_manager/plasma/common.h Show resolved Hide resolved
@@ -49,4 +41,6 @@ struct MmapRecord {
/// and size.
extern std::unordered_map<void *, MmapRecord> mmap_records;

/// private function, only used by PlasmaAllocator
bool GetMallocMapinfo(void *addr, MEMFD_TYPE *fd, int64_t *map_length, ptrdiff_t *offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a get, please mark it as const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unfortunate a C function. I'll make addr const.

@fishbone
Copy link
Contributor

I feel fine about this one. Only one nit.

Copy link
Contributor

@rkooo567 rkooo567 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It'll be great if we can run the nightly before merging this...

@ericl ericl added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Jul 30, 2021
@scv119 scv119 force-pushed the test-wheels/introduce-allocator branch from 54bb716 to 28fe635 Compare July 30, 2021 23:09
@rkooo567
Copy link
Contributor

Let me know when it is mergeable!

@scv119
Copy link
Contributor Author

scv119 commented Jul 30, 2021

This should be mergable once CI passes!
image

@scv119 scv119 removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Jul 31, 2021
@rkooo567 rkooo567 merged commit 96c69f8 into master Jul 31, 2021
@rkooo567 rkooo567 deleted the test-wheels/introduce-allocator branch July 31, 2021 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants