]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: pool: check one other random bucket on alloc conflict
authorWilly Tarreau <w@1wt.eu>
Wed, 8 Nov 2023 15:44:20 +0000 (16:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 8 Nov 2023 16:12:49 +0000 (17:12 +0100)
commita9ae094b271d8e8d2d71082f541a1e98b88421ee
tree0144612a2b115c8cd93d94ee867986940d0fc964
parent89c6b67a8241cdc56b42ecea52983e632f00b3bc
BUG/MINOR: pool: check one other random bucket on alloc conflict

Since 2.9-dev3 with commit 7bf829ace ("MAJOR: pools: move the shared
pool's free_list over multiple buckets"), the global pool supports
multiple heads to reduce inter-thread contention. However, when
grabbing a freelist head fails because another thread is already
picking from it, we just skip to the next one and try again.

Unfortunately, it still maintains a bit of contention between thread
pairs when for some reasons only a few threads are used. This may
happen for example when running on a 4- or 8- thread system and
the two most active ones end up on adjacent buckets.

A better and much simpler solution consists in visiting a random bucket
instead of the current one. Tests show that the CPU usage spent in
pool_refill_local_from_shared() reduces at low number of connections
(hence threads).

No backport is needed, as the issue is only in 2.9.
src/pool.c