RwLock needs a task-fair locking policy
Open
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
Long story short, I've audited at least three different async RwLock implementations 😁 and they all have the same problem; read-heavy workloads will starve writers.
In the case of `async-std`, the starvation happens here: https://github.com/async-rs/async-std/blob/125fa5b0a026088f16fb4c1e2df6375d0b30c0e5/src/sync/rwlock.rs#L195-L201 by incrementing the reader count without regard for the number of writers waiting to acquire the lock.
See also:
- https://docs.rs/parking_lot/0.10.0/parking_lot/type.RwLock.html
- https://github.com/asomers/futures-locks/issues/34
- https://github.com/rust-lang/futures-rs/pull/2082#issuecomment-586752557
Contributor guide
Assessment
This issue has not been assessed yet.