[tor-commits] [tor] branch main updated: cpu: Set number of threads to number of cores

gitolite role git at cupani.torproject.org
Mon Nov 28 14:34:26 UTC 2022


This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

The following commit(s) were added to refs/heads/main by this push:
     new b9de73e46e cpu: Set number of threads to number of cores
     new 3ac08ac200 Merge branch 'tor-gitlab/mr/658'
b9de73e46e is described below

commit b9de73e46ea86de1ca1e4810cd14ea21c81acfc8
Author: David Goulet <dgoulet at torproject.org>
AuthorDate: Wed Nov 23 13:40:47 2022 -0500

    cpu: Set number of threads to number of cores
    
    Cap this to 2 threads always because we need a low and high priority
    thread even with a single core.
    
    Fixes #40713
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 changes/ticket40713           | 4 ++++
 src/core/mainloop/cpuworker.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/changes/ticket40713 b/changes/ticket40713
new file mode 100644
index 0000000000..eaddfd30d7
--- /dev/null
+++ b/changes/ticket40713
@@ -0,0 +1,4 @@
+  o Minor feature (cpuworker):
+    - Always use the number of threads for our CPU worker pool to the number of
+      core available but cap it to a minimum of 2 in case of a single core.
+      Fixes bug 40713; bugfix on 0.3.5.1-alpha.
diff --git a/src/core/mainloop/cpuworker.c b/src/core/mainloop/cpuworker.c
index 3ad556a184..0459f22efe 100644
--- a/src/core/mainloop/cpuworker.c
+++ b/src/core/mainloop/cpuworker.c
@@ -129,7 +129,7 @@ cpu_init(void)
       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;
+    const int n_threads = MAX(get_num_cpus(get_options()), 2);
     threadpool = threadpool_new(n_threads,
                                 replyqueue,
                                 worker_state_new,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list