From 0ae0b5aa4136fe6df7863c8a5b7d239d519b7393 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Jul 2017 12:17:51 -0400 Subject: Queue consensus diffs at LOW priority. Fixes bug 22883. --- src/or/cpuworker.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/or/cpuworker.c') diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 1013fa555e..ad99af64c0 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -481,16 +481,18 @@ queue_pending_tasks(void) /** DOCDOC */ MOCK_IMPL(workqueue_entry_t *, -cpuworker_queue_work,(workqueue_reply_t (*fn)(void *, void *), +cpuworker_queue_work,(workqueue_priority_t priority, + workqueue_reply_t (*fn)(void *, void *), void (*reply_fn)(void *), void *arg)) { tor_assert(threadpool); - return threadpool_queue_work(threadpool, - fn, - reply_fn, - arg); + return threadpool_queue_work_priority(threadpool, + priority, + fn, + reply_fn, + arg); } /** Try to tell a cpuworker to perform the public key operations necessary to @@ -545,7 +547,8 @@ assign_onionskin_to_cpuworker(or_circuit_t *circ, memwipe(&req, 0, sizeof(req)); ++total_pending_tasks; - queue_entry = threadpool_queue_work(threadpool, + queue_entry = threadpool_queue_work_priority(threadpool, + WQ_PRI_HIGH, cpuworker_onion_handshake_threadfn, cpuworker_onion_handshake_replyfn, job); -- cgit v1.2.3-54-g00ecf From 250c88014d81fcd4406359d44c9f3f3432844a2f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Jul 2017 12:23:33 -0400 Subject: Always start with one additional worker thread 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 | 3 +++ src/or/cpuworker.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changes/more-threads (limited to 'src/or/cpuworker.c') diff --git a/changes/more-threads b/changes/more-threads new file mode 100644 index 0000000000..eae88b70fd --- /dev/null +++ b/changes/more-threads @@ -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. diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index ad99af64c0..8d71483f81 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -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, -- cgit v1.2.3-54-g00ecf From fdd8156ea3da9548b99ab95d72e3193ae9de3feb Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 27 Jul 2017 16:18:40 -0400 Subject: Fix the cpuworker.c documentation to mention all the kinds of work --- src/or/cpuworker.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/or/cpuworker.c') diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 8d71483f81..f5fff2b331 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -11,8 +11,11 @@ * The multithreading backend for this module is in workqueue.c; this module * specializes workqueue.c. * - * Right now, we only use this for processing onionskins, and invoke it mostly - * from onion.c. + * Right now, we use this infrastructure + *
  • for processing onionskins in onion.c + *
  • for compressing consensuses in consdiffmgr.c, + *
  • and for calculating diffs and compressing them in consdiffmgr.c. + *
**/ #include "or.h" #include "channel.h" -- cgit v1.2.3-54-g00ecf