-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Consider switching off spin
#29
Comments
Note also that spinlocks have pretty bad worst-case behavior. If performance of std::Mutex is unsatisfactory, i would advice to replace it with a faster sleeping mutex (eg, parking_lot) instead of going to an unbounded spinning: https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html |
@matklad Hi. I read your blog post some months ago. While it makes a lot of good points, I don't think it's applicable in this case. Flume doesn't use spinlocks like a regular mutex: it uses them to moderate contention and then switches to scheduler-managed waiting after a backoff period. We've done extensive benchmarking across a wide variety of scenarios and have found this to consistently perform better than a mutex under many different workloads on *nix platforms. |
With regards to the process we went through on this:
Imo, still worth looking into potentially replacing |
Is it? Perhaps I am reading the code incorrectly, but it seems there are cases where flume doesn't fall-back to scheduler-managed waiting? Here's what I gathered (might be totally or partially wrong):
So, either I missed the bit about falling back to scheduler, or it isn't there? |
JFYI, the way I deal with it in once_cell is that |
Ah, indeed. Though I wonder why Lines 591 to 595 in 53d93a0
|
@matklad Yes, it's used during shutdown. Most work is now being done on the |
|
So, apparently
spin
is unmaintained.cargo deny
mentions a few alternatives, though.The text was updated successfully, but these errors were encountered: