From 718fef29ef0da1b1651bf10a46bf4cb018aff299 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Mar 2016 13:09:14 +0100 Subject: [PATCH] Keep track of time required to load builds --- src/hydra-queue-runner/hydra-queue-runner.cc | 2 ++ src/hydra-queue-runner/queue-monitor.cc | 6 ++++++ src/hydra-queue-runner/state.hh | 1 + 3 files changed, 9 insertions(+) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 8ad86019..a4b4595b 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -548,6 +548,8 @@ void State::dumpStatus(Connection & conn, bool log) root.attr("bytesSent", bytesSent); root.attr("bytesReceived", bytesReceived); root.attr("nrBuildsRead", nrBuildsRead); + root.attr("buildReadTimeMs", buildReadTimeMs); + root.attr("buildReadTimeAvgMs", nrBuildsRead == 0 ? 0.0 : (float) buildReadTimeMs / nrBuildsRead); root.attr("nrBuildsDone", nrBuildsDone); root.attr("nrStepsStarted", nrStepsStarted); root.attr("nrStepsDone", nrStepsDone); diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 605102af..7d0b95a2 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -247,6 +247,8 @@ bool State::getQueuedBuilds(Connection & conn, ref localStore, if (i == newBuildsByID.end()) continue; auto build = i->second; + auto now1 = std::chrono::steady_clock::now(); + newRunnable.clear(); nrAdded = 0; try { @@ -256,6 +258,10 @@ bool State::getQueuedBuilds(Connection & conn, ref localStore, throw; } + auto now2 = std::chrono::steady_clock::now(); + + buildReadTimeMs += std::chrono::duration_cast(now2 - now1).count(); + /* Add the new runnable build steps to ‘runnable’ and wake up the builder threads. */ printMsg(lvlChatty, format("got %1% new runnable steps from %2% new builds") % newRunnable.size() % nrAdded); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index cc972d79..35f84209 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -294,6 +294,7 @@ private: /* Various stats. */ time_t startedAt; counter nrBuildsRead{0}; + counter buildReadTimeMs{0}; counter nrBuildsDone{0}; counter nrStepsStarted{0}; counter nrStepsDone{0};