diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-19 18:29:42 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-19 18:30:55 -0500 |
commit | 8e388bc39ceb9b1a642359005b320cdc994f8a4e (patch) | |
tree | 554ea67834af1e6622c9385f77dd136c18cfbec8 /src/or/cpuworker.c | |
parent | 5a02406ae0d8059d3b0bbff51d37fcb92650274b (diff) | |
download | tor-8e388bc39ceb9b1a642359005b320cdc994f8a4e.tar.gz tor-8e388bc39ceb9b1a642359005b320cdc994f8a4e.zip |
Only call cull_wedged_cpuworkers once every 60 seconds.
The function is over 10 or 20% on some of Moritz's profiles, depending
on how you could.
Since it's checking for a multi-hour timeout, this is safe to do.
Fixes bug 4518.
Diffstat (limited to 'src/or/cpuworker.c')
-rw-r--r-- | src/or/cpuworker.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index c5e4863f7f..9d196d36eb 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -446,9 +446,19 @@ assign_onionskin_to_cpuworker(connection_t *cpuworker, { char qbuf[1]; char tag[TAG_LEN]; + time_t now = approx_time(); + static time_t last_culled_cpuworkers = 0; - cull_wedged_cpuworkers(); - spawn_enough_cpuworkers(); + /* Checking for wedged cpuworkers requires a linear search over all + * connections, so let's do it only once a minute. + */ +#define CULL_CPUWORKERS_INTERVAL 60 + + if (last_culled_cpuworkers + CULL_CPUWORKERS_INTERVAL <= now) { + cull_wedged_cpuworkers(); + spawn_enough_cpuworkers(); + last_culled_cpuworkers = now; + } if (1) { if (num_cpuworkers_busy == num_cpuworkers) { |