From: Frederic Lecaille Date: Fri, 24 Jul 2026 10:06:23 +0000 (+0200) Subject: BUG/MINOR: haload: fix CPU topology detection by omitting forced "nbthread" X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=be66535ab904ed76d8c8165249ab0db5a570e359;p=thirdparty%2Fhaproxy.git BUG/MINOR: haload: fix CPU topology detection by omitting forced "nbthread" Always writing "nbthread" in the generated global configuration forced a static thread count, preventing HAProxy from using its automatic CPU topology detection and correct core binding. This caused severe performance degradation on large multi-core machines. Fix this by omitting the "nbthread" directive when -t is not explicitly specified, while ensuring is properly initialized to global.nbthread for internal calculations such as connection and request rates. Also ensure <= when -R is specified for internal calculations. --- diff --git a/src/haload.c b/src/haload.c index e13e3cf77..91b036ca1 100644 --- a/src/haload.c +++ b/src/haload.c @@ -100,7 +100,7 @@ int arg_rcon = -1; // max requests per conn int arg_reqs = -1; // max total requests int arg_serr; // stop on first error int arg_slow; // slow start: delay in milliseconds -int arg_thrd = 1; // number of threads +int arg_thrd; // number of threads int arg_usr = 1; // number of users int arg_wait = 10000; // I/O time out (ms) @@ -1916,6 +1916,20 @@ static int hld_init(void) if (!hld_cfg_finalize()) goto err; + /* This is the location to initialize the default value for . + * Indeed, global.nthread is initialized late(after the parsing step). + */ + if (arg_thrd == 0) + arg_thrd = global.nbthread; + + if (arg_rate && arg_thrd > arg_usr) { + ha_alert("Thread count (%d) must not exceed connection count (%d)\n", + arg_thrd, arg_usr); + goto err; + } + + BUG_ON(arg_thrd != global.nbthread); + /* Consider the case where < */ if (arg_reqs != -1 && arg_reqs < arg_usr) arg_usr = arg_reqs; diff --git a/src/haload_init.c b/src/haload_init.c index 8da0b8f95..82770eae6 100644 --- a/src/haload_init.c +++ b/src/haload_init.c @@ -28,7 +28,7 @@ static void hld_usage(char *name, int argc) " -n maximum total requests (-1)\n" " -r number of requests per connection (-1)\n" " -s