1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 09:49:36 +01:00

Log build/substitution finishes

This commit is contained in:
Eelco Dolstra 2020-11-27 11:31:44 +01:00
parent 846c028609
commit 101b15663b
4 changed files with 32 additions and 0 deletions

View file

@ -650,6 +650,7 @@ void DerivationGoal::tryToBuild()
EOF from the hook. */ EOF from the hook. */
actLock.reset(); actLock.reset();
result.startTime = time(0); // inexact result.startTime = time(0); // inexact
startTime = std::chrono::steady_clock::now();
state = &DerivationGoal::buildDone; state = &DerivationGoal::buildDone;
started(); started();
return; return;
@ -997,6 +998,16 @@ void DerivationGoal::buildDone()
} }
done(BuildResult::Built); done(BuildResult::Built);
auto stopTime = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stopTime - startTime).count() / 1000.0;
// FIXME: associate with activity 'act'.
notice(ANSI_BOLD ANSI_GREEN "Built" ANSI_NORMAL " '%s' in %s%.1f s" ANSI_NORMAL ".",
worker.store.printStorePath(drvPath),
duration > 0.5 ? ANSI_BOLD : ANSI_NORMAL,
duration);
} }
void DerivationGoal::resolvedFinished() { void DerivationGoal::resolvedFinished() {
@ -1573,6 +1584,7 @@ void DerivationGoal::startBuilder()
throw SysError("putting pseudoterminal into raw mode"); throw SysError("putting pseudoterminal into raw mode");
result.startTime = time(0); result.startTime = time(0);
startTime = std::chrono::steady_clock::now();
/* Fork a child to build the package. */ /* Fork a child to build the package. */
ProcessOptions options; ProcessOptions options;

View file

@ -194,6 +194,11 @@ struct DerivationGoal : public Goal
BuildResult result; BuildResult result;
/* Time the build started. 'result' also has a 'startTime' field,
but that's wall clock time, so we can't use it to compute the
build duration... */
std::chrono::time_point<std::chrono::steady_clock> startTime;
/* The current round, if we're building multiple times. */ /* The current round, if we're building multiple times. */
size_t curRound = 1; size_t curRound = 1;

View file

@ -205,6 +205,8 @@ void SubstitutionGoal::tryToRun()
outPipe.create(); outPipe.create();
startTime = std::chrono::steady_clock::now();
promise = std::promise<void>(); promise = std::promise<void>();
thr = std::thread([this]() { thr = std::thread([this]() {
@ -280,6 +282,16 @@ void SubstitutionGoal::finished()
worker.updateProgress(); worker.updateProgress();
amDone(ecSuccess); amDone(ecSuccess);
auto stopTime = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stopTime - startTime).count() / 1000.0;
// FIXME: associate with activity 'act'.
notice(ANSI_BOLD ANSI_GREEN "Substituted" ANSI_NORMAL " '%s' in %s%.1f s" ANSI_NORMAL ".",
worker.store.printStorePath(storePath),
duration > 0.5 ? ANSI_BOLD : ANSI_NORMAL,
duration);
} }

View file

@ -53,6 +53,9 @@ struct SubstitutionGoal : public Goal
/* Content address for recomputing store path */ /* Content address for recomputing store path */
std::optional<ContentAddress> ca; std::optional<ContentAddress> ca;
/* Time substitution started. */
std::chrono::time_point<std::chrono::steady_clock> startTime;
SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt); SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
~SubstitutionGoal(); ~SubstitutionGoal();