]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Reduce the number of hazard pointers
authorOndřej Surý <ondrej@isc.org>
Tue, 7 Dec 2021 19:35:58 +0000 (20:35 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 7 Dec 2021 20:12:53 +0000 (21:12 +0100)
Previously, we set the number of the hazard pointers to be 4 times the
number of workers because the dispatch ran on the old socket code.
Since the old socket code was removed there's a smaller number of
threads, namely:

 - 1 main thread
 - 1 timer thread
 - <n> netmgr threads
 - <n> threadpool threads

Set the number of hazard pointers to 2 + 2 * workers.

lib/isc/managers.c
lib/isc/tests/doh_test.c

index 094e4c0eb8dbd75b78fb937dd3892189ee8bd75c..b57f8ab7c6afe72eecf2f94563c7e8159e41f4fd 100644 (file)
@@ -27,10 +27,13 @@ isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
        isc_timermgr_t *timermgr = NULL;
 
        /*
-        * We have ncpus network threads, ncpus old network threads - make
-        * it 4x just to be on the safe side.
+        * Currently, there are:
+        * - 1 main thread
+        * - 1 timer thread
+        * - n netmgr threads
+        * - n threadpool threads
         */
-       isc_hp_init(4 * workers);
+       isc_hp_init(2 + 2 * workers);
 
        REQUIRE(netmgrp != NULL && *netmgrp == NULL);
        isc__netmgr_create(mctx, workers, &netmgr);
index 117728554dac9dde1c165d6e45c5f33f448323ac..7a2c06571b2861bff2638397fc12fd1c2a709549 100644 (file)
@@ -27,6 +27,7 @@
 #include <isc/atomic.h>
 #include <isc/buffer.h>
 #include <isc/condition.h>
+#include <isc/hp.h>
 #include <isc/mutex.h>
 #include <isc/netmgr.h>
 #include <isc/nonce.h>
@@ -256,6 +257,8 @@ _setup(void **state) {
                return (-1);
        }
 
+       isc_hp_init(4 * workers);
+
        signal(SIGPIPE, SIG_IGN);
 
        return (0);