From c7c7f068c15e419aaf5ef616516aa5ad4e55c2fa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 14 Dec 2020 17:59:32 +0100 Subject: daemon: Delegate deduplication to 'guix substitute'. This removes the main source of latency between subsequent downloads. * nix/libstore/build.cc (SubstitutionGoal::tryToRun): Add a "deduplicate" key to ENV. (SubstitutionGoal::finished): Remove call to 'optimisePath'. * guix/scripts/substitute.scm (process-substitution)[destination-in-store?] [dump-file/deduplicate*]: New variables. Pass #:dump-file to 'restore-file'. * guix/scripts/substitute.scm (guix-substitute)[deduplicate?]: New variable. Pass #:deduplicate? to 'process-substitution'. * guix/serialization.scm (dump-file): Export and augment 'dump-file'. --- nix/libstore/build.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'nix') diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index ea809c6971..20d83fea4a 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2984,7 +2984,12 @@ void SubstitutionGoal::tryToRun() if (!worker.substituter) { const Strings args = { "substitute", "--substitute" }; - const std::map env = { { "_NIX_OPTIONS", settings.pack() } }; + const std::map env = { + { "_NIX_OPTIONS", + settings.pack() + "deduplicate=" + + (settings.autoOptimiseStore ? "yes" : "no") + } + }; worker.substituter = std::make_shared(settings.guixProgram, args, env); } @@ -3085,10 +3090,8 @@ void SubstitutionGoal::finished() if (repair) replaceValidPath(storePath, destPath); - /* Note: 'guix substitute' takes care of resetting timestamps and - permissions on 'destPath', so no need to do it here. */ - - worker.store.optimisePath(storePath); // FIXME: combine with hashPath() + /* Note: 'guix substitute' takes care of resetting timestamps and of + deduplicating 'destPath', so no need to do it here. */ ValidPathInfo info2; info2.path = storePath; -- cgit v1.2.3