In tokio, when the processors finish all the tasks in their run queue, do they first look into the global queue for more tasks or do they try work steal from sibling processors first?
Does the tokio task scheduler "steal work" or fetch from the global queue first?
1.1k views Asked by pandawithcat At
1
Given this is undocumented, I would assume it is unspecified and not part of the library's guarantees unless you can get an issue or PR accepted to specify this behaviour. I would strongly recommend not relying on the current behaviour.
With that being said, "use the code luke" is a short hop away: the main run loop would be Context::run. When the local queue is empty, it calls Core::steal_work which first starts to steal work from a sibling then falls back to the global queue.
Note that schedulers will try to pop tasks from the global queue once in a while during normal operations though, the essay introducing the work-stealing schedulers notes: