From 61ee4517214cd8547ba7088fb4a53ec543d986b2 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Mon, 8 Aug 2022 17:25:57 +0200 Subject: Rebuild: Support proper progress printing --- src/buildtool/execution_engine/executor/executor.hpp | 16 ++++++++++------ src/buildtool/graph_traverser/graph_traverser.hpp | 9 ++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index 02a56f49..546c5165 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -72,8 +72,11 @@ class ExecutorImpl { return std::nullopt; } - Progress::Instance().Start(action->Content().Id()); - Statistics::Instance().IncrementActionsQueuedCounter(); + // do not count statistics for rebuilder fetching from cache + if (cache_flag != IExecutionAction::CacheFlag::FromCacheOnly) { + Progress::Instance().Start(action->Content().Id()); + Statistics::Instance().IncrementActionsQueuedCounter(); + } auto remote_action = api->CreateAction(*root_digest, action->Command(), @@ -414,8 +417,8 @@ class ExecutorImpl { [[nodiscard]] static auto ParseResponse( Logger const& logger, IExecutionResponse::Ptr const& response, - gsl::not_null const& action) - -> bool { + gsl::not_null const& action, + bool count_as_executed = false) -> bool { logger.Emit(LogLevel::Trace, "finished execution"); if (!response) { @@ -423,7 +426,7 @@ class ExecutorImpl { return false; } - if (response->IsCached()) { + if (not count_as_executed and response->IsCached()) { logger.Emit(LogLevel::Trace, " - served from cache"); Statistics::Instance().IncrementActionsCachedCounter(); } @@ -618,7 +621,8 @@ class Rebuilder { } DetectFlakyAction(*response, *response_cached, action->Content()); - return Impl::ParseResponse(logger, *response, action); + return Impl::ParseResponse( + logger, *response, action, /*count_as_executed=*/true); } [[nodiscard]] auto Process( diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index acd1515a..0e81d46e 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -351,12 +351,19 @@ class GraphTraverser { RemoteExecutionConfig::PlatformProperties(), clargs_.build.timeout}; bool traversing{false}; - std::atomic failed{false}; + std::atomic done = false; + std::atomic failed = false; + std::condition_variable cv{}; + auto observer = + std::thread([this, &done, &cv]() { reporter_(&done, &cv); }); { Traverser t{executor, g, clargs_.jobs, &failed}; traversing = t.Traverse({std::begin(artifact_ids), std::end(artifact_ids)}); } + done = true; + cv.notify_all(); + observer.join(); if (traversing and not failed and clargs_.rebuild->dump_flaky) { std::ofstream file{*clargs_.rebuild->dump_flaky}; -- cgit v1.2.3