]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: pools: implement a thread-local cache for pool entries
authorWilly Tarreau <w@1wt.eu>
Tue, 16 Oct 2018 08:28:54 +0000 (10:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Oct 2018 11:46:08 +0000 (13:46 +0200)
commite18db9e984e69e3802868bac10ce0703ce31e7d0
treea597d1567905196bddb45be877f45a5cb45cdf56
parent146794dc4f9274fda29283c58de1502a2ada3f73
MEDIUM: pools: implement a thread-local cache for pool entries

Each thread now keeps the last ~512 kB of freed objects into a local
cache. There are some heuristics involved so that a specific pool cannot
use more than 1/8 of the total cache in number of objects. Tests have
shown that 512 kB is an optimal size on a 24-thread test running on a
dual-socket machine, resulting in an overall 7.5% performance increase
and a cache miss ratio reducing from 19.2 to 17.7%. Anyway it seems
pointless to keep more than an L2 cache, which probably explains why
sizes between 256 and 512 kB are optimal.

Cached objects appear in two lists, one per pool and one LRU to help
with fair eviction. Currently there is no way to check each thread's
cache state nor to flush it. This cache cannot be disabled and is
enabled as soon as the lockless pools are enabled (i.e.: threads are
enabled, no pool debugging is in use and the CPU supports a double word
CAS).
include/common/buffer.h
include/common/config.h
include/common/memory.h
src/memory.c