]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: stats-file/counters: store and preload stats counters as shm file objects
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 27 Aug 2025 15:23:42 +0000 (17:23 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 3 Sep 2025 13:59:37 +0000 (15:59 +0200)
commit585ece4c9237eb6faa7787f3a58000815697f455
tree2a860511f809f3157ea07ca0bb498e18568aba42
parentee17d2024528efc7aebce63d97fa7c64e701f83e
MEDIUM: stats-file/counters: store and preload stats counters as shm file objects

This is the last patch of the shm stats file series, in this patch we
implement the logic to store and fetch shm stats objects and associate
them to existing shared counters on the current process.

Shm objects are stored in the same memory location as the shm stats file
header. In fact they are stored right after it. All objects (struct
shm_stats_file_object) have the same size (no matter their type), which
allows for easy object traversal without having to check the object's
type, and could permit the use of external tools to scan the SHM in the
future. Each object stores a guid (of GUID_MAX_LEN+1 size) and tgid
which allows to match corresponding shared counters indexes. Also,
as stated before, each object stores the list of users making use of
it. Objects are never released (the map can only grow), but unused
objects (when no more users or active users are found in objects->users),
the object is automatically recycled. Also, each object stores its
type which defines how the object generic data member should be handled.

Upon startup (or reload), haproxy first tries to scan existing shm to
find objects that could be associated to frontends, backends, listeners
or servers in the current config based on GUID. For associations that
couldn't be made, haproxy will automatically create missing objects in
the SHM during late startup. When haproxy matches with an existing object,
it means the counter from an older process is preserved in the new
process, so multiple processes temporarily share the same counter for as
long as required for older processes to eventually exit.
include/haproxy/stats-file-t.h
include/haproxy/stats-file.h
src/counters.c
src/stats-file.c