]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: queue: use a dedicated lock for the queues (v2)
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Jun 2021 07:45:27 +0000 (09:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Jun 2021 08:52:31 +0000 (10:52 +0200)
commit16fbdda3c33703702462a46805a88673e7f6ca51
tree39cedd8327b527085d8f5ed72b0a9d3eb31b04af
parent9cef43acab5137657deea9e1189a1bd7b163f6fb
MEDIUM: queue: use a dedicated lock for the queues (v2)

Till now whenever a server or proxy's queue was touched, this server
or proxy's lock was taken. Not only this requires distinct code paths,
but it also causes unnecessary contention with other uses of these locks.

This patch adds a lock inside the "queue" structure that will be used
the same way by the server and the proxy queuing code. The server used
to use a spinlock and the proxy an rwlock, though the queue only used
it for locked writes. This new version uses a spinlock since we don't
need the read lock part here. Tests have not shown any benefit nor cost
in using this one versus the rwlock so we could change later if needed.

The lower contention on the locks increases the performance from 362k
to 374k req/s on 16 threads with 20 servers and leastconn. The gain
with roundrobin even increases by 9%.

This is tagged medium because the lock is changed, but no other part of
the code touches the queues, with nor without locking, so this should
remain invisible.
include/haproxy/queue-t.h
include/haproxy/thread.h
src/proxy.c
src/queue.c
src/server.c