]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: stats-file: don't unnecessarily die hard on shm_stats_file_reuse_object()
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 29 Aug 2025 13:34:10 +0000 (13:34 +0000)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 3 Sep 2025 14:28:41 +0000 (16:28 +0200)
commitcf2562cddf7c32c540ef55d1f5a28094b972fb2f
treebff15c935b167940daed25c77361b2cd7e54f523
parent16abfb6e06873d90a6d55fd6755a40dd208a21df
OPTIM: stats-file: don't unnecessarily die hard on shm_stats_file_reuse_object()

shm_stats_file_reuse_object() has a non negligible cost, especially if
the shm file contains a lot of objects because the functions scans the
whole shm file to find available slots.

During startup, if no existing objects could be mapped in the shm
file shm_stats_file_add_object() for each object (server, fe, be or
listener) with a GUID set. On large config it means
shm_stats_file_add_object() could be called a lot of times in a row.

With current implementation, each shm_stats_file_add_object() call
leverages shm_stats_file_reuse_object(), so the more objects are defined
in the config, the slower the startup will be.

To try to optimize startup time a bit with large configs, we don't
sytematically call shm_stats_file_reuse_object(), especially when we
know that the previous attempt to reuse objects failed. In this case
we add a small tempo between failed attempts to reuse objects because
we assume the new attempt will probably fail anyway. (For slots to
become available, either an old process has to clean its entries,
or they have to time out which implies that the clock needs to be updated)
src/stats-file.c