From 7bf9ad3f629ea35b7a8dd97f90f9a87c8fd489a5 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Mon, 23 Jan 2023 18:47:57 -0700 Subject: [PATCH] fix: don't compute closures inside sub loop Just causes extra computation that isn't necessary. --- src/nix-uncached.cc | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/nix-uncached.cc b/src/nix-uncached.cc index 6edd746..fae320c 100644 --- a/src/nix-uncached.cc +++ b/src/nix-uncached.cc @@ -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; @@ -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(