From 44a2b74f5a94a23d2e4c3417709e348775b83515 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 22 Jun 2015 11:23:00 +0200 Subject: [PATCH] Keep track of the number of build steps that are being built (As opposed to being in the closure copying stage.) --- src/hydra-queue-runner/build-remote.cc | 8 ++++++-- src/hydra-queue-runner/build-remote.hh | 4 +++- src/hydra-queue-runner/counter.hh | 12 ++++++++++++ src/hydra-queue-runner/hydra-queue-runner.cc | 15 ++++----------- 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 src/hydra-queue-runner/counter.hh diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 7f02d081..b9696733 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -114,7 +114,7 @@ void buildRemote(std::shared_ptr store, const string & sshName, const string & sshKey, const Path & drvPath, const Derivation & drv, const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout, - RemoteResult & result) + RemoteResult & result, counter & nrStepsBuilding) { string base = baseNameOf(drvPath); result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2); @@ -176,7 +176,11 @@ void buildRemote(std::shared_ptr store, // FIXME: send maxLogSize. to.flush(); result.startTime = time(0); - int res = readInt(from); + int res; + { + MaintainCount mc(nrStepsBuilding); + res = readInt(from); + } result.stopTime = time(0); if (res) { result.errorMsg = (format("%1% on ‘%2%’") % readString(from) % sshName).str(); diff --git a/src/hydra-queue-runner/build-remote.hh b/src/hydra-queue-runner/build-remote.hh index d932e8ae..68d612e3 100644 --- a/src/hydra-queue-runner/build-remote.hh +++ b/src/hydra-queue-runner/build-remote.hh @@ -3,6 +3,8 @@ #include "store-api.hh" #include "derivations.hh" +#include "counter.hh" + struct RemoteResult { enum { @@ -20,4 +22,4 @@ void buildRemote(std::shared_ptr store, const std::string & sshName, const std::string & sshKey, const nix::Path & drvPath, const nix::Derivation & drv, const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout, - RemoteResult & result); + RemoteResult & result, counter & nrStepsBuilding); diff --git a/src/hydra-queue-runner/counter.hh b/src/hydra-queue-runner/counter.hh new file mode 100644 index 00000000..4d6b4163 --- /dev/null +++ b/src/hydra-queue-runner/counter.hh @@ -0,0 +1,12 @@ +#pragma once + +#include + +typedef std::atomic counter; + +struct MaintainCount +{ + counter & c; + MaintainCount(counter & c) : c(c) { c++; } + ~MaintainCount() { c--; } +}; diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 44e84587..ca35d3fb 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -19,6 +19,7 @@ #include "build-remote.hh" #include "sync.hh" #include "pool.hh" +#include "counter.hh" #include "store-api.hh" #include "derivations.hh" @@ -43,16 +44,6 @@ bool has(const C & c, const V & v) } -typedef std::atomic counter; - -struct MaintainCount -{ - counter & c; - MaintainCount(counter & c) : c(c) { c++; } - ~MaintainCount() { c--; } -}; - - typedef enum { bsSuccess = 0, bsFailed = 1, @@ -252,6 +243,7 @@ private: counter nrBuildsDone{0}; counter nrStepsDone{0}; counter nrActiveSteps{0}; + counter nrStepsBuilding{0}; counter nrRetries{0}; counter maxNrRetries{0}; counter nrQueueWakeups{0}; @@ -1094,7 +1086,7 @@ bool State::doBuildStep(std::shared_ptr store, Step::ptr step, try { /* FIXME: referring builds may have conflicting timeouts. */ buildRemote(store, machine->sshName, machine->sshKey, step->drvPath, step->drv, - logDir, build->maxSilentTime, build->buildTimeout, result); + logDir, build->maxSilentTime, build->buildTimeout, result, nrStepsBuilding); } catch (Error & e) { result.status = RemoteResult::rrMiscFailure; result.errorMsg = e.msg(); @@ -1432,6 +1424,7 @@ void State::dumpStatus() printMsg(lvlError, format("%1% runnable build steps") % runnable_->size()); } printMsg(lvlError, format("%1% active build steps") % nrActiveSteps); + printMsg(lvlError, format("%1% build steps currently building") % nrStepsBuilding); printMsg(lvlError, format("%1% builds read from queue") % nrBuildsRead); printMsg(lvlError, format("%1% builds done") % nrBuildsDone); printMsg(lvlError, format("%1% build steps done") % nrStepsDone);