You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scheduler: Use a "scheduler" task for thread sleep (#57544)
A Julia thread runs Julia's scheduler in the context of the switching
task. If no task is found to switch to, the thread will sleep while
holding onto the (possibly completed) task, preventing the task from
being garbage collected. This recent [Discourse
post](https://discourse.julialang.org/t/weird-behaviour-of-gc-with-multithreaded-array-access/125433)
illustrates precisely this problem.
A solution to this would be for an idle Julia thread to switch to a
"scheduler" task, thereby freeing the old task.
This PR uses `OncePerThread` to create a "scheduler" task (that does
nothing but run `wait()` in a loop) and switches to that task when the
thread finds itself idle.
Other approaches considered and discarded in favor of this one:
#57465 and
#57543.
0 commit comments