aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-08-30 19:01:30 +0200
committereldritch horrors <pennae@lix.systems>2024-08-30 19:01:30 +0200
commite0fd0ba211b38827627218424f92b7d0e059a626 (patch)
tree0b0b1cf1f32302f683d7ab1bcd1a7469fc6a3e3c /src/libstore/build/worker.cc
parentc2b90d235fb5dd721898d8d41d73a51607654890 (diff)
libstore: use notifications for stats counters
updating statistics *immediately* when any counter changes declutters things somewhat and makes useful status reports less dependent on the current worker main loop. using callbacks will make it easier to move the worker loop into kj entirely, using only promises for scheduling. Change-Id: I695dfa83111b1ec09b1a54cff268f3c1d7743ed6
Diffstat (limited to 'src/libstore/build/worker.cc')
-rw-r--r--src/libstore/build/worker.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc
index 7336ad50f..24c700396 100644
--- a/src/libstore/build/worker.cc
+++ b/src/libstore/build/worker.cc
@@ -320,6 +320,27 @@ void Worker::waitForAWhile(GoalPtr goal)
}
+void Worker::updateStatistics()
+{
+ // only update progress info while running. this notably excludes updating
+ // progress info while destroying, which causes the progress bar to assert
+ if (running && statisticsOutdated) {
+ actDerivations.progress(
+ doneBuilds, expectedBuilds + doneBuilds, runningBuilds, failedBuilds
+ );
+ actSubstitutions.progress(
+ doneSubstitutions,
+ expectedSubstitutions + doneSubstitutions,
+ runningSubstitutions,
+ failedSubstitutions
+ );
+ act.setExpected(actFileTransfer, expectedDownloadSize + doneDownloadSize);
+ act.setExpected(actCopyPath, expectedNarSize + doneNarSize);
+
+ statisticsOutdated = false;
+ }
+}
+
Goals Worker::run(std::function<Goals (GoalFactory &)> req)
{
auto _topGoals = req(goalFactory());
@@ -329,6 +350,8 @@ Goals Worker::run(std::function<Goals (GoalFactory &)> req)
running = true;
Finally const _stop([&] { running = false; });
+ updateStatistics();
+
for (auto & i : _topGoals) {
topGoals.insert(i);
if (auto goal = dynamic_cast<DerivationGoal *>(i.get())) {
@@ -373,18 +396,7 @@ Goals Worker::run(std::function<Goals (GoalFactory &)> req)
? nrSubstitutions < std::max(1U, (unsigned int) settings.maxSubstitutionJobs)
: nrLocalBuilds < settings.maxBuildJobs;
handleWorkResult(goal, goal->work(inSlot));
-
- actDerivations.progress(
- doneBuilds, expectedBuilds + doneBuilds, runningBuilds, failedBuilds
- );
- actSubstitutions.progress(
- doneSubstitutions,
- expectedSubstitutions + doneSubstitutions,
- runningSubstitutions,
- failedSubstitutions
- );
- act.setExpected(actFileTransfer, expectedDownloadSize + doneDownloadSize);
- act.setExpected(actCopyPath, expectedNarSize + doneNarSize);
+ updateStatistics();
if (topGoals.empty()) break; // stuff may have been cancelled
}