5 ms·
Classic use-case where a posix rwlock will outperform a mutex. How often does the locale change in practice? Almost never.
by PandaPanda150 5y ago
Classic use-case where a posix rwlock will outperform a mutex.
How often does the locale change in practice? Almost never.
- hinkley 5y agoWith most locking logic, it’s a series of escalations from the most optimistic/polite to least polite solution, and the worst case behavior is when a sequence always goes to the worst case scenario. In these situations, assuming the worst up front, and jumping straight to it or something very similar saves a lot of bargaining that leads to cache pressure and branch prediction. ETA: It's also quite common in engineering blogs for languages, libraries or frameworks, an entry detailing how in the new version they have made a performance improvement by making the fast case faster, or the predictor more accurate, and then removed option 2 from the decision tree, so that we get a bigger benefit from the happy path and the average case, and as a benefit the system is now simpler as well.
- loeg 5y agorwlock still require contending on a shared, mutated cache line. Something like RCU would bypass that.