Choice of Slim RW Lock over Critical Section for std::mutex? #4126
-
Hi friends, I'm just curious about the choice of Slim RW Locks over Critical Sections for * I do recognize that there are random benchmarks online that show SRW outpacing CS even outside of read/write contention, so maybe the documentation is just wrong nowadays. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
FWIW other MS products also prefer SRW locks for mutex purposes. WIL and cppwinrt are two examples that come to mind. This advice from MS docs may no longer be true. |
Beta Was this translation helpful? Give feedback.
IIRC, Windows folks told us to prefer SRW when the threading primitives were last overhauled in 2016 (which changes we haven't been able to ship due to the joys of ABI stability). I don't have hard numbers to hand, but I'd be surprised if the implementer, who was our perf champ at the time, didn't do some performance investigation as well.
I will note that SRW's ease of construction also makes it possible for us to make
std::mutex
's constructorconstexpr
as required by the Standard since C++11.