]> git.kaiwu.me - haproxy.git/commit
MINOR: memprof: attempt different retry slots for different hashes on collision
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2026 15:33:33 +0000 (16:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Mar 2026 17:06:37 +0000 (18:06 +0100)
commitfb7e5e169654e2c78d85774091ab92952b33f4f8
tree3d3ff17c98b345c83d3952ffbb14e78b9f150217
parent3b4275b0724479717af9efcf254604d21b3ef766
MINOR: memprof: attempt different retry slots for different hashes on collision

When two pointer hash to the same memprofile bin, we currently try again
with the same bin until we find a spare one or we reach the limit of 16.
Olivier suggested to try with a different step for different pointers so
as to limit the number of bins to visit in such a case, so let's split
the pointer hash calculation so that we keep the raw hash before reduction
and use its lowest bits as the retry step. We force lowest bit to 1 to
avoid integral multiples that would oscillate between only a few positions.

Quick tests with h1+h2 requests show that for ~744 distinct entries, we
used to have 1.17 retries per lookup before and 0.6 now so we're halving
the cost of hash collisions. A heavier workload that used to produce 920
entries with 2.01 retries per lookup now reaches 966 entries (94.3% usage
vs 89.8% before) with only 1.44 retries per lookup.

This should be safe to backport, but depends on this previous commit:

    MINOR: tools: extend the pointer hashing code to ease manipulations
src/activity.c