]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: do not try to redistribute the WQ when single-threaded
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2026 08:51:42 +0000 (10:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2026 08:54:07 +0000 (10:54 +0200)
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

index 8eabb463391475bea6bba22ef772b52af926d615..055f26d221c3e90cb2f72fe2f634822d399a35d2 100644 (file)
@@ -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);