From 78cc7dacbb3f32a1ebdd46e1339d1c2317fdd851 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 25 Jun 2026 10:51:42 +0200 Subject: [PATCH] MINOR: task: do not try to redistribute the WQ when single-threaded When running with nbthread=1, we still try to redistribute once, it fails (new_tid=tid) and leaves the loop. That's just a waste for no reason. Let's condition the redispatch to the presence of at least another thread. --- src/task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/task.c b/src/task.c index 8eabb4633..055f26d22 100644 --- a/src/task.c +++ b/src/task.c @@ -388,7 +388,7 @@ void wake_expired_tasks() * If it's a shared task, see whether we should hand it * to a less loaded thread. */ - if (task->tid < 0) { + if (unlikely(task->tid < 0) && global.nbthread > 1) { int attempts = MIN(global.nbthread, 3); while (attempts-- > 0) { uint new_tid = statistical_prng_range(global.nbthread); -- 2.47.3