Previously this function didn't actually have a lot of effect. If a build A had a dependency B, Hydra would start B first. But on the next scan through the queue, it would start A anyway, because of the "busy => 0" restriction.
Now the queue runner won't start a build if a dependency is already running. (This is not necessarily optimal, since the build may have other dependencies that don't correspond to a build in the queue but could run. One day we'll start all Hydra builds in parallel…)
Also, for performance, use computeFSClosure instead of "nix-store -qR". And don't bother with topological sorting because it didn't have an effect anyway since the database returns dependencies in arbitrary order.
YEXD7CBKPTMRCYQFNJFWXJUFOAKXNCVVYYJW3PHXQ5CX53Y5CUGQC Y6AHH4THYQA43V77L43YM42DYRPCMDSWLUV4NKWAQYMPL4NTUIPQC 7YBYT2LQML2PKEO6UO4444AGSASS664UCDXW2YO3ALB7THQHCEBQC OV7F5M3EQBESXVE3GGPXCTEBF2KZH6CUM6ZTXEF72HDSKRLUIZRAC PYTQMQKDYAR66MOX2V7ZHLCJKHASTLTEVVJXCEY3LMRDXCCXAU4QC DTXTS7LNTY43YDI5FXVDEJZ75JMR4OW6WS7ZBUXXM3L242VEIIWQC MOX7XJ2E3XISXA7V7T4W6GEAGECGWBZ4PYSLTYBVVR4VAKOI33CQC DQD7JMSUAPXKASPXUDXY4LCE6QCAZSGWNQYTOKNIQE6RRSRP4KGAC my $drvpath = $build->drvpath;my @paths = reverse(split '\n', `nix-store -qR $drvpath`);my $depBuild;my @drvs = ();foreach my $path (@paths) {push @drvs, $path if $path =~ /\.drv$/ && $path ne $drvpath;}return unless scalar @drvs > 0;($depBuild) = $db->resultset('Builds')->search({ drvpath => [ @drvs ], finished => 0, busy => 0, enabled => 1, disabled => 0 },{ join => ['project'], rows => 1 } ) ;return $depBuild;
my @deps = grep { /\.drv$/ && $_ ne $build->drvpath } computeFSClosure(0, 0, $build->drvpath);return unless scalar @deps > 0;return $db->resultset('Builds')->search({ drvpath => [ @deps ], finished => 0, enabled => 1, disabled => 0 },{ join => ['project'], rows => 1 })->single;
my $depbuild = findBuildDependencyInQueue($build);$build = $depbuild if defined $depbuild;
# Find a dependency of $build that has no queued# dependencies itself. This isn't strictly necessary,# but it ensures that Nix builds are done as part of# their corresponding Hydra builds, rather than as a# dependency of some other Hydra build.while (my $dep = findBuildDependencyInQueue($build)) {$build = $dep;}next if $build->busy;