forked from lix-project/hydra
* Speed up findBuildDependencyInQueue by doing only one SQL query for
all the dependencies (`drvpath => [ @drvs ]' is an OR).
This commit is contained in:
parent
fbeb5abc69
commit
1495e04d9d
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return unless scalar @drvs > 0;
|
||||||
|
|
||||||
($depBuild) = $db->resultset('Builds')->search(
|
($depBuild) = $db->resultset('Builds')->search(
|
||||||
{ drvpath => $path, finished => 0, busy => 0, enabled => 1, disabled => 0 },
|
{ drvpath => [ @drvs ], finished => 0, busy => 0, enabled => 1, disabled => 0 },
|
||||||
{ join => ['schedulingInfo', 'project'], rows => 1 } ) ;
|
{ join => ['schedulingInfo', 'project'], rows => 1 } ) ;
|
||||||
return $depBuild if defined $depBuild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $depBuild;
|
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);
|
||||||
|
|
Loading…
Reference in a new issue