Skip to content

Commit

Permalink
Make affinity-threshold calculation simpler
Browse files Browse the repository at this point in the history
By unshifting an element into the constant array with threshold values
so that we don't need to do a -1 everytime
  • Loading branch information
lizmat committed Mar 27, 2018
1 parent 637147a commit 04014cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/ThreadPoolScheduler.pm6
Expand Up @@ -373,7 +373,7 @@ my class ThreadPoolScheduler does Scheduler {
)
}

constant @affinity-add-thresholds = 1, 5, 10, 20, 50, 100;
constant @affinity-add-thresholds = 0, 1, 5, 10, 20, 50, 100;
method !affinity-queue() {
# If there's no affinity workers, start one.
nqp::unless(
Expand Down Expand Up @@ -434,7 +434,7 @@ my class ThreadPoolScheduler does Scheduler {
# worker thread.
my $chosen-queue := $most-free-worker.queue;
my $threshold = @affinity-add-thresholds[
($cur-affinity-workers.elems min @affinity-add-thresholds) - 1
$cur-affinity-workers.elems min @affinity-add-thresholds
];
if $chosen-queue.elems > $threshold {
# Add another one, unless another thread did too.
Expand Down

0 comments on commit 04014cf

Please sign in to comment.