1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

copyPaths(): Use queryValidPaths() to reduce SSH latency

This commit is contained in:
Eelco Dolstra 2017-03-16 13:50:01 +01:00
parent 91d67692cf
commit c5b83d8913
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
10 changed files with 45 additions and 37 deletions

View file

@ -377,7 +377,7 @@ void Store::queryPathInfo(const Path & storePath,
}
PathSet Store::queryValidPaths(const PathSet & paths)
PathSet Store::queryValidPaths(const PathSet & paths, bool maybeSubstitute)
{
struct State
{
@ -550,6 +550,8 @@ void copyClosure(ref<Store> srcStore, ref<Store> dstStore,
for (auto & path : storePaths)
srcStore->computeFSClosure(path, closure);
// FIXME: use copyStorePaths()
PathSet valid = dstStore->queryValidPaths(closure);
if (valid.size() == closure.size()) return;
@ -791,35 +793,22 @@ std::list<ref<Store>> getDefaultSubstituters()
}
void copyPaths(ref<Store> from, ref<Store> to, const Paths & storePaths, bool substitute)
void copyPaths(ref<Store> from, ref<Store> to, const PathSet & storePaths, bool substitute)
{
if (substitute) {
/* Filter out .drv files (we don't want to build anything). */
PathSet paths2;
for (auto & path : storePaths)
if (!isDerivation(path)) paths2.insert(path);
unsigned long long downloadSize, narSize;
PathSet willBuild, willSubstitute, unknown;
to->queryMissing(PathSet(paths2.begin(), paths2.end()),
willBuild, willSubstitute, unknown, downloadSize, narSize);
/* FIXME: should use ensurePath(), but it only
does one path at a time. */
if (!willSubstitute.empty())
try {
to->buildPaths(willSubstitute);
} catch (Error & e) {
printMsg(lvlError, format("warning: %1%") % e.msg());
}
}
PathSet valid = to->queryValidPaths(storePaths, substitute);
PathSet missing;
for (auto & path : storePaths)
if (!valid.count(path)) missing.insert(path);
std::string copiedLabel = "copied";
logger->setExpected(copiedLabel, storePaths.size());
logger->setExpected(copiedLabel, missing.size());
ThreadPool pool;
processGraph<Path>(pool,
PathSet(storePaths.begin(), storePaths.end()),
PathSet(missing.begin(), missing.end()),
[&](const Path & storePath) {
if (to->isValidPath(storePath)) return PathSet();