MEDIUM: ring: improve speed in the queue waiting loop on x86_64
authorWilly Tarreau <w@1wt.eu>
Sun, 17 Mar 2024 09:20:56 +0000 (10:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
commit573bbbe127608d36e4050fcb19069dc64ba4b2fb
tree0875b381d69904d64fd05d2dd020d3d65ed70069
parent30a659c3554ce45ae2c280ba02d53a4f6aba17b3
MEDIUM: ring: improve speed in the queue waiting loop on x86_64

x86_64 doesn't have a native atomic FETCH_OR(), it's implemented using
a CAS, which will always cause a write cycle. Here we know we can just
wait as long as the lock bit is held so better loop on a load, and only
attempt the CAS on success. This requires a tiny ifdef and brings nice
benefits. This brings the performance back from 3.33M to 3.75M at 24C48T
while doing no change at 3C6T.
src/ring.c