Navigation Menu

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

[core worker] Refactor CoreWorker member classes #5062

Merged

Conversation

stephanie-wang
Copy link
Contributor

@stephanie-wang stephanie-wang commented Jun 29, 2019

What do these changes do?

Refactoring CoreWorker class to encapsulate functionality a bit more. Removes references to the parent CoreWorker from the CoreWorkerObjectInterface, CoreWorkerTaskInterface, and CoreWorkerTaskExecutionInterface.

Linter

  • I've run scripts/format.sh to lint the changes in this PR.

@stephanie-wang
Copy link
Contributor Author

cc @raulchen @jovany-wang @zhijunfu, please let me know if these changes don't align with what you guys are thinking!

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/14969/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1398/
Test FAILed.

Copy link
Contributor

@zhijunfu zhijunfu left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for the effort. I left a few minor comments.

/// Information about a remote function.
struct RayFunction {
/// Language of the remote function.
const WorkerLanguage language;
const Language language;
Copy link
Contributor

Choose a reason for hiding this comment

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

The original intent of having a WorkerLanguage structure is that users don't need to look at the generated protobuf file for the Language definition, as that generated .h file is complex so we want to hide that complexity. But yes I agree that using Language directly makes the core worker code simpler, probably that's the right thing to do. Maybe we can consider separating Language definition to a different protobuf file say common.proto ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, yes, I think having a single Language type is cleaner. Sure, should I move Language to a new protobuf file now?

Copy link
Contributor

Choose a reason for hiding this comment

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

never mind, I could take care of it in my next PR:)

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, I'm working on common.proto right now.

// TODO(zhijunfu): currently RayletClient would crash in its constructor if it cannot
// connect to Raylet after a number of retries, this needs to be changed
// so that the worker (java/python .etc) can retrieve and handle the error
// instead of crashing.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment actually refers to RayletClient , and should better be moved to CoreWorker where raylet_client_ is initialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks!

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/14987/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1412/
Test FAILed.

Copy link
Contributor

@zhijunfu zhijunfu left a comment

Choose a reason for hiding this comment

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

LGTM. thanks.

@pcmoritz
Copy link
Contributor

pcmoritz commented Jul 1, 2019

@stephanie-wang There is a compile error in one of the tests, do you want to fix it?

src/ray/core_worker/mock_worker.cc: In constructor 'ray::MockWorker::MockWorker(const string&, const string&)':
src/ray/core_worker/mock_worker.cc:20:37: error: 'WorkerLanguage' has not been declared
       : worker_(WorkerType::WORKER, WorkerLanguage::PYTHON, store_socket, raylet_socket,

@raulchen
Copy link
Contributor

raulchen commented Jul 1, 2019

I'm actually in favor of having the CoreWorker and the sub interfaces friend each other.

Because the public methods in these interfaces are supposed to exposed to Java/Python workers and should be limited. And on the other hand, inside these interfaces, we sometimes want to use other interfaces' private methods. E.g., DirectActorCallTransport would need the private api in ObjectInterface that puts an object directly in local memory.

The initial reason why we split CoreWorker into sub interfaces was mainly to avoid making CoreWorker class too large, not because of encapsulation.

Does this make sense?

@stephanie-wang
Copy link
Contributor Author

I'm actually in favor of having the CoreWorker and the sub interfaces friend each other.

Because the public methods in these interfaces are supposed to exposed to Java/Python workers and should be limited. And on the other hand, inside these interfaces, we sometimes want to use other interfaces' private methods. E.g., DirectActorCallTransport would need the private api in ObjectInterface that puts an object directly in local memory.

The initial reason why we split CoreWorker into sub interfaces was mainly to avoid making CoreWorker class too large, not because of encapsulation.

Does this make sense?

Sorry, I don't understand your example about the DirectActorCallTransport. Can you describe specifically what the inheritance/friend relationships would be in that case? That seems like you would want to make DirectActorCallTransport a friend of an ObjectInterface, which I think would be okay in certain cases for the reasons you mentioned, but it does not explain why ObjectInterface needs to be a friend of CoreWorker.

In general, I just want to avoid giving classes access to private fields that they are not currently using; for example, before this PR, the CoreWorkerTaskInterface had access to the plasma store_socket_, even though it never uses it.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/15009/
Test PASSed.

@raulchen
Copy link
Contributor

raulchen commented Jul 2, 2019

@stephanie-wang Initially, I was thinking that all the sub interfaces would intensively use other interfaces' private methods. After thinking more, this doesn't seem true. I think what you said should be better. Only use friend in particular classes that need it. Thanks.

@zhijunfu
Copy link
Contributor

zhijunfu commented Jul 2, 2019

@stephanie-wang there's still a compile error, may you please fix it? There are a few such places in core_worker_test.cc

src/ray/core_worker/core_worker_test.cc: In member function 'virtual void ray::TwoNodeTest_TestObjectInterfaceCrossNodes_Test::TestBody()':
src/ray/core_worker/core_worker_test.cc:370:42: error: 'WorkerLanguage' has not been declared
   CoreWorker worker1(WorkerType::DRIVER, WorkerLanguage::PYTHON,

@stephanie-wang
Copy link
Contributor Author

@stephanie-wang there's still a compile error, may you please fix it? There are a few such places in core_worker_test.cc

src/ray/core_worker/core_worker_test.cc: In member function 'virtual void ray::TwoNodeTest_TestObjectInterfaceCrossNodes_Test::TestBody()':
src/ray/core_worker/core_worker_test.cc:370:42: error: 'WorkerLanguage' has not been declared
   CoreWorker worker1(WorkerType::DRIVER, WorkerLanguage::PYTHON,

Oops, thank you!

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/15014/
Test PASSed.

@kfstorm
Copy link
Member

kfstorm commented Jul 2, 2019

FYI, I changed type of language to ray::rpc::language in #5034.

@stephanie-wang
Copy link
Contributor Author

FYI, I changed type of language to ray::rpc::language in #5034.

Thanks, I changed it to just use Language everywhere. Hope this is okay...

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1429/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/15031/
Test FAILed.

@stephanie-wang stephanie-wang merged commit 71d4637 into ray-project:master Jul 2, 2019
@stephanie-wang stephanie-wang deleted the core-worker-refactor branch July 2, 2019 22:30
@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1434/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1449/
Test FAILed.

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.

None yet

6 participants