Skip to content

Commit

Permalink
fix: don't compute closures inside sub loop
Browse files Browse the repository at this point in the history
Just causes extra computation that isn't necessary.
  • Loading branch information
nrdxp committed Jan 24, 2023
1 parent dfc3a3f commit 7bf9ad3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/nix-uncached.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ int main(int argc, char **argv) {
fileTransferSettings.tries = 1;
fileTransferSettings.enableHttp2 = true;

for (auto &storePath : storePaths) {
StorePathSet paths;
store->computeFSClosure(storePath, paths, false, true);

// for sanity, only query remotely buildable paths that have a known
// deriver
for (auto &p : paths) {
auto deriver = store->queryPathInfo(p)->deriver;
if (deriver.has_value()) {
if (store->isValidPath(deriver.value())) {
auto drv = store->derivationFromPath(deriver.value());
auto parsedDrv = ParsedDerivation(deriver.value(), drv);
if (!parsedDrv.getBoolAttr("preferLocalBuild"))
queryPaths[store->printStorePath(storePath)].insert(
store->printStorePath(p));
}
}
}
}

for (auto &sub : getDefaultSubstituters()) {
if (!settings.useSubstitutes)
break;
Expand All @@ -83,26 +103,6 @@ int main(int argc, char **argv) {
if (!sub->wantMassQuery)
continue;

for (auto &storePath : storePaths) {
StorePathSet paths;
store->computeFSClosure(storePath, paths, false, true);

// for sanity, only query remotely buildable paths that have a known
// deriver
for (auto &p : paths) {
auto deriver = store->queryPathInfo(p)->deriver;
if (deriver.has_value()) {
if (store->isValidPath(deriver.value())) {
auto drv = store->derivationFromPath(deriver.value());
auto parsedDrv = ParsedDerivation(deriver.value(), drv);
if (!parsedDrv.getBoolAttr("preferLocalBuild"))
queryPaths[store->printStorePath(storePath)].insert(
store->printStorePath(p));
}
}
}
}

for (auto &map : queryPaths) {
for (auto &path : map.second)
futures[map.first].push_back(std::async(
Expand Down

0 comments on commit 7bf9ad3

Please sign in to comment.