Skip to content
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

A long-running job could make the pool degenerate #10

Open
QuarticCat opened this issue Sep 2, 2024 · 0 comments
Open

A long-running job could make the pool degenerate #10

QuarticCat opened this issue Sep 2, 2024 · 0 comments

Comments

@QuarticCat
Copy link

QuarticCat commented Sep 2, 2024

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. rayon-rs/rfcs#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant