Skip to content

[Java] Fix setCurrentTask() in multi threading#3821

Merged
raulchen merged 7 commits into
ray-project:masterfrom
antgroup:fix-multi-threading
Jan 23, 2019
Merged

[Java] Fix setCurrentTask() in multi threading#3821
raulchen merged 7 commits into
ray-project:masterfrom
antgroup:fix-multi-threading

Conversation

@jovany-wang

Copy link
Copy Markdown
Contributor

What do these changes do?

For actor tasks , we should not set current driver id to null.

Related issue number

N/A

@AmplabJenkins

Copy link
Copy Markdown

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

@AmplabJenkins

Copy link
Copy Markdown

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

@stephanie-wang stephanie-wang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Left a couple questions.

runtime.getWorkerContext().setCurrentTask(null, null, null);
}

Thread.currentThread().setContextClassLoader(oldLoader);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I'm not clear on what classLoader is, but it seems like you could get rid of this line and pass in oldLoader in the setCurrentTask lines above?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@stephanie-wang classLoader is used to tell JVM where and how to load a class into memory. We use different class loaders for different drivers. So different drivers can have classes with the same name without conflicts.
@jovany-wang classLoader should be set and reset in the same way as the driver id.

* be called from the main thread.
*/
public void setCurrentTask(TaskSpec task, ClassLoader classLoader) {
public void setCurrentTask(UniqueId currentTaskId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Set currentTaskId to UniqueId.NIL if it's null?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

right, but maybe it's more clear to just pass in UniqueId.NIL

Comment thread java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java Outdated
* be called from the main thread.
*/
public void setCurrentTask(TaskSpec task, ClassLoader classLoader) {
public void setCurrentTask(UniqueId currentTaskId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

right, but maybe it's more clear to just pass in UniqueId.NIL

runtime.getWorkerContext().setCurrentTask(null, null, null);
}

Thread.currentThread().setContextClassLoader(oldLoader);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@stephanie-wang classLoader is used to tell JVM where and how to load a class into memory. We use different class loaders for different drivers. So different drivers can have classes with the same name without conflicts.
@jovany-wang classLoader should be set and reset in the same way as the driver id.

@jovany-wang

Copy link
Copy Markdown
Contributor Author

@raulchen @stephanie-wang
I have refined this PR with following logic:
In finally block we should not set any workerContext.
Because we will set it in the next turn of the while loop.

@AmplabJenkins

Copy link
Copy Markdown

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

@AmplabJenkins

Copy link
Copy Markdown

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

@raulchen raulchen merged commit 816406e into ray-project:master Jan 23, 2019
@jovany-wang jovany-wang deleted the fix-multi-threading branch February 20, 2019 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants