async-rs / async-rs/async-std

Unbounded spinning in `WakerSet`

Open
#656 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
4.1k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

`WakerSet` contains a spin lock which never falls back to OS-provided blocking facilities:

https://github.com/async-rs/async-std/blob/6d69a3e368869bb7fb6933baad3b0bc1cd5ef8f8/src/sync/waker_set.rs#L181-L182

I think this might lead to a pretty bad behavior in pathological cases, due to priority inversion.

Not sure what's the best solution here is though: `std::sync::Mutex` is not the fastest one in town, `parking_lot` is an external dependency.

See also https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html and https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.