From 0e0dcf2c7ec054f1b30629e275f53f56039b8257 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Aug 2017 22:12:36 +0200 Subject: Progress indicator: Unify "copying" and "substituting" They're the same thing after all. Example: $ nix build --store local?root=/tmp/nix nixpkgs.firefox-unwrapped [0/1 built, 49/98 copied, 16.3/92.8 MiB DL, 55.8/309.2 MiB copied] downloading 'https://cache.nixos.org/nar/0pl9li1jigcj2dany47hpmn0r3r48wc4nz48v5mqhh426lgz3bz6.nar.xz' --- src/libstore/build.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index d5f48237bd..9ea4e4b88e 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -207,7 +207,7 @@ struct MaintainCount { T & counter; T delta; - MaintainCount(T & counter, T delta) : counter(counter), delta(delta) { counter += delta; } + MaintainCount(T & counter, T delta = 1) : counter(counter), delta(delta) { counter += delta; } ~MaintainCount() { counter -= delta; } }; @@ -256,6 +256,7 @@ private: public: const Activity act; + const Activity actSubstitutions; /* Set if at least one derivation had a BuildError (i.e. permanent failure). */ @@ -268,6 +269,8 @@ public: std::unique_ptr hook; + uint64_t expectedSubstitutions = 0; + uint64_t doneSubstitutions = 0; uint64_t expectedDownloadSize = 0; uint64_t doneDownloadSize = 0; uint64_t expectedNarSize = 0; @@ -334,6 +337,7 @@ public: void updateProgress() { + actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions); logger->event(evSetExpected, act, actDownload, expectedDownloadSize + doneDownloadSize); logger->event(evSetExpected, act, actCopyPath, expectedNarSize + doneNarSize); } @@ -3328,7 +3332,8 @@ private: storePath when doing a repair. */ Path destPath; - std::unique_ptr> maintainExpectedNar, maintainExpectedDownload; + std::unique_ptr> maintainExpectedSubstitutions, + maintainExpectedNar, maintainExpectedDownload; typedef void (SubstitutionGoal::*GoalState)(); GoalState state; @@ -3364,7 +3369,6 @@ public: void amDone(ExitCode result) override { - logger->event(evSubstitutionFinished, act, result == ecSuccess); Goal::amDone(result); } }; @@ -3379,7 +3383,7 @@ SubstitutionGoal::SubstitutionGoal(const Path & storePath, Worker & worker, Repa state = &SubstitutionGoal::init; name = (format("substitution of '%1%'") % storePath).str(); trace("created"); - logger->event(evSubstitutionCreated, act, storePath); + maintainExpectedSubstitutions = std::make_unique>(worker.expectedSubstitutions); } @@ -3527,8 +3531,6 @@ void SubstitutionGoal::tryToRun() printInfo(format("fetching path '%1%'...") % storePath); - logger->event(evSubstitutionStarted, act); - outPipe.create(); promise = std::promise(); @@ -3576,6 +3578,9 @@ void SubstitutionGoal::finished() printMsg(lvlChatty, format("substitution of path '%1%' succeeded") % storePath); + maintainExpectedSubstitutions.reset(); + worker.doneSubstitutions++; + if (maintainExpectedDownload) { auto fileSize = maintainExpectedDownload->delta; maintainExpectedDownload.reset(); @@ -3610,6 +3615,7 @@ static bool working = false; Worker::Worker(LocalStore & store) : act(actRealise) + , actSubstitutions(actCopyPaths) , store(store) { /* Debugging: prevent recursive workers. */ @@ -3632,6 +3638,7 @@ Worker::~Worker() their destructors). */ topGoals.clear(); + assert(expectedSubstitutions == 0); assert(expectedDownloadSize == 0); assert(expectedNarSize == 0); } -- cgit 1.4.1