From e4d7c9dd65c197b6b948d98a4b9ea11c23f9bdd4 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 10 Jun 2019 10:14:52 +0200 Subject: [PATCH] OPTIM/MINOR: init/threads: only call protocol_enable_all() on first thread There's no point in calling this on each and every thread since the first thread passing there will enable the listeners, and the next ones will simply scan all of them in turn to discover that they are already initialized. Let's only initilize them on the first thread. This could slightly speed up start up on very large configurations, eventhough most of the time is still spent in the main thread binding the sockets. A few measurements have constantly shown that this decreases the startup time by ~0.1s for 150k listeners. Starting all of them in parallel doesn't provide better results and can still expose some undesired races. --- src/haproxy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/haproxy.c b/src/haproxy.c index 5732f2d907..a8898b78d4 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2611,7 +2611,8 @@ static void *run_thread_poll_loop(void *data) thread_sync_release(); thread_isolate(); - protocol_enable_all(); + if (tid == 0) + protocol_enable_all(); /* done initializing this thread, don't start before others are done */ thread_sync_release(); -- 2.39.5