From ea7fa88131eb486ffe54f32601d36a64374f7b7c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Mar 2017 11:44:01 +0100 Subject: [PATCH] LegacySSHStore: Provide a faster implementation of computeFSClosure() This avoids the latency of the standard implementation, which can make a huge difference (e.g. 16.5s -> 0.5s on a NixOS system closure). --- src/libstore/legacy-ssh-store.cc | 22 ++++++++++++++++++++++ src/libstore/store-api.hh | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index d804b27c1..1a933259b 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -204,6 +204,28 @@ struct LegacySSHStore : public Store bool isTrusted() override { return true; } + void computeFSClosure(const PathSet & paths, + PathSet & out, bool flipDirection = false, + bool includeOutputs = false, bool includeDerivers = false) override + { + if (flipDirection || includeDerivers) { + Store::computeFSClosure(paths, out, flipDirection, includeOutputs, includeDerivers); + return; + } + + auto conn(connections->get()); + + conn->to + << cmdQueryClosure + << includeOutputs + << paths; + conn->to.flush(); + + auto res = readStorePaths(*this, conn->from); + + out.insert(res.begin(), res.end()); + } + }; static RegisterStoreImplementation regStore([]( diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 3aea30c28..92aa8862f 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -511,7 +511,7 @@ public: `storePath' is returned; that is, the closures under the `referrers' relation instead of the `references' relation is returned. */ - void computeFSClosure(const PathSet & paths, + virtual void computeFSClosure(const PathSet & paths, PathSet & out, bool flipDirection = false, bool includeOutputs = false, bool includeDerivers = false);