]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: ring: check the queue's owner using a CAS on x86
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Sep 2025 13:08:12 +0000 (15:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Sep 2025 13:08:12 +0000 (15:08 +0200)
commita727c6eaa54f95e72a45b98c2d5ff9d89ac54448
tree660d60f0ca860054db003ae764291d56f566198c
parentd25099b359df8277e9296a1deaa7297b66e95ad0
OPTIM: ring: check the queue's owner using a CAS on x86

In the loop where the queue's leader tries to get the tail lock,
we also need to check if another thread took ownership of the queue
the current thread is currently working for. This is currently done
using an atomic load.

Tests show that on x86, using a CAS for this is much more efficient
because it allows to keep the cache line in exclusive state for a
few more cycles that permit the queue release call after the loop
to be done without having to wait again. The measured gain is +5%
for 128 threads on a 64-core AMD system (11.08M msg/s vs 10.56M).
However, ARM loses about 1% on this, and we cannot afford that on
machines without a fast CAS anyway, so the load is performed using
a CAS only on x86_64. It might not be as efficient on low-end models
but we don't care since they are not the ones dealing with high
contention.
src/ring.c