Keep track of the number of build steps that are being built

(As opposed to being in the closure copying stage.)
This commit is contained in:
Eelco Dolstra 2015-06-22 11:23:00 +02:00
parent fed71d3fe9
commit 44a2b74f5a
4 changed files with 25 additions and 14 deletions

View file

@ -114,7 +114,7 @@ void buildRemote(std::shared_ptr<StoreAPI> store,
const string & sshName, const string & sshKey, const string & sshName, const string & sshKey,
const Path & drvPath, const Derivation & drv, const Path & drvPath, const Derivation & drv,
const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout, const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout,
RemoteResult & result) RemoteResult & result, counter & nrStepsBuilding)
{ {
string base = baseNameOf(drvPath); string base = baseNameOf(drvPath);
result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2); result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2);
@ -176,7 +176,11 @@ void buildRemote(std::shared_ptr<StoreAPI> store,
// FIXME: send maxLogSize. // FIXME: send maxLogSize.
to.flush(); to.flush();
result.startTime = time(0); result.startTime = time(0);
int res = readInt(from); int res;
{
MaintainCount mc(nrStepsBuilding);
res = readInt(from);
}
result.stopTime = time(0); result.stopTime = time(0);
if (res) { if (res) {
result.errorMsg = (format("%1% on %2%") % readString(from) % sshName).str(); result.errorMsg = (format("%1% on %2%") % readString(from) % sshName).str();

View file

@ -3,6 +3,8 @@
#include "store-api.hh" #include "store-api.hh"
#include "derivations.hh" #include "derivations.hh"
#include "counter.hh"
struct RemoteResult struct RemoteResult
{ {
enum { enum {
@ -20,4 +22,4 @@ void buildRemote(std::shared_ptr<nix::StoreAPI> store,
const std::string & sshName, const std::string & sshKey, const std::string & sshName, const std::string & sshKey,
const nix::Path & drvPath, const nix::Derivation & drv, const nix::Path & drvPath, const nix::Derivation & drv,
const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout, const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout,
RemoteResult & result); RemoteResult & result, counter & nrStepsBuilding);

View file

@ -0,0 +1,12 @@
#pragma once
#include <atomic>
typedef std::atomic<unsigned int> counter;
struct MaintainCount
{
counter & c;
MaintainCount(counter & c) : c(c) { c++; }
~MaintainCount() { c--; }
};

View file

@ -19,6 +19,7 @@
#include "build-remote.hh" #include "build-remote.hh"
#include "sync.hh" #include "sync.hh"
#include "pool.hh" #include "pool.hh"
#include "counter.hh"
#include "store-api.hh" #include "store-api.hh"
#include "derivations.hh" #include "derivations.hh"
@ -43,16 +44,6 @@ bool has(const C & c, const V & v)
} }
typedef std::atomic<unsigned int> counter;
struct MaintainCount
{
counter & c;
MaintainCount(counter & c) : c(c) { c++; }
~MaintainCount() { c--; }
};
typedef enum { typedef enum {
bsSuccess = 0, bsSuccess = 0,
bsFailed = 1, bsFailed = 1,
@ -252,6 +243,7 @@ private:
counter nrBuildsDone{0}; counter nrBuildsDone{0};
counter nrStepsDone{0}; counter nrStepsDone{0};
counter nrActiveSteps{0}; counter nrActiveSteps{0};
counter nrStepsBuilding{0};
counter nrRetries{0}; counter nrRetries{0};
counter maxNrRetries{0}; counter maxNrRetries{0};
counter nrQueueWakeups{0}; counter nrQueueWakeups{0};
@ -1094,7 +1086,7 @@ bool State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
try { try {
/* FIXME: referring builds may have conflicting timeouts. */ /* FIXME: referring builds may have conflicting timeouts. */
buildRemote(store, machine->sshName, machine->sshKey, step->drvPath, step->drv, 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) { } catch (Error & e) {
result.status = RemoteResult::rrMiscFailure; result.status = RemoteResult::rrMiscFailure;
result.errorMsg = e.msg(); result.errorMsg = e.msg();
@ -1432,6 +1424,7 @@ void State::dumpStatus()
printMsg(lvlError, format("%1% runnable build steps") % runnable_->size()); printMsg(lvlError, format("%1% runnable build steps") % runnable_->size());
} }
printMsg(lvlError, format("%1% active build steps") % nrActiveSteps); 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 read from queue") % nrBuildsRead);
printMsg(lvlError, format("%1% builds done") % nrBuildsDone); printMsg(lvlError, format("%1% builds done") % nrBuildsDone);
printMsg(lvlError, format("%1% build steps done") % nrStepsDone); printMsg(lvlError, format("%1% build steps done") % nrStepsDone);