Suppose we join task A (fast) and task B (slow) in thread 1, and thread 2 steals task B. After thread 1 finishes task A, it cannot find another job to run, then it waits for task B to be done.
Here's the problem. If new tasks are pushed, thread 1 won't be awakened to steal and execute them. The pool just lost one spare thread util task B finishes.
In the worst case, thread 1 is waiting for a task on thread 2, which is waiting for a task on thread 3.... Eventually all threads are blocked by a slow task and cannot execute new tasks.
Suppose we join task A (fast) and task B (slow) in thread 1, and thread 2 steals task B. After thread 1 finishes task A, it cannot find another job to run, then it waits for task B to be done.
Here's the problem. If new tasks are pushed, thread 1 won't be awakened to steal and execute them. The pool just lost one spare thread util task B finishes.
In the worst case, thread 1 is waiting for a task on thread 2, which is waiting for a task on thread 3.... Eventually all threads are blocked by a slow task and cannot execute new tasks.
It seems like rayon can overcome this issue by some complicated sleep mechanism. https://github.com/rayon-rs/rfcs/pull/5