@Marko,
I went over the article. It suggests checking for the variable before attempting to write it. Fortunately, our server and most new generation system uses compare_exchange_strong there-by stimulating the same behavior but more efficiently at the processor level.
just to add a note for a wider audience ... compare_exchange can be looked upon as 2 ops:
compare (if the desired value is present) then try to exchange ... RARE event while the lock is being acquired
compare (if the desired value is absent) return immediately .. common scenario leading to the loop.
krunalbauskar, in
MDEV-24167andMDEV-24142in 10.6, the old rw_lock_t was replaced with srw_lock and ssux_lock. Have you run benchmarks on that code?My idea to make S-latch acquisition a simple fetch_add() had to be abandoned, because it caused writer starvation (
MDEV-24271). The compare-and-swap loop does look ugly, but I was not able to come up with anything better.