From 8e36343b62a1fc19054eebbf68761f07371d1481 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Jun 2013 19:18:09 +0000 Subject: [PATCH] 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. --- src/script/hydra-queue-runner | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/script/hydra-queue-runner b/src/script/hydra-queue-runner index f876bce2..43a6ed16 100755 --- a/src/script/hydra-queue-runner +++ b/src/script/hydra-queue-runner @@ -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"; } } });