-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1147,7 +1147,11 @@ end | |||||||
|
||||||||
@inline function wait_forever() | ||||||||
while true | ||||||||
wait() | ||||||||
try | ||||||||
wait() | ||||||||
catch | ||||||||
# ignore SIGINT and anything thrown from wait() | ||||||||
end | ||||||||
end | ||||||||
end | ||||||||
|
||||||||
|
@@ -1204,11 +1208,13 @@ function wait() | |||||||
W = workqueue_for(Threads.threadid()) | ||||||||
task = trypoptask(W) | ||||||||
if task === nothing | ||||||||
# No tasks to run; switch to the scheduler task to run the | ||||||||
# thread sleep logic. | ||||||||
sched_task = get_sched_task() | ||||||||
if ct !== sched_task | ||||||||
return yieldto(sched_task) | ||||||||
# No tasks to run; if the current task is done/failed, switch to the | ||||||||
# scheduler task to run the thread sleep logic. | ||||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(plus implement Or remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
scheduler_task() = nothing
if ct.start !== scheduler_task
yieldto(Task(scheduler_task))
end |
||||||||
end | ||||||||
end | ||||||||
task = ccall(:jl_task_get_next, Ref{Task}, (Any, Any, Any), trypoptask, W, checktaskempty) | ||||||||
end | ||||||||
|
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 fromwait()
, then how is that different from just ignoring it?