* Speed up findBuildDependencyInQueue by doing only one SQL query for

all the dependencies (`drvpath => [ @drvs ]' is an OR).
This commit is contained in:
Eelco Dolstra 2010-08-31 16:19:33 +00:00
parent fbeb5abc69
commit 1495e04d9d

View file

@ -50,23 +50,27 @@ sub unlockDeadBuilds {
}); });
} }
sub findBuildDependencyInQueue { sub findBuildDependencyInQueue {
my ($build) = @_; my ($build) = @_;
my $drvpath = $build->drvpath; my $drvpath = $build->drvpath;
my @paths = reverse(split '\n', `nix-store -qR $drvpath`); my @paths = reverse(split '\n', `nix-store -qR $drvpath`);
my $depBuild; my $depBuild;
my @drvs = ();
foreach my $path (@paths) { foreach my $path (@paths) {
if($path ne $drvpath) { push @drvs, $path if $path =~ /\.drv$/ && $path ne $drvpath;
($depBuild) = $db->resultset('Builds')->search( }
{ drvpath => $path, finished => 0, busy => 0, enabled => 1, disabled => 0 },
{ join => ['schedulingInfo', 'project'], rows => 1 } ) ; return unless scalar @drvs > 0;
return $depBuild if defined $depBuild;
} ($depBuild) = $db->resultset('Builds')->search(
} { drvpath => [ @drvs ], finished => 0, busy => 0, enabled => 1, disabled => 0 },
return $depBuild; { join => ['schedulingInfo', 'project'], rows => 1 } ) ;
return $depBuild;
} }
sub checkBuilds { sub checkBuilds {
print "looking for runnable builds...\n"; print "looking for runnable builds...\n";
@ -107,9 +111,7 @@ sub checkBuilds {
foreach my $build (@builds) { foreach my $build (@builds) {
my $depbuild = findBuildDependencyInQueue($build); my $depbuild = findBuildDependencyInQueue($build);
if(defined $depbuild) { $build = $depbuild if defined $depbuild;
$build = $depbuild;
}
my $logfile = getcwd . "/logs/" . $build->id; my $logfile = getcwd . "/logs/" . $build->id;
mkdir(dirname $logfile); mkdir(dirname $logfile);