1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 20:01:15 +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

@ -252,10 +252,10 @@ connected:
string line;
if (!getline(cin, line))
throw Error("hook caller didn't send inputs");
auto inputs = tokenizeString<std::list<string>>(line);
auto inputs = tokenizeString<PathSet>(line);
if (!getline(cin, line))
throw Error("hook caller didn't send outputs");
auto outputs = tokenizeString<Strings>(line);
auto outputs = tokenizeString<PathSet>(line);
AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + hostName + ".upload-lock", true);
auto old = signal(SIGALRM, handleAlarm);
alarm(15 * 60);
@ -269,11 +269,15 @@ connected:
printError("building %s on %s", drvPath, hostName);
sshStore->buildDerivation(drvPath, readDerivation(drvPath));
std::remove_if(outputs.begin(), outputs.end(), [=](const Path & path) { return store->isValidPath(path); });
if (!outputs.empty()) {
setenv("NIX_HELD_LOCKS", concatStringsSep(" ", outputs).c_str(), 1); /* FIXME: ugly */
copyPaths(ref<Store>(sshStore), store, outputs);
PathSet missing;
for (auto & path : outputs)
if (!store->isValidPath(path)) missing.insert(path);
if (!missing.empty()) {
setenv("NIX_HELD_LOCKS", concatStringsSep(" ", missing).c_str(), 1); /* FIXME: ugly */
copyPaths(ref<Store>(sshStore), store, missing);
}
return;
});
}