]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: buffers: always allocate from the local cache first
authorWilly Tarreau <w@1wt.eu>
Sun, 28 Jun 2020 08:31:15 +0000 (10:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Jun 2020 08:45:35 +0000 (10:45 +0200)
commitd79422a0ffa8ed926326496f45105e4132ebf5f0
treeb6430a63bf496fa5c928e2b26d67c722a30df0fd
parent4dc6c860b4520eaf9fb3f780488107b7011d2387
BUG/MEDIUM: buffers: always allocate from the local cache first

It looked strange to see pool_evict_from_cache() always very present
on "perf top", but there was actually a reason to this: while b_free()
uses pool_free() which properly disposes the buffer into the local cache
and b_alloc_fast() allocates using pool_get_first() which considers the
local cache, b_alloc_margin() does not consider the local cache as it
only uses __pool_get_first() which only allocates from the shared pools.

The impact is that basically everywhere a buffer is allocated (muxes,
streams, applets), it's always picked from the shared pool (hence
involves locking) and is released to the local one and makes it grow
until it's required to trigger a flush using pool_evict_from_cache().
Buffers usage are thus not thread-local at all, and cause eviction of
a lot of possibly useful objects from the local caches.

Just fixing this results in a 10% request rate increase in an HTTP/1 test
on a 16-thread machine.

This bug was caused by recent commit ed891fd ("MEDIUM: memory: make local
pools independent on lockless pools") merged into 2.2-dev9, so not backport
is needed.
include/haproxy/dynbuf.h