]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: ring: avoid reloading the tail_ofs value before the CAS in ring_write()
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Sep 2025 13:23:53 +0000 (15:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Sep 2025 13:27:32 +0000 (15:27 +0200)
commit79ef362d9e64f6fd0b6bf9ec29c0c1fe6ca6d91d
treebfe84bf1519c4a1a166557170227ace3532a772f
parenta727c6eaa54f95e72a45b98c2d5ff9d89ac54448
OPTIM: ring: avoid reloading the tail_ofs value before the CAS in ring_write()

The load followed by the CAS seem to cause two bus cycles, one to
retrieve the cache line in shared state and a second one to get
exclusive ownership of it. Tests show that on x86 it's much better
to just rely on the previous value and preset it to zero before
entering the loop. We just mask the ring lock in case of failure
so as to challenge it on next iteration and that's done.

This little change brings 2.3% extra performance (11.34M msg/s) on
a 64-core AMD.
src/ring.c