rust-lang / rfcs

RFCs for changes to Rust
https://rust-lang.github.io/rfcs/
Apache License 2.0
5.79k stars 1.55k forks source link

RwLock: Priority policy #2674

Open nico-abram opened 5 years ago

nico-abram commented 5 years ago

It would be nice to be able to specify writer preference or reader preference.

Just using os defaults is a very bad idea in my opinión. It would be better to first enforce a default policy regardless of os, and allow changing it. Otherwise, we end up with wildly varying performance results (Like https://fy.blackhats.net.au/blog/html/2018/10/19/rust_rwlock_and_mutex_performance_oddities.html and https://www.slideshare.net/mobile/mitsunorikomatsu/performance-comparison-of-mutex-rwlock-and-atomic-types-in-rust ) and in the worst case, writer starvation.

nico-abram commented 5 years ago

This will probably be fixed once https://github.com/rust-lang/rust/pull/56410 lands.