MINOR: stats: Add an option to disable the calculation of max counters

Add a new option, "stats calculate-max-counters [on|off]".
It makes it possible to disable the calculation of max counters, as they
can have a performance cost.
This commit is contained in:
Olivier Houchard 2026-03-02 17:01:58 +01:00 committed by Olivier Houchard
parent 1544842801
commit 5d02d33ee1
4 changed files with 20 additions and 2 deletions

View File

@ -3604,6 +3604,11 @@ ssl-skip-self-issued-ca
certificates. It's useless for BoringSSL, .issuer is ignored because ocsp
bits does not need it. Requires at least OpenSSL 1.0.2.
stats calculate-max-counters [on|off]
Activates or deactivates the calculation of stats max counters. If you
don't need them, deactivating them may increase performances a bit.
The default is on.
stats maxconn <connections>
By default, the stats socket is limited to 10 concurrent connections. It is
possible to change this value with "stats maxconn".

View File

@ -26,6 +26,7 @@
#include <haproxy/counters-t.h>
#include <haproxy/guid-t.h>
#include <haproxy/global.h>
extern THREAD_LOCAL void *trash_counters;
@ -105,7 +106,8 @@ void counters_be_shared_drop(struct be_counters_shared *counters);
#define COUNTERS_UPDATE_MAX(counter, count) \
do { \
HA_ATOMIC_UPDATE_MAX(counter, count); \
if (!(global.tune.options & GTUNE_NO_MAX_COUNTER)) \
HA_ATOMIC_UPDATE_MAX(counter, count); \
} while (0)
/* Manipulation of extra_counters, for boot-time registrable modules */

View File

@ -86,6 +86,7 @@
#define GTUNE_LISTENER_MQ_OPT (1<<28)
#define GTUNE_LISTENER_MQ_ANY (GTUNE_LISTENER_MQ_FAIR | GTUNE_LISTENER_MQ_OPT)
#define GTUNE_NO_KTLS (1<<29)
#define GTUNE_NO_MAX_COUNTER (1<<30)
/* subsystem-specific debugging options for tune.debug */
#define GDBG_CPU_AFFINITY (1U<< 0)

View File

@ -616,12 +616,22 @@ static int cli_parse_global(char **args, int section_type, struct proxy *curpx,
}
global.cli_fe->maxconn = maxconn;
}
else if (strcmp(args[1], "calculate-max-counters") == 0) {
if (!strcasecmp(args[2], "on"))
return 0;
else if (!strcasecmp(args[2], "off")) {
global.tune.options |= GTUNE_NO_MAX_COUNTER;
return 0;
}
memprintf(err, "'%s' only supports 'on' and 'off', received '%s'", args[1], args[2]);
return -1;
}
else if (strcmp(args[1], "bind-process") == 0) {
memprintf(err, "'%s %s' is not supported anymore.", args[0], args[1]);
return -1;
}
else {
memprintf(err, "'%s' only supports 'socket', 'maxconn', 'bind-process' and 'timeout' (got '%s')", args[0], args[1]);
memprintf(err, "'%s' only supports 'socket', 'maxconn', 'bind-process', 'calculate-max-counters' and 'timeout' (got '%s')", args[0], args[1]);
return -1;
}
return 0;