diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-14T20·42+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T18·56+0200 |
commit | bf1f123b09ec7402b0565808619e11b5bfe6b16b (patch) | |
tree | d0e4c9af039b8bf05244f648907c21274ee37054 /src/libstore | |
parent | 0e0dcf2c7ec054f1b30629e275f53f56039b8257 (diff) |
Progress indicator: Show number of active items
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 20 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 5 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 9ea4e4b88ef9..a45ca8923016 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -202,16 +202,6 @@ struct Child }; -template<typename T> -struct MaintainCount -{ - T & counter; - T delta; - MaintainCount(T & counter, T delta = 1) : counter(counter), delta(delta) { counter += delta; } - ~MaintainCount() { counter -= delta; } -}; - - /* The worker class. */ class Worker { @@ -271,6 +261,7 @@ public: uint64_t expectedSubstitutions = 0; uint64_t doneSubstitutions = 0; + uint64_t runningSubstitutions = 0; uint64_t expectedDownloadSize = 0; uint64_t doneDownloadSize = 0; uint64_t expectedNarSize = 0; @@ -337,7 +328,7 @@ public: void updateProgress() { - actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions); + actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions, runningSubstitutions); logger->event(evSetExpected, act, actDownload, expectedDownloadSize + doneDownloadSize); logger->event(evSetExpected, act, actCopyPath, expectedNarSize + doneNarSize); } @@ -3333,7 +3324,7 @@ private: Path destPath; std::unique_ptr<MaintainCount<uint64_t>> maintainExpectedSubstitutions, - maintainExpectedNar, maintainExpectedDownload; + maintainRunningSubstitutions, maintainExpectedNar, maintainExpectedDownload; typedef void (SubstitutionGoal::*GoalState)(); GoalState state; @@ -3531,6 +3522,9 @@ void SubstitutionGoal::tryToRun() printInfo(format("fetching path '%1%'...") % storePath); + maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions); + worker.updateProgress(); + outPipe.create(); promise = std::promise<void>(); @@ -3578,6 +3572,8 @@ void SubstitutionGoal::finished() printMsg(lvlChatty, format("substitution of path '%1%' succeeded") % storePath); + maintainRunningSubstitutions.reset(); + maintainExpectedSubstitutions.reset(); worker.doneSubstitutions++; diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 1e11e54eba7c..5aa3dcfd26a3 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -625,9 +625,10 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa std::atomic<size_t> nrDone{0}; std::atomic<uint64_t> bytesExpected{0}; + std::atomic<uint64_t> nrRunning{0}; auto showProgress = [&]() { - act.progress(nrDone, missing.size()); + act.progress(nrDone, missing.size(), nrRunning); }; ThreadPool pool; @@ -655,6 +656,8 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa if (!dstStore->isValidPath(storePath)) { printInfo("copying '%s'...", storePath); + MaintainCount<decltype(nrRunning)> mc(nrRunning); + showProgress(); copyStorePath(srcStore, dstStore, storePath, repair, checkSigs); } |