]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM/MINOR: init/threads: only call protocol_enable_all() on first thread
authorWilly Tarreau <w@1wt.eu>
Mon, 10 Jun 2019 08:14:52 +0000 (10:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 10 Jun 2019 08:53:59 +0000 (10:53 +0200)
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

index 5732f2d907763a585c7a29bbe074daa1a6cfe302..a8898b78d4c6ab0294c1043fedb8224d30bc0ca5 100644 (file)
@@ -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();