]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: vars: use multiple name heads in the vars struct
authorWilly Tarreau <w@1wt.eu>
Sun, 15 Sep 2024 11:06:08 +0000 (13:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 15 Sep 2024 21:51:51 +0000 (23:51 +0200)
commit5d350d1e5032fed589739a87b30fc857e3ed2ee1
treeeb90313843a30fe678af4080e8ea843b8e86ace1
parent47ec7c681e85b999a59d26cf317ffe6bd6a01ac2
OPTIM: vars: use multiple name heads in the vars struct

Given that the original list-based version was using a list head as the
root of the variables, while the tree is using a single pointer, it made
sense to reuse that space to place multiple roots, indexed on the lower
bits of the name hash. Two roots slightly increase the performance level,
but the best gain is obtained with 4 roots. The performance is now always
above that of the list, even with small counts, and with 100 vars, it's
21% higher than before, or 67% higher than with the list.

We keep the same lock (it could have made sense to use one lock per head),
because most of the variables in large configs are attached to a stream
or a session, hence are not shared between threads. Thus there's no point
in sharding the pointer.
include/haproxy/vars-t.h
include/haproxy/vars.h
src/vars.c