]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Always start with one additional worker thread
authorNick Mathewson <nickm@torproject.org>
Wed, 12 Jul 2017 16:23:33 +0000 (12:23 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 27 Jul 2017 20:28:59 +0000 (16:28 -0400)
Now that half the threads are permissive and half are strict, we
need to make sure we have at least two threads, so that we'll
have at least one of each kind.

changes/more-threads [new file with mode: 0644]
src/or/cpuworker.c

diff --git a/changes/more-threads b/changes/more-threads
new file mode 100644 (file)
index 0000000..eae88b7
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor features (relay, performance):
+    - Always start relays with at least two worker threads, to prevent
+      priority inversion on slow tasks.  Part of the fix for bug 22883.
index ad99af64c01db423cc338507ff1856601c8c142d..8d71483f817759174ab4e2cc47a104dd1ee3f944 100644 (file)
@@ -89,7 +89,14 @@ cpu_init(void)
     event_add(reply_event, NULL);
   }
   if (!threadpool) {
-    threadpool = threadpool_new(get_num_cpus(get_options()),
+    /*
+      In our threadpool implementation, half the threads are permissive and
+      half are strict (when it comes to running lower-priority tasks). So we
+      always make sure we have at least two threads, so that there will be at
+      least one thread of each kind.
+    */
+    const int n_threads = get_num_cpus(get_options()) + 1;
+    threadpool = threadpool_new(n_threads,
                                 replyqueue,
                                 worker_state_new,
                                 worker_state_free,