]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: connection: move idle connection trees to ceb64
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Sep 2025 13:28:33 +0000 (15:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2025 07:23:46 +0000 (09:23 +0200)
commitceaf8c1220accbdd80c1c77626d69286cc28f0f9
treedeb041194b1b442a43ab89427f91b3014ea377dc
parent95b8adff670081f0a83493bca52c31c16ee76068
MEDIUM: connection: move idle connection trees to ceb64

Idle connection trees currently require a 56-byte conn_hash_node per
connection, which can be reduced to 32 bytes by moving to ceb64. While
ceb64 is theoretically slower, in practice here we're essentially
dealing with trees that almost always contain a single key and many
duplicates. In this case, ceb64 insert and lookup functions become
faster than eb64 ones because all duplicates are a list accessed in
O(1) while it's a subtree for eb64. In tests it is impossible to tell
the difference between the two, so it's worth reducing the memory
usage.

This commit brings the following memory savings to conn_hash_node
(one per backend connection), and to srv_per_thread (one per thread
and per server):

     struct       before  after  delta
  conn_hash_nodea   56     32     -24
  srv_per_thread    96     72     -24

The delicate part is conn_delete_from_tree(), because we need to
know the tree root the connection is attached to. But thanks to
recent cleanups, it's now clear enough (i.e. idle/safe/avail vs
session are easy to distinguish).
include/haproxy/connection-t.h
include/haproxy/server-t.h
include/haproxy/server.h
src/backend.c
src/connection.c
src/mux_fcgi.c
src/mux_h2.c
src/mux_quic.c
src/mux_spop.c
src/server.c
src/session.c