Skip to content

Commit

Permalink
Only tweak-workers if there's something to tweak
Browse files Browse the repository at this point in the history
- tweak-workers should now only be called if there's something in the queue
- by moving the test outside, we don't need to call tweak-workers
- makes test-t 20 race about 3% faster
  • Loading branch information
lizmat committed Oct 27, 2017
1 parent 2cd568f commit 6bf5892
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/ThreadPoolScheduler.pm
Expand Up @@ -505,11 +505,11 @@ my class ThreadPoolScheduler does Scheduler {
my $smooth-per-core-util = @last-utils.sum;
scheduler-debug-status "Per-core utilization (approx): $smooth-per-core-util%";

if $!general-queue.DEFINITE {
if $!general-queue.DEFINITE && $!general-queue.elems {
self!tweak-workers: $!general-queue, $!general-workers,
&add-general-worker, $cpu-cores, $smooth-per-core-util;
}
if $!timer-queue.DEFINITE {
if $!timer-queue.DEFINITE && $!timer-queue.elems {
self!tweak-workers: $!timer-queue, $!timer-workers,
&add-timer-worker, $cpu-cores, $smooth-per-core-util;
}
Expand Down Expand Up @@ -552,12 +552,11 @@ my class ThreadPoolScheduler does Scheduler {
nqp::atpos_i(rusage, nqp::const::RUSAGE_STIME_MSEC)
}

# Tweak workers for non-empty queues
method !tweak-workers(\queue, \worker-list, &add-worker, $cores, $per-core-util) {
# If there's nothing in the queue, nothing could need an extra worker.
return if queue.elems == 0;

# Go through the worker list. If something is not working, then there
# is at lesat one worker free to process things in the queue, so we
# is at least one worker free to process things in the queue, so we
# don't need to add one.
my int $total-completed;
my int $total-times-nothing-completed;
Expand Down

0 comments on commit 6bf5892

Please sign in to comment.