Moar stats

This commit is contained in:
Eelco Dolstra 2015-06-25 16:46:59 +02:00
parent b5815e2aa6
commit c6fcce3b3b
5 changed files with 31 additions and 15 deletions

View file

@ -71,7 +71,7 @@ static void openConnection(const string & sshName, const string & sshKey,
static void copyClosureTo(std::shared_ptr<StoreAPI> store,
FdSource & from, FdSink & to, const PathSet & paths,
TokenServer & copyClosureTokenServer,
TokenServer & copyClosureTokenServer, counter & bytesSent,
bool useSubstitutes = false)
{
PathSet closure;
@ -115,6 +115,9 @@ static void copyClosureTo(std::shared_ptr<StoreAPI> store,
printMsg(lvlDebug, format("sending %1% missing paths") % missing.size());
for (auto & p : missing)
bytesSent += store->queryPathInfo(p).narSize;
writeInt(cmdImportPaths, to);
exportPaths(*store, missing, false, to);
to.flush();
@ -125,13 +128,16 @@ static void copyClosureTo(std::shared_ptr<StoreAPI> store,
static void copyClosureFrom(std::shared_ptr<StoreAPI> store,
FdSource & from, FdSink & to, const PathSet & paths)
FdSource & from, FdSink & to, const PathSet & paths, counter & bytesReceived)
{
writeInt(cmdExportPaths, to);
writeInt(0, to); // == don't sign
writeStrings(paths, to);
to.flush();
store->importPaths(false, from);
for (auto & p : paths)
bytesReceived += store->queryPathInfo(p).narSize;
}
@ -140,7 +146,8 @@ void buildRemote(std::shared_ptr<StoreAPI> store,
const Path & drvPath, const Derivation & drv,
const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout,
TokenServer & copyClosureTokenServer, RemoteResult & result,
counter & nrStepsBuilding, counter & nrStepsCopyingTo, counter & nrStepsCopyingFrom)
counter & nrStepsBuilding, counter & nrStepsCopyingTo, counter & nrStepsCopyingFrom,
counter & bytesSent, counter & bytesReceived)
{
string base = baseNameOf(drvPath);
result.logFile = logDir + "/" + string(base, 0, 2) + "/" + string(base, 2);
@ -188,10 +195,10 @@ void buildRemote(std::shared_ptr<StoreAPI> store,
}
/* Copy the input closure. */
printMsg(lvlDebug, format("sending closure of %1% to %2%") % drvPath % sshName);
{
if (sshName != "localhost") {
printMsg(lvlDebug, format("sending closure of %1% to %2%") % drvPath % sshName);
MaintainCount mc(nrStepsCopyingTo);
copyClosureTo(store, from, to, inputs, copyClosureTokenServer);
copyClosureTo(store, from, to, inputs, copyClosureTokenServer, bytesSent);
}
autoDelete.cancel();
@ -220,13 +227,13 @@ void buildRemote(std::shared_ptr<StoreAPI> store,
}
/* Copy the output paths. */
printMsg(lvlDebug, format("copying outputs of %1% from %2%") % drvPath % sshName);
PathSet outputs;
for (auto & output : drv.outputs)
outputs.insert(output.second.path);
{
if (sshName != "localhost") {
printMsg(lvlDebug, format("copying outputs of %1% from %2%") % drvPath % sshName);
PathSet outputs;
for (auto & output : drv.outputs)
outputs.insert(output.second.path);
MaintainCount mc(nrStepsCopyingFrom);
copyClosureFrom(store, from, to, outputs);
copyClosureFrom(store, from, to, outputs, bytesReceived);
}
/* Shut down the connection. */

View file

@ -24,4 +24,5 @@ void buildRemote(std::shared_ptr<nix::StoreAPI> store,
const nix::Path & drvPath, const nix::Derivation & drv,
const nix::Path & logDir, unsigned int maxSilentTime, unsigned int buildTimeout,
TokenServer & copyClosureTokenServer, RemoteResult & result,
counter & nrStepsBuilding, counter & nrStepsCopyingTo, counter & nrStepsCopyingFrom);
counter & nrStepsBuilding, counter & nrStepsCopyingTo, counter & nrStepsCopyingFrom,
counter & bytesSent, counter & bytesReceived);

View file

@ -2,7 +2,7 @@
#include <atomic>
typedef std::atomic<unsigned int> counter;
typedef std::atomic<unsigned long> counter;
struct MaintainCount
{

View file

@ -256,6 +256,8 @@ private:
counter totalStepBuildTime{0}; // total build time for steps
counter nrQueueWakeups{0};
counter nrDispatcherWakeups{0};
counter bytesSent{0};
counter bytesReceived{0};
/* Log compressor work queue. */
Sync<std::queue<Path>> logCompressorQueue;
@ -1158,7 +1160,8 @@ bool State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
/* FIXME: referring builds may have conflicting timeouts. */
buildRemote(store, machine->sshName, machine->sshKey, step->drvPath, step->drv,
logDir, build->maxSilentTime, build->buildTimeout, copyClosureTokenServer,
result, nrStepsBuilding, nrStepsCopyingTo, nrStepsCopyingFrom);
result, nrStepsBuilding, nrStepsCopyingTo, nrStepsCopyingFrom,
bytesSent, bytesReceived);
} catch (Error & e) {
result.status = RemoteResult::rrMiscFailure;
result.errorMsg = e.msg();
@ -1592,6 +1595,8 @@ void State::dumpStatus(Connection & conn, bool log)
root.attr("nrStepsBuilding", nrStepsBuilding);
root.attr("nrStepsCopyingTo", nrStepsCopyingTo);
root.attr("nrStepsCopyingFrom", nrStepsCopyingFrom);
root.attr("bytesSent", bytesSent);
root.attr("bytesReceived", bytesReceived);
root.attr("nrBuildsRead", nrBuildsRead);
root.attr("nrBuildsDone", nrBuildsDone);
root.attr("nrStepsDone", nrStepsDone);

View file

@ -44,6 +44,9 @@ sub sendQueueRunnerStats {
gauge("hydra.queue.builds.finished", $json->{nrBuildsDone});
gauge("hydra.queue.checks", $json->{nrQueueWakeups});
gauge("hydra.queue.bytes_sent", $json->{bytesSent});
gauge("hydra.queue.bytes_received", $json->{bytesReceived});
}
while (1) {