-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std::rt: Fix the set up of the main thread so that it doesn't try to ste... #9857
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
Conversation
…steal work This is causing really awful scheduler behavior where the main thread scheduler is continually waking up, stealing work, discovering it can't actually run the work, and sending it off to another scheduler.
This fixes a problem described on dev-servo |
CC #9831. |
The patch itself looks fine to me, but I'm a little confused about what's going on here. This seems to be indicative of a larger problem if we've got runnable tasks that are waking up schedulers they can't run on. I'm not really sure why a task wouldn't be run on a scheduler, and if it's targeted at a specific scheduler then it seems like we shouldn't be waking up other schedulers regardless. Could you explain a bit more about what's happening? I'm not sure why the main scheduler is determining that it can't run this task, and I'm also not sure why the task is waking up the main scheduler if it can't be run on it. |
Schedulers run on a single thread. Within the runtime, some subset of the schedulers are work stealing schedulers, some are not. The work stealing schedulers are collaborating to schedule tasks across threads. The non-work stealing schedulers are currently used solely for 'single-threaded schedulers' in which one task is assigned it's own scheduler and it's own thread. There are two reasons that a scheduler may not be able to run a task:
Tasks that are homed to a specific scheduler are sent directly to that scheduler for execution - they do not wake up any other schedulers. Tasks that are not homed but can't be run on the local scheduler are sent instead to a scheduler-designated 'friend' scheduler for reevaluation. All schedulers share a What was happening here is that the main thread scheduler, which is a single-threaded scheduler that runs the homed main task, was pushing itself to the sleeper list as if it were a work-stealing scheduler. It would get woken up to look for work, steal random, unhomed tasks, but because the main thread scheduler's 'run_anything' flag is false could not actually run the tasks, so it would send it to its friend scheduler. Another way to phrase this change might be to make Scheduler not push to the SleeperList when the |
Thanks for the explanation! I think it's fine to have the identical setup, and I also think that it makes the most sense. |
...al work This is causing really awful scheduler behavior where the main thread scheduler is continually waking up, stealing work, discovering it can't actually run the work, and sending it off to another scheduler. No test cases because we don't have suitable instrumentation for it.
...al work
This is causing really awful scheduler behavior where the main thread scheduler is
continually waking up, stealing work, discovering it can't actually run the work,
and sending it off to another scheduler.
No test cases because we don't have suitable instrumentation for it.