-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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][state][dashboard] Use main threads's task id or actor creation task id for parent's task id in state API #32157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, any reason to special case the concurrent actor case? If it's an implemention issue we can probably use an atomic reference or something like that for safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe what we really want is an inheritable thread local variable.
Guess it's special in what the main thread runs:
Or to make things consistent across all actors, we could probably always use the actor creation task's task id? |
For async actors, since multiple tasks could be run in the same thread concurrently, a thread-local variable might still not be able to solve the problem? Or maybe I am not understanding what you mean by "inheritable" correctly. |
That's true, the management for an async actor would be more complex. I guess using the constructor task is probably good enough for now in these more unusual cases, and we can always revisit later... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the short-term fix.
I think we need a lock?
Q: Is actor creation task semantic necessary? If not, let's just not do it. If so, can you modify the docstring of parent_task_id of the state API to explain this semantics?
Yeah, it's needed because we might have use cases where the actor manages a thread pool, and submits tasks from the thread pool while running actor task/actor creation task. Without proxying the actor creation task's id to those submitted tasks' parent task id, the parent task id of those tasks will be random. |
Signed-off-by: rickyyx <rickyx@anyscale.com>
Synced offline with Sang - so I guess I misunderstood Eric's original comment. We will revert to using the actor creation tasks for the tricky cases (concurrent actors), but use the main thread's task id for others. |
Signed-off-by: rickyyx <rickyx@anyscale.com>
Talked offline. The final behavior is;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proto change lgtm
… task id for parent's task id in state API (ray-project#32157) Right now, if a new thread (or async actor's event loop executing thread) runs some ray code (e.g. submitting a task, calling runtime context), the thread will have a WorkerThreadContext that has a random task id. This causes issues in state API since the task tree will have wrong structures, i.e. some tasks might have parent_task_id that doesn't match any existing tasks: For normal single threaded task/actor, we will use the main thread's task id (correct hehavior). For unusual cases (threaded/async actors), we will use the actor creation task's task id. This means from the advanced visualization, all the remote tasks created from actor tasks will be under the constructor of threaded/async actors Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: rickyyx rickyx@anyscale.com
Why are these changes needed?
Problems
Right now, if a new thread (or async actor's event loop executing thread) runs some ray code (e.g. submitting a task, calling runtime context), the thread will have a
WorkerThreadContext
that has a random task id.This causes issues in state API since the task tree will have wrong structures, i.e. some tasks might have
parent_task_id
that doesn't match any existing tasks:Solutions
This PR adds a
main_thread_or_actor_creation_task_id
so that this will be used as the parent task id info for State API related features so that:Not fixed in this PR
This PR doesn't address the actual runtime context of tasks in anonymous threads: calling
ray.get_runtime_context()
is still not defined for async actors or threaded actors that start new threads.Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.