Skip to content

Commit

Permalink
Use shift/push again
Browse files Browse the repository at this point in the history
- but as nqp::shift/nqp::push, timotimo++ for pointing out
- don't think it suffers too much in readability from the original shift/push
- indexing solution was about 2x as fast as the original shift/push
- this is again 4x faster than the indexing solution
- shaves off about 1% of test-t 20 race
  • Loading branch information
lizmat committed Oct 27, 2017
1 parent 6de66df commit 6aa150d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/ThreadPoolScheduler.pm
Expand Up @@ -475,7 +475,6 @@ my class ThreadPoolScheduler does Scheduler {
my num $last-rusage-time = nqp::time_n;
my int $last-usage = self!getrusage-total();
my num @last-utils = 0e0 xx NUM_SAMPLES;
my int $sampled;
my int $cpu-cores = nqp::cpucores();
scheduler-debug "Supervisor thinks there are $cpu-cores CPU cores";
loop {
Expand All @@ -501,7 +500,8 @@ my class ThreadPoolScheduler does Scheduler {

# Since those values are noisy, average the last
# NUM_SAMPLES values to get a smoothed value.
@last-utils[++$sampled % NUM_SAMPLES] = $per-core-util;
nqp::shift_n(@last-utils);
nqp::push_n(@last-utils,$per-core-util);
my $smooth-per-core-util = @last-utils.sum;
scheduler-debug-status "Per-core utilization (approx): $smooth-per-core-util%";

Expand Down

0 comments on commit 6aa150d

Please sign in to comment.