]> git.kaiwu.me - haproxy.git/commit
MEDIUM: queues: Introduce a new field to know if queues are empty.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 3 Feb 2026 02:44:58 +0000 (03:44 +0100)
committerOlivier Houchard <cognet@ci0.org>
Mon, 2 Mar 2026 12:46:17 +0000 (13:46 +0100)
commit131113bbe567e64b00ae61ff49d53e2944215ff1
tree131cda6a53c21457f29526ed05e756cc33b12c9e
parent9db62d408a2011253ecd5ba748039fb30265b773
MEDIUM: queues: Introduce a new field to know if queues are empty.

Proxies and servers both have a queueslength entry, that indicates how
many entries there are in their request queues. Those can get a lot of
contention, and they are often accessed just to know if the queue is
empty or not, which it will always be when there is no maxconn.
So for both, introduce a new field, "queues_not_empty", in a different,
less contended cache line, and use it every time we just want to know if
the queue is empty or not.
Those are only changed when the queues goes from empty to non-empty, and
vice-versa, which hopefully should not be too often.
For proxies, they are protected by the proxy lock. For servers, they are
protected by a new lock contained in the server, the status_lock.
In both case, to prevent any race condition, once the relevant lock is
held, the value of queueslength should be checked again before deciding
to change or not queues_not_empty, to prevent any race condition.
include/haproxy/proxy-t.h
include/haproxy/queue.h
include/haproxy/server-t.h
src/backend.c
src/lb_chash.c
src/lb_fas.c
src/lb_fwlc.c
src/lb_fwrr.c
src/lb_map.c
src/queue.c
src/server.c