]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: server: add and use a separate last_change variable for internal use
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 30 Jun 2025 08:57:29 +0000 (10:57 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 30 Jun 2025 14:26:25 +0000 (16:26 +0200)
commit01dfe17acf5b16471482f4f80849d3cddee9b613
tree76525492491e1963c35822b488a97d488038207e
parent9d3c73c9f2c7650de356c4b75cb114a6a60282c4
MEDIUM: server: add and use a separate last_change variable for internal use

last_change server metric is used for 2 separate purposes. First it is
used to report last server state change date for stats and other related
metrics. But it is also used internally, including in sensitive paths,
such as lb related stuff to take decision or perform computations
(ie: in srv_dynamic_maxconn()).

Due to last_change counter now being split over thread groups since 16eb0fa
("MAJOR: counters: dispatch counters over thread groups"), reading the
aggregated value has a cost, and we cannot afford to consult last_change
value from srv_dynamic_maxconn() anymore. Moreover, since the value is
used to take decision for the current process we don't wan't the variable
to be updated by another process in our back.

To prevent performance regression and sharing issues, let's instead add a
separate srv->last_change value, which is not updated atomically (given how
rare the  updates are), and only serves for places where the use of the
aggregated last_change counter/stats (split over thread groups) is too
costly.
include/haproxy/server-t.h
src/check.c
src/proxy.c
src/queue.c
src/server.c
src/server_state.c