From 77dbf55abbf1a668918e7d18c2eb641b4fd21712 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 21 Sep 2013 19:54:58 +0000 Subject: [PATCH] hydra-queue-runner: Tweaked the selection method Pick the jobset that has used the smallest fraction of its share, rather than the jobset furthest below its share in absolute terms. This gives jobsets with a small share a quicker start (but they will also run out of their share quicker). --- src/script/hydra-queue-runner | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/script/hydra-queue-runner b/src/script/hydra-queue-runner index 6172bd32..370ea7e2 100755 --- a/src/script/hydra-queue-runner +++ b/src/script/hydra-queue-runner @@ -145,15 +145,15 @@ sub checkBuilds { $timeSpentPerJobset->{$b->get_column('project')}->{$b->get_column('jobset')} = $timeSpent; } - my $share = $jobset->schedulingshares; - my $delta = ($share / $totalShares) - ($duration / $totalWindowSize); + my $share = $jobset->schedulingshares || 1; # prevent division by zero + my $used = $timeSpent / ($totalWindowSize * ($share / $totalShares)); - #printf STDERR "%s:%s: %d s, %.3f%%, allowance = %.3f%%\n", $jobset->get_column('project'), $jobset->name, $duration, $duration / $totalWindowSize, $delta; + #printf STDERR "%s:%s: %d s, total used = %.2f%%, share used = %.2f%%\n", $jobset->get_column('project'), $jobset->name, $timeSpent, $timeSpent / $totalWindowSize * 100, $used * 100; - push @res, { jobset => $jobset, delta => $delta }; + push @res, { jobset => $jobset, used => $used }; } - foreach my $r (sort { $b->{delta} <=> $a->{delta} } @res) { + foreach my $r (sort { $a->{used} <=> $b->{used} } @res) { my $jobset = $r->{jobset}; #print STDERR "selected ", $jobset->get_column('project'), ':', $jobset->name, "\n"; @@ -173,8 +173,8 @@ sub checkBuilds { } next if $build->busy; - printf STDERR "starting build %d (%s:%s:%s) on %s (jobset allowance = %.3f%%)\n", - $build->id, $build->project->name, $build->jobset->name, $build->job->name, $build->system, $r->{delta}; + printf STDERR "starting build %d (%s:%s:%s) on %s; jobset at %.2f%% of its share\n", + $build->id, $build->project->name, $build->jobset->name, $build->job->name, $build->system, $r->{used} * 100; my $logfile = getcwd . "/logs/" . $build->id; mkdir(dirname $logfile);