Skip to content

Commit 2e136dd

Browse files
committed
WIP: Avoid custom logic copying outputs from the remote builder
We need a replacement for the nar member logic, however. And maybe also a test that fails until this is fixed (this one should not be passing).
1 parent a873a12 commit 2e136dd

File tree

1 file changed

+4
-90
lines changed

1 file changed

+4
-90
lines changed

src/hydra-queue-runner/build-remote.cc

+4-90
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,6 @@ bool ::Machine::isLocalhost() const
3636

3737
namespace nix::build_remote {
3838

39-
// FIXME: use Store::topoSortPaths().
40-
static StorePaths reverseTopoSortPaths(const std::map<StorePath, UnkeyedValidPathInfo> & paths)
41-
{
42-
StorePaths sorted;
43-
StorePathSet visited;
44-
45-
std::function<void(const StorePath & path)> dfsVisit;
46-
47-
dfsVisit = [&](const StorePath & path) {
48-
if (!visited.insert(path).second) return;
49-
50-
auto info = paths.find(path);
51-
auto references = info == paths.end() ? StorePathSet() : info->second.references;
52-
53-
for (auto & i : references)
54-
/* Don't traverse into paths that don't exist. That can
55-
happen due to substitutes for non-existent paths. */
56-
if (i != path && paths.count(i))
57-
dfsVisit(i);
58-
59-
sorted.push_back(path);
60-
};
61-
62-
for (auto & i : paths)
63-
dfsVisit(i.first);
64-
65-
return sorted;
66-
}
67-
6839
static std::pair<Path, AutoCloseFD> openLogFile(const std::string & logDir, const StorePath & drvPath)
6940
{
7041
std::string base(drvPath.to_string());
@@ -205,54 +176,6 @@ static BuildResult performBuild(
205176
return result;
206177
}
207178

208-
static void copyPathFromRemote(
209-
::Machine::Connection & conn,
210-
NarMemberDatas & narMembers,
211-
Store & localStore,
212-
Store & destStore,
213-
const ValidPathInfo & info
214-
)
215-
{
216-
/* Receive the NAR from the remote and add it to the
217-
destination store. Meanwhile, extract all the info from the
218-
NAR that getBuildOutput() needs. */
219-
auto source2 = sinkToSource([&](Sink & sink)
220-
{
221-
/* Note: we should only send the command to dump the store
222-
path to the remote if the NAR is actually going to get read
223-
by the destination store, which won't happen if this path
224-
is already valid on the destination store. Since this
225-
lambda function only gets executed if someone tries to read
226-
from source2, we will send the command from here rather
227-
than outside the lambda. */
228-
conn.store->narFromPath(info.path, [&](Source & source) {
229-
TeeSource tee{source, sink};
230-
extractNarData(tee, conn.store->printStorePath(info.path), narMembers);
231-
});
232-
});
233-
234-
destStore.addToStore(info, *source2, NoRepair, NoCheckSigs);
235-
}
236-
237-
static void copyPathsFromRemote(
238-
::Machine::Connection & conn,
239-
NarMemberDatas & narMembers,
240-
Store & localStore,
241-
Store & destStore,
242-
const std::map<StorePath, UnkeyedValidPathInfo> & infos
243-
)
244-
{
245-
auto pathsSorted = reverseTopoSortPaths(infos);
246-
247-
for (auto & path : pathsSorted) {
248-
auto & info = infos.find(path)->second;
249-
copyPathFromRemote(
250-
conn, narMembers, localStore, destStore,
251-
ValidPathInfo { path, info });
252-
}
253-
254-
}
255-
256179
}
257180

258181
/* using namespace nix::build_remote; */
@@ -451,21 +374,12 @@ void State::buildRemote(ref<Store> destStore,
451374

452375
auto now1 = std::chrono::steady_clock::now();
453376

454-
auto infos = conn.store->queryPathInfosUncached(outputs);
455-
456-
size_t totalNarSize = 0;
457-
for (auto & [_, info] : infos) totalNarSize += info.narSize;
458-
459-
if (totalNarSize > maxOutputSize) {
460-
result.stepStatus = bsNarSizeLimitExceeded;
461-
return;
462-
}
463-
464377
/* Copy each path. */
465-
printMsg(lvlDebug, "copying outputs of ‘%s’ from ‘%s’ (%d bytes)",
466-
localStore->printStorePath(step->drvPath), machine->storeUri.render(), totalNarSize);
378+
printMsg(lvlDebug, "copying outputs of ‘%s’ from ‘%s’",
379+
localStore->printStorePath(step->drvPath), machine->storeUri.render());
380+
381+
copyClosure(*conn.store, *destStore, outputs);
467382

468-
build_remote::copyPathsFromRemote(conn, narMembers, *localStore, *destStore, infos);
469383
auto now2 = std::chrono::steady_clock::now();
470384

471385
result.overhead += std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();

0 commit comments

Comments
 (0)