-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Scheduler: do not always switch to the scheduler task #58765
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
base: master
Are you sure you want to change the base?
Conversation
Only switch when the current task is done/failed.
I'm not sure if I like this. Specifically because the whole point of the waiter task is to not have a task hogging a thread and vice versa. This just adds some complexity but the bad case is still there. |
I'm not sure I understand. The scheduler task addresses the problem that a dead task (and everything it references) cannot be GCed until there is some other task for the thread to run. This fix doesn't change that. If the current task is not dead, then it's fine to not switch to another task? |
Part of at least my idea for the waiter task, is to avoid the case where when we want to schedule a task that's waiting on a lock or something but it's stuck to a thread. This means we have to wakeup the thread adding complexity to the scheduler and making it have to worry about this case. I would like to have every task either be schedulable or currently running |
try | ||
wait() | ||
catch | ||
# ignore SIGINT and anything thrown from wait() |
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.
This should still kill the application, as currently this would make julia unkillable with ^C, which isn't intended (there is also some logic in task_done_hook to move the exception to the correct Task, which this prevents)
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.
I saw the logic in task_done_hook
, and thought about replicating it here but wasn't sure that was the right thing to do.
If we allow an InterruptException
to kill this task, and simply restart it from wait()
, then how is that different from just ignoring it?
if istaskdone(ct) | ||
sched_task = get_sched_task() | ||
if ct !== sched_task | ||
return yieldto(sched_task) |
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.
return yieldto(sched_task) | |
istaskdone(sched_task) && sched_task = reset(get_sched_task) | |
return yieldto(sched_task) |
(plus implement reset
)
Or remove the OncePerThread{Task}
, since it adds a lot of unnecessary complexity here, and just use @task wait()
here instead?
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.
Re: @task wait()
, I feel that it would add avoidable latency. If there is a way to implement a reset
, that would make it unnecessary, yes? But how would I implement reset
?
Only switch when the current task is done/failed. Also, ignore all exceptions in the scheduler task.
Context.
The downside is that when Julia is lightly loaded, Ctrl+C will often do nothing at all. However, Ctrl+C is delivered to an essentially random task anyway so I'm not sure if this is worse.
@Keno and @vtjnash: I think this is a simple fix that can be added to 1.12 instead of backing the scheduler task out altogether. Thoughts?