]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: memory: make the pool cache an array and not a thread_local
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 16:09:46 +0000 (17:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 18:50:32 +0000 (19:50 +0100)
commit7f0165e3990ee8ceca3a6fbb6d4e2728eb889730
treed2ccc157354767d70007130b4bd9b34b4bf28013
parentb6b3df3ed3476141f39a3d57b87f801c659e773c
MEDIUM: memory: make the pool cache an array and not a thread_local

Having a thread_local for the pool cache is messy as we need to
initialize all elements upon startup, but we can't until the threads
are created, and once created it's too late. For this reason, the
allocation code used to check for the pool's initialization, and
it was the release code which used to detect the first call and to
initialize the cache on the fly, which is not exactly optimal.

Now that we have initcalls, let's turn this into a per-thread array.
This array is initialized very early in the boot process (STG_PREPARE)
so that pools are always safe to use. This allows to remove the tests
from the alloc/free calls.

Doing just this has removed 2.5 kB of code on all cumulated pool_alloc()
and pool_free() paths.
include/common/buffer.h
include/common/memory.h
src/memory.c