hydra-queue-runner: Start as many builds as possible on each iteration

Because we don't start a build if a dependency is already building,
it's possible that some or all of the $extraAllowed highest-priority
builds in the queue are not eligible.  E.g. with $extraAllowed = 32,
we might start only 3 builds even though there are thousands in the
queue.  The fix is to try all queued builds until $extraAllowed have
been started.

Issue #99.
This commit is contained in:
Eelco Dolstra 2013-06-07 19:18:09 +00:00
parent 2974fea1a7
commit 8e36343b62

View file

@ -100,15 +100,9 @@ sub checkBuilds {
# Select the highest-priority builds to start.
my @builds = $extraAllowed == 0 ? () : $db->resultset('Builds')->search(
{ finished => 0, busy => 0, system => $system->system, enabled => 1 },
{ join => ['project'], order_by => ["priority DESC", "id"],
rows => $extraAllowed });
if (scalar(@builds) > 0) {
print "system type `", $system->system,
"': $nrActive active, $max allowed, ",
"starting ", scalar(@builds), " builds\n";
}
{ join => ['project'], order_by => ["priority DESC", "id"] });
my $started = 0;
foreach my $build (@builds) {
# Find a dependency of $build that has no queued
# dependencies itself. This isn't strictly necessary,
@ -130,6 +124,13 @@ sub checkBuilds {
, starttime => time()
});
push @buildsStarted, $build;
last if ++$started >= $extraAllowed;
}
if ($started > 0) {
print STDERR "system type `", $system->system,
"': $nrActive active, $max allowed, started $started builds\n";
}
}
});