From a82625065951e411f28d319e570ef0e2901ce008 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 25 Feb 2025 08:42:45 +0100 Subject: [PATCH] OPTIM: connection: don't try to kill other threads' connection when !shared Users may have good reasons for using "tune.idle-pool.shared off", one of them being the cost of moving cache lines between cores, or the kernel- side locking associated with moving FDs. For this reason, when getting close to the file descriptors limits, we must not try to kill adjacent threads' FDs when the sharing of pools is disabled. This is extremely expensive and kills the performance. We must limit ourselves to our local FDs only. In such cases, it's up to the users to configure a large enough maxconn for their usages. Before this patch, perf top reported 9% CPU usage in connect_server() onthe trylock used to kill connections when running at 4800 conns for a global maxconn of 6400 on a 128-thread server. Now it doesn't spend its time there anymore, and performance has increased by 12%. Note, it was verified that disabling the locks in such a case has no effect at all, so better keep them and stay safe. --- src/backend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend.c b/src/backend.c index b1703e295..56381a49f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1675,6 +1675,9 @@ int connect_server(struct stream *s) task_wakeup(idle_conns[i].cleanup_task, TASK_WOKEN_OTHER); break; } + + if (!(global.tune.options & GTUNE_IDLE_POOL_SHARED)) + break; } }