From: Olivier Houchard Date: Wed, 1 Apr 2026 13:01:09 +0000 (+0200) Subject: MINOR: backends: Don't update last_sess if it did not change X-Git-Tag: v3.4-dev8~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaf42ee886546ee889767841bce1b813521dd16a;p=thirdparty%2Fhaproxy.git MINOR: backends: Don't update last_sess if it did not change Check that last_sess actually changed before attempting to set it, as it should only change once every second, that will avoid a lot of atomic writes on a busy cache line. --- diff --git a/include/haproxy/backend.h b/include/haproxy/backend.h index 6930ff256..263a2e2c2 100644 --- a/include/haproxy/backend.h +++ b/include/haproxy/backend.h @@ -99,8 +99,11 @@ static inline int be_is_eligible(const struct proxy *be) /* set the time of last session on the backend */ static inline void be_set_sess_last(struct proxy *be) { + uint now_sec = ns_to_sec(now_ns); + if (be->be_counters.shared.tg) - HA_ATOMIC_STORE(&be->be_counters.shared.tg[tgid - 1]->last_sess, ns_to_sec(now_ns)); + if (HA_ATOMIC_LOAD(&be->be_counters.shared.tg[tgid - 1]->last_sess) != now_sec) + HA_ATOMIC_STORE(&be->be_counters.shared.tg[tgid - 1]->last_sess, now_sec); } /* This function returns non-zero if the designated server will be