Skip to content

Commit 5ed5d7a

Browse files
committed
Improve "waiting for locks" messages
These are now shown in the progress bar. Closes #3577.
1 parent e14e62f commit 5ed5d7a

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/libmain/progress-bar.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class ProgressBar : public Logger
156156
{
157157
auto state(state_.lock());
158158

159-
if (lvl <= verbosity && !s.empty())
159+
if (lvl <= verbosity && !s.empty() && type != actBuildWaiting)
160160
log(*state, lvl, s + "...");
161161

162162
state->activities.emplace_back(ActInfo());

src/libstore/build.cc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,9 @@ class DerivationGoal : public Goal
869869

870870
std::unique_ptr<Activity> act;
871871

872+
/* Activity that denotes waiting for a lock. */
873+
std::unique_ptr<Activity> actLock;
874+
872875
std::map<ActivityId, Activity> builderActivities;
873876

874877
/* The remote machine on which we're building. */
@@ -1439,10 +1442,15 @@ void DerivationGoal::tryToBuild()
14391442
lockFiles.insert(worker.store.Store::toRealPath(outPath));
14401443

14411444
if (!outputLocks.lockPaths(lockFiles, "", false)) {
1445+
if (!actLock)
1446+
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
1447+
fmt("waiting for lock on %s", yellowtxt(showPaths(lockFiles))));
14421448
worker.waitForAWhile(shared_from_this());
14431449
return;
14441450
}
14451451

1452+
actLock.reset();
1453+
14461454
/* Now check again whether the outputs are valid. This is because
14471455
another process may have started building in parallel. After
14481456
it has finished and released the locks, we can (and should)
@@ -1481,13 +1489,17 @@ void DerivationGoal::tryToBuild()
14811489
case rpAccept:
14821490
/* Yes, it has started doing so. Wait until we get
14831491
EOF from the hook. */
1492+
actLock.reset();
14841493
result.startTime = time(0); // inexact
14851494
state = &DerivationGoal::buildDone;
14861495
started();
14871496
return;
14881497
case rpPostpone:
14891498
/* Not now; wait until at least one child finishes or
14901499
the wake-up timeout expires. */
1500+
if (!actLock)
1501+
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
1502+
fmt("waiting for a machine to build '%s'", yellowtxt(worker.store.printStorePath(drvPath))));
14911503
worker.waitForAWhile(shared_from_this());
14921504
outputLocks.unlock();
14931505
return;
@@ -1497,6 +1509,8 @@ void DerivationGoal::tryToBuild()
14971509
}
14981510
}
14991511

1512+
actLock.reset();
1513+
15001514
/* Make sure that we are allowed to start a build. If this
15011515
derivation prefers to be done locally, do it even if
15021516
maxBuildJobs is 0. */
@@ -1524,7 +1538,9 @@ void DerivationGoal::tryLocalBuild() {
15241538
uid. */
15251539
buildUser->kill();
15261540
} else {
1527-
debug("waiting for build users");
1541+
if (!actLock)
1542+
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
1543+
fmt("waiting for UID to build '%s'", yellowtxt(worker.store.printStorePath(drvPath))));
15281544
worker.waitForAWhile(shared_from_this());
15291545
return;
15301546
}
@@ -1535,6 +1551,8 @@ void DerivationGoal::tryLocalBuild() {
15351551
#endif
15361552
}
15371553

1554+
actLock.reset();
1555+
15381556
try {
15391557

15401558
/* Okay, we have to build. */
@@ -4863,8 +4881,6 @@ void Worker::waitForInput()
48634881
up after a few seconds at most. */
48644882
if (!waitingForAWhile.empty()) {
48654883
useTimeout = true;
4866-
if (lastWokenUp == steady_time_point::min())
4867-
printInfo("waiting for locks, build slots or build users...");
48684884
if (lastWokenUp == steady_time_point::min() || lastWokenUp > before) lastWokenUp = before;
48694885
timeout = std::max(1L,
48704886
(long) std::chrono::duration_cast<std::chrono::seconds>(

src/libutil/logging.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef enum {
1818
actSubstitute = 108,
1919
actQueryPathInfo = 109,
2020
actPostBuildHook = 110,
21+
actBuildWaiting = 111,
2122
} ActivityType;
2223

2324
typedef enum {

0 commit comments

Comments
 (0)