summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/target_map/TARGETS8
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.cpp25
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.hpp4
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.cpp9
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.hpp2
-rw-r--r--src/buildtool/build_engine/target_map/export.cpp13
-rw-r--r--src/buildtool/build_engine/target_map/export.hpp2
-rw-r--r--src/buildtool/build_engine/target_map/target_map.cpp38
-rw-r--r--src/buildtool/build_engine/target_map/target_map.hpp2
-rw-r--r--src/buildtool/common/statistics.hpp10
-rw-r--r--src/buildtool/main/TARGETS4
-rw-r--r--src/buildtool/main/analyse.cpp29
-rw-r--r--src/buildtool/progress_reporting/TARGETS18
-rw-r--r--src/buildtool/progress_reporting/exports_progress_reporter.cpp (renamed from src/buildtool/serve_api/progress_reporting/progress_reporter.cpp)35
-rw-r--r--src/buildtool/progress_reporting/exports_progress_reporter.hpp32
-rw-r--r--src/buildtool/serve_api/progress_reporting/TARGETS29
-rw-r--r--src/buildtool/serve_api/progress_reporting/progress.hpp41
-rw-r--r--src/buildtool/serve_api/progress_reporting/progress_reporter.hpp25
-rw-r--r--src/buildtool/serve_api/progress_reporting/statistics.hpp55
19 files changed, 170 insertions, 211 deletions
diff --git a/src/buildtool/build_engine/target_map/TARGETS b/src/buildtool/build_engine/target_map/TARGETS
index 38c261d5..5e77e98f 100644
--- a/src/buildtool/build_engine/target_map/TARGETS
+++ b/src/buildtool/build_engine/target_map/TARGETS
@@ -48,6 +48,7 @@
, ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/multithreading", "async_map_consumer"]
+ , ["src/buildtool/progress_reporting", "progress"]
, ["src/buildtool/storage", "storage"]
, ["@", "gsl", "", "gsl"]
, ["@", "json", "", "json"]
@@ -56,7 +57,6 @@
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, ["src/utils/cpp", "gsl"]
- , ["src/buildtool/common", "common"]
, ["src/buildtool/storage", "storage"]
, ["src/buildtool/build_engine/base_maps", "entity_name"]
, ["src/buildtool/build_engine/base_maps", "field_reader"]
@@ -101,15 +101,13 @@
, ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/multithreading", "async_map_consumer"]
+ , ["src/buildtool/progress_reporting", "progress"]
, ["@", "gsl", "", "gsl"]
]
, "stage": ["src", "buildtool", "build_engine", "target_map"]
, "private-deps":
- [ ["src/buildtool/common", "common"]
- , ["src/buildtool/storage", "storage"]
+ [ ["src/buildtool/storage", "storage"]
, ["src/buildtool/logging", "logging"]
- , ["src/buildtool/serve_api/progress_reporting", "progress"]
- , ["src/buildtool/serve_api/progress_reporting", "statistics"]
, ["src/buildtool/serve_api/remote", "serve_api"]
]
}
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp
index f72dc697..d725ef22 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.cpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp
@@ -14,8 +14,6 @@
#include "src/buildtool/build_engine/target_map/absent_target_map.hpp"
#ifndef BOOTSTRAP_BUILD_TOOL
-#include "src/buildtool/serve_api/progress_reporting/progress.hpp"
-#include "src/buildtool/serve_api/progress_reporting/statistics.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/target_cache_key.hpp"
#endif
@@ -23,10 +21,11 @@
auto BuildMaps::Target::CreateAbsentTargetMap(
const gsl::not_null<ResultTargetMap*>& result_map,
gsl::not_null<RepositoryConfig*> const& repo_config,
- gsl::not_null<Statistics*> const& local_stats,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& exports_progress,
std::size_t jobs) -> AbsentTargetMap {
#ifndef BOOTSTRAP_BUILD_TOOL
- auto target_reader = [result_map, repo_config, local_stats](
+ auto target_reader = [result_map, repo_config, stats, exports_progress](
auto /*ts*/,
auto setter,
auto logger,
@@ -56,6 +55,8 @@ auto BuildMaps::Target::CreateAbsentTargetMap(
/*fatal=*/true);
return;
}
+ // we know now that this target is an export target
+ stats->IncrementExportsFoundCounter();
// TODO(asartori): avoid code duplication in export.cpp
auto effective_config = key.config.Prune(*flexible_vars);
auto target_name = key.target.GetNamedTarget();
@@ -84,19 +85,14 @@ auto BuildMaps::Target::CreateAbsentTargetMap(
Logger::Log(LogLevel::Debug,
"Querying serve endpoint for absent export target {}",
key.target.ToString());
- ServeServiceProgress::Instance().TaskTracker().Start(
+ exports_progress->TaskTracker().Start(
target_cache_key->Id().ToString());
- ServeServiceStatistics::Instance().IncrementDispatchedCounter();
target_cache_value =
ServeApi::ServeTarget(*target_cache_key, *repo_key);
- ServeServiceStatistics::Instance().IncrementServedCounter();
- ServeServiceProgress::Instance().TaskTracker().Stop(
+ exports_progress->TaskTracker().Stop(
target_cache_key->Id().ToString());
from_just_serve = true;
}
- else {
- ServeServiceStatistics::Instance().IncrementCacheHitsCounter();
- }
if (!target_cache_value) {
(*logger)(fmt::format("Could not get target cache value for key {}",
@@ -139,7 +135,12 @@ auto BuildMaps::Target::CreateAbsentTargetMap(
info.ToString());
(*setter)(std::move(analysis_result));
- local_stats->IncrementExportsCachedCounter();
+ if (from_just_serve) {
+ stats->IncrementExportsServedCounter();
+ }
+ else {
+ stats->IncrementExportsCachedCounter();
+ }
return;
}
(*logger)(fmt::format("Reading target entry for key {} failed",
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.hpp b/src/buildtool/build_engine/target_map/absent_target_map.hpp
index a00fc05d..eb454ab7 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.hpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.hpp
@@ -21,13 +21,15 @@
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
namespace BuildMaps::Target {
using AbsentTargetMap = AsyncMapConsumer<ConfiguredTarget, AnalysedTargetPtr>;
auto CreateAbsentTargetMap(const gsl::not_null<ResultTargetMap*>&,
gsl::not_null<RepositoryConfig*> const& repo_config,
- gsl::not_null<Statistics*> const& local_stats,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& exports_progress,
std::size_t jobs = 0) -> AbsentTargetMap;
} // namespace BuildMaps::Target
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp
index 2c90cc9d..1ab71a1c 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.cpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp
@@ -341,6 +341,7 @@ void FileGenRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -361,6 +362,7 @@ void SymlinkRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -490,6 +492,7 @@ void TreeRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -740,6 +743,7 @@ void InstallRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1327,6 +1331,7 @@ void GenericRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1406,6 +1411,7 @@ void ConfigureRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
[[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
+ [[maybe_unused]] const gsl::not_null<Progress*>& /*exports_progress*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1548,6 +1554,7 @@ auto const kBuiltIns = std::unordered_map<
const gsl::not_null<RepositoryConfig*>&,
const ActiveTargetCache&,
const gsl::not_null<Statistics*>&,
+ const gsl::not_null<Progress*>&,
const BuildMaps::Target::TargetMap::SubCallerPtr&,
const BuildMaps::Target::TargetMap::SetterPtr&,
const BuildMaps::Target::TargetMap::LoggerPtr&,
@@ -1580,6 +1587,7 @@ auto HandleBuiltin(
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1607,6 +1615,7 @@ auto HandleBuiltin(
repo_config,
target_cache,
stats,
+ exports_progress,
subcaller,
setter,
target_logger,
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.hpp b/src/buildtool/build_engine/target_map/built_in_rules.hpp
index 1eb6e086..8a0dedeb 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.hpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.hpp
@@ -22,6 +22,7 @@
#include "src/buildtool/build_engine/target_map/target_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/buildtool/storage/target_cache.hpp"
namespace BuildMaps::Target {
@@ -32,6 +33,7 @@ auto HandleBuiltin(
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp
index 29085716..e035d2c0 100644
--- a/src/buildtool/build_engine/target_map/export.cpp
+++ b/src/buildtool/build_engine/target_map/export.cpp
@@ -99,10 +99,12 @@ void ExportRule(
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
const gsl::not_null<BuildMaps::Target::ResultTargetMap*> result_map) {
+ stats->IncrementExportsFoundCounter();
auto desc = BuildMaps::Base::FieldReader::CreatePtr(
desc_json, key.target, "export target", logger);
auto flexible_vars = desc->ReadStringList("flexible_config");
@@ -128,8 +130,12 @@ void ExportRule(
Logger::Log(LogLevel::Debug,
"Querying serve endpoint for export target {}",
key.target.ToString());
+ exports_progress->TaskTracker().Start(
+ target_cache_key->Id().ToString());
target_cache_value =
ServeApi::ServeTarget(*target_cache_key, *repo_key);
+ exports_progress->TaskTracker().Stop(
+ target_cache_key->Id().ToString());
from_just_serve = true;
}
#endif // BOOTSTRAP_BUILD_TOOL
@@ -177,7 +183,12 @@ void ExportRule(
info.ToString());
(*setter)(std::move(analysis_result));
- stats->IncrementExportsCachedCounter();
+ if (from_just_serve) {
+ stats->IncrementExportsServedCounter();
+ }
+ else {
+ stats->IncrementExportsCachedCounter();
+ }
return;
}
(*logger)(fmt::format("Reading target entry for key {} failed",
diff --git a/src/buildtool/build_engine/target_map/export.hpp b/src/buildtool/build_engine/target_map/export.hpp
index 3f43796b..19cda908 100644
--- a/src/buildtool/build_engine/target_map/export.hpp
+++ b/src/buildtool/build_engine/target_map/export.hpp
@@ -22,6 +22,7 @@
#include "src/buildtool/build_engine/target_map/target_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/buildtool/storage/target_cache.hpp"
void ExportRule(const nlohmann::json& desc_json,
@@ -29,6 +30,7 @@ void ExportRule(const nlohmann::json& desc_json,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp
index d1812d92..02a28acd 100644
--- a/src/buildtool/build_engine/target_map/target_map.cpp
+++ b/src/buildtool/build_engine/target_map/target_map.cpp
@@ -30,7 +30,6 @@
#include "src/buildtool/build_engine/expression/function_map.hpp"
#include "src/buildtool/build_engine/target_map/built_in_rules.hpp"
#include "src/buildtool/build_engine/target_map/utils.hpp"
-#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/utils/cpp/gsl.hpp"
#include "src/utils/cpp/path.hpp"
@@ -1239,6 +1238,7 @@ void withTargetsFile(
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
const nlohmann::json& targets_file,
const gsl::not_null<BuildMaps::Base::SourceTargetMap*>& source_target,
const gsl::not_null<BuildMaps::Base::UserRuleMap*>& rule_map,
@@ -1273,16 +1273,18 @@ void withTargetsFile(
return;
}
// Handle built-in rule, if it is
- auto handled_as_builtin = BuildMaps::Target::HandleBuiltin(*rule_it,
- desc,
- key,
- repo_config,
- target_cache,
- stats,
- subcaller,
- setter,
- logger,
- result_map);
+ auto handled_as_builtin =
+ BuildMaps::Target::HandleBuiltin(*rule_it,
+ desc,
+ key,
+ repo_config,
+ target_cache,
+ stats,
+ exports_progress,
+ subcaller,
+ setter,
+ logger,
+ result_map);
if (handled_as_builtin) {
return;
}
@@ -1664,6 +1666,7 @@ auto CreateTargetMap(
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
std::size_t jobs) -> TargetMap {
auto target_reader = [source_target_map,
targets_file_map,
@@ -1673,11 +1676,12 @@ auto CreateTargetMap(
result_map,
repo_config,
target_cache,
- stats](auto ts,
- auto setter,
- auto logger,
- auto subcaller,
- auto key) {
+ stats,
+ exports_progress](auto ts,
+ auto setter,
+ auto logger,
+ auto subcaller,
+ auto key) {
if (key.target.IsAnonymousTarget()) {
withTargetNode(key,
repo_config,
@@ -1815,6 +1819,7 @@ auto CreateTargetMap(
repo_config,
target_cache,
stats,
+ exports_progress,
source_target_map,
rule_map,
ts,
@@ -1826,6 +1831,7 @@ auto CreateTargetMap(
repo_config,
target_cache,
stats,
+ exports_progress,
*values[0],
source_target_map,
rule_map,
diff --git a/src/buildtool/build_engine/target_map/target_map.hpp b/src/buildtool/build_engine/target_map/target_map.hpp
index eda27b77..15540f00 100644
--- a/src/buildtool/build_engine/target_map/target_map.hpp
+++ b/src/buildtool/build_engine/target_map/target_map.hpp
@@ -30,6 +30,7 @@
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/buildtool/storage/target_cache.hpp"
namespace BuildMaps::Target {
@@ -46,6 +47,7 @@ auto CreateTargetMap(
const gsl::not_null<RepositoryConfig*>&,
const ActiveTargetCache&,
const gsl::not_null<Statistics*>& stats,
+ const gsl::not_null<Progress*>& exports_progress,
std::size_t jobs = 0) -> TargetMap;
// use explicit cast to std::function to allow template deduction when used
diff --git a/src/buildtool/common/statistics.hpp b/src/buildtool/common/statistics.hpp
index 4022db15..ed2c3afb 100644
--- a/src/buildtool/common/statistics.hpp
+++ b/src/buildtool/common/statistics.hpp
@@ -47,6 +47,8 @@ class Statistics {
void IncrementExportsNotEligibleCounter() noexcept {
++num_exports_not_eligible_;
}
+ void IncrementExportsFoundCounter() noexcept { ++num_exports_found_; }
+ void IncrementExportsServedCounter() noexcept { ++num_exports_served_; }
void IncrementTreesAnalysedCounter() noexcept { ++num_trees_analysed_; }
[[nodiscard]] auto ActionsQueuedCounter() const noexcept -> int {
return num_actions_queued_;
@@ -78,6 +80,12 @@ class Statistics {
[[nodiscard]] auto ExportsNotEligibleCounter() const noexcept -> int {
return num_exports_not_eligible_;
}
+ [[nodiscard]] auto ExportsFoundCounter() const noexcept -> int {
+ return num_exports_found_;
+ }
+ [[nodiscard]] auto ExportsServedCounter() const noexcept -> int {
+ return num_exports_served_;
+ }
[[nodiscard]] auto TreesAnalysedCounter() const noexcept -> int {
return num_trees_analysed_;
}
@@ -93,6 +101,8 @@ class Statistics {
std::atomic<int> num_exports_cached_{};
std::atomic<int> num_exports_uncached_{};
std::atomic<int> num_exports_not_eligible_{};
+ std::atomic<int> num_exports_found_{};
+ std::atomic<int> num_exports_served_{};
std::atomic<int> num_trees_analysed_{};
};
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS
index 1919101c..2cb08ea9 100644
--- a/src/buildtool/main/TARGETS
+++ b/src/buildtool/main/TARGETS
@@ -135,7 +135,9 @@
, ["src/buildtool/build_engine/base_maps", "targets_file_map"]
, ["src/buildtool/build_engine/target_map", "absent_target_map"]
, ["src/buildtool/build_engine/target_map", "target_map"]
- , ["src/buildtool/serve_api/progress_reporting", "progress_reporter"]
+ , ["src/buildtool/progress_reporting", "exports_progress_reporter"]
+ , ["src/buildtool/progress_reporting", "progress"]
+ , ["src/buildtool/serve_api/remote", "config"]
]
}
, "diagnose":
diff --git a/src/buildtool/main/analyse.cpp b/src/buildtool/main/analyse.cpp
index 09973446..b52c376f 100644
--- a/src/buildtool/main/analyse.cpp
+++ b/src/buildtool/main/analyse.cpp
@@ -14,11 +14,9 @@
#include "src/buildtool/main/analyse.hpp"
-#ifndef BOOTSTRAP_BUILD_TOOL
#include <atomic>
#include <condition_variable>
#include <thread>
-#endif // BOOTSTRAP_BUILD_TOOL
#include "src/buildtool/build_engine/base_maps/directory_map.hpp"
#include "src/buildtool/build_engine/base_maps/entity_name.hpp"
@@ -31,8 +29,10 @@
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/multithreading/async_map_utils.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
+#include "src/buildtool/progress_reporting/exports_progress_reporter.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#ifndef BOOTSTRAP_BUILD_TOOL
-#include "src/buildtool/serve_api/progress_reporting/progress_reporter.hpp"
+#include "src/buildtool/serve_api/remote/config.hpp"
#endif // BOOTSTRAP_BUILD_TOOL
namespace {
@@ -101,6 +101,9 @@ namespace Target = BuildMaps::Target;
std::size_t jobs,
std::optional<std::string> const& request_action_input)
-> std::optional<AnalysisResult> {
+ // create progress tracker for export targets
+ Progress exports_progress{};
+ // create async maps
auto directory_entries = Base::CreateDirectoryEntriesMap(repo_config, jobs);
auto expressions_file_map =
Base::CreateExpressionFileMap(repo_config, jobs);
@@ -112,8 +115,8 @@ namespace Target = BuildMaps::Target;
Base::CreateRuleMap(&rule_file_map, &expr_map, repo_config, jobs);
auto source_targets =
Base::CreateSourceTargetMap(&directory_entries, repo_config, jobs);
- auto absent_target_map =
- Target::CreateAbsentTargetMap(result_map, repo_config, stats, jobs);
+ auto absent_target_map = Target::CreateAbsentTargetMap(
+ result_map, repo_config, stats, &exports_progress, jobs);
auto target_map = Target::CreateTargetMap(&source_targets,
&targets_file_map,
&rule_map,
@@ -123,17 +126,25 @@ namespace Target = BuildMaps::Target;
repo_config,
target_cache,
stats,
+ &exports_progress,
jobs);
Logger::Log(LogLevel::Info, "Requested target is {}", id.ToString());
AnalysedTargetPtr target{};
+ // we should only report served export targets if a serve endpoint exists
+ bool has_serve{false};
#ifndef BOOTSTRAP_BUILD_TOOL
+ if (RemoteServeConfig::RemoteAddress()) {
+ has_serve = true;
+ }
+#endif // BOOTSTRAP_BUILD_TOOL
+
std::atomic<bool> done{false};
std::condition_variable cv{};
- auto reporter = ServeServiceProgressReporter::Reporter();
+ auto reporter =
+ ExportsProgressReporter::Reporter(stats, &exports_progress, has_serve);
auto observer =
std::thread([reporter, &done, &cv]() { reporter(&done, &cv); });
-#endif // BOOTSTRAP_BUILD_TOOL
bool failed{false};
{
@@ -150,12 +161,10 @@ namespace Target = BuildMaps::Target;
});
}
-#ifndef BOOTSTRAP_BUILD_TOOL
- // close progress observer
+ // close analysis progress observer
done = true;
cv.notify_all();
observer.join();
-#endif // BOOTSTRAP_BUILD_TOOL
if (failed) {
return std::nullopt;
diff --git a/src/buildtool/progress_reporting/TARGETS b/src/buildtool/progress_reporting/TARGETS
index 6a00bcdc..f33b5424 100644
--- a/src/buildtool/progress_reporting/TARGETS
+++ b/src/buildtool/progress_reporting/TARGETS
@@ -41,4 +41,22 @@
, "stage": ["src", "buildtool", "progress_reporting"]
, "private-deps": [["src/buildtool/logging", "logging"]]
}
+, "exports_progress_reporter":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["exports_progress_reporter"]
+ , "hdrs": ["exports_progress_reporter.hpp"]
+ , "srcs": ["exports_progress_reporter.cpp"]
+ , "stage": ["src", "buildtool", "progress_reporting"]
+ , "deps":
+ [ "base_progress_reporter"
+ , "progress"
+ , ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/common", "common"]
+ ]
+ , "private-deps":
+ [ ["@", "fmt", "", "fmt"]
+ , ["@", "json", "", "json"]
+ , ["src/buildtool/logging", "logging"]
+ ]
+ }
}
diff --git a/src/buildtool/serve_api/progress_reporting/progress_reporter.cpp b/src/buildtool/progress_reporting/exports_progress_reporter.cpp
index 96f1a589..7c3bb659 100644
--- a/src/buildtool/serve_api/progress_reporting/progress_reporter.cpp
+++ b/src/buildtool/progress_reporting/exports_progress_reporter.cpp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/buildtool/serve_api/progress_reporting/progress_reporter.hpp"
+#include "src/buildtool/progress_reporting/exports_progress_reporter.hpp"
#include <string>
@@ -20,24 +20,29 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
-#include "src/buildtool/serve_api/progress_reporting/progress.hpp"
-#include "src/buildtool/serve_api/progress_reporting/statistics.hpp"
-auto ServeServiceProgressReporter::Reporter() noexcept -> progress_reporter_t {
- return BaseProgressReporter::Reporter([]() {
- auto const& stats = ServeServiceStatistics::Instance();
- // get served counter before dispatched counter, to ensure we never
- // undercount the amount of builds in flight
- int served = stats.ServedCounter();
- int dispatched = stats.DispatchedCounter();
- int processing = dispatched - served;
- int cached = stats.CacheHitsCounter();
+auto ExportsProgressReporter::Reporter(gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ bool has_serve) noexcept
+ -> progress_reporter_t {
+ return BaseProgressReporter::Reporter([stats, progress, has_serve]() {
+ // get 'found' counter last to ensure we never undercount the amount of
+ // work not yet done
+ auto cached = stats->ExportsCachedCounter();
+ auto served = stats->ExportsServedCounter();
+ auto uncached = stats->ExportsUncachedCounter();
+ auto not_eligible = stats->ExportsNotEligibleCounter();
+ auto found = stats->ExportsFoundCounter();
- auto active = ServeServiceProgress::Instance().TaskTracker().Active();
- auto sample = ServeServiceProgress::Instance().TaskTracker().Sample();
+ auto active = progress->TaskTracker().Active();
+ auto sample = progress->TaskTracker().Sample();
auto msg = fmt::format(
- "{} cached, {} served, {} processing", cached, served, processing);
+ "Export targets: {} found [{} cached{}, {} analysed locally]",
+ found,
+ cached,
+ has_serve ? fmt::format(", {} served", served) : "",
+ uncached + not_eligible);
if ((active > 0) && !sample.empty()) {
msg = fmt::format("{} ({}{})",
diff --git a/src/buildtool/progress_reporting/exports_progress_reporter.hpp b/src/buildtool/progress_reporting/exports_progress_reporter.hpp
new file mode 100644
index 00000000..888409df
--- /dev/null
+++ b/src/buildtool/progress_reporting/exports_progress_reporter.hpp
@@ -0,0 +1,32 @@
+// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_EXPORTS_PROGRESS_REPORTER_HPP
+#define INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_EXPORTS_PROGRESS_REPORTER_HPP
+
+#include "gsl/gsl"
+#include "src/buildtool/common/statistics.hpp"
+#include "src/buildtool/progress_reporting/base_progress_reporter.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
+
+/// \brief Reporter for progress in analysing export targets
+class ExportsProgressReporter {
+ public:
+ [[nodiscard]] static auto Reporter(gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ bool has_serve) noexcept
+ -> progress_reporter_t;
+};
+
+#endif // INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_EXPORTS_PROGRESS_REPORTER_HPP
diff --git a/src/buildtool/serve_api/progress_reporting/TARGETS b/src/buildtool/serve_api/progress_reporting/TARGETS
deleted file mode 100644
index c3a9abb4..00000000
--- a/src/buildtool/serve_api/progress_reporting/TARGETS
+++ /dev/null
@@ -1,29 +0,0 @@
-{ "statistics":
- { "type": ["@", "rules", "CC", "library"]
- , "name": ["statistics"]
- , "hdrs": ["statistics.hpp"]
- , "stage": ["src", "buildtool", "serve_api", "progress_reporting"]
- }
-, "progress":
- { "type": ["@", "rules", "CC", "library"]
- , "name": ["progress"]
- , "hdrs": ["progress.hpp"]
- , "stage": ["src", "buildtool", "serve_api", "progress_reporting"]
- , "deps": [["src/buildtool/progress_reporting", "task_tracker"]]
- }
-, "progress_reporter":
- { "type": ["@", "rules", "CC", "library"]
- , "name": ["progress_reporter"]
- , "hdrs": ["progress_reporter.hpp"]
- , "srcs": ["progress_reporter.cpp"]
- , "stage": ["src", "buildtool", "serve_api", "progress_reporting"]
- , "deps": [["src/buildtool/progress_reporting", "base_progress_reporter"]]
- , "private-deps":
- [ "progress"
- , "statistics"
- , ["@", "fmt", "", "fmt"]
- , ["@", "json", "", "json"]
- , ["src/buildtool/logging", "logging"]
- ]
- }
-}
diff --git a/src/buildtool/serve_api/progress_reporting/progress.hpp b/src/buildtool/serve_api/progress_reporting/progress.hpp
deleted file mode 100644
index adf06e00..00000000
--- a/src/buildtool/serve_api/progress_reporting/progress.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_HPP
-#define INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_HPP
-
-#include <cstdlib>
-#include <string>
-#include <unordered_set>
-#include <utility>
-#include <vector>
-
-#include "src/buildtool/progress_reporting/task_tracker.hpp"
-
-class ServeServiceProgress {
- public:
- [[nodiscard]] static auto Instance() noexcept -> ServeServiceProgress& {
- static ServeServiceProgress instance{};
- return instance;
- }
-
- [[nodiscard]] auto TaskTracker() noexcept -> TaskTracker& {
- return task_tracker_;
- }
-
- private:
- ::TaskTracker task_tracker_{};
-};
-
-#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_HPP
diff --git a/src/buildtool/serve_api/progress_reporting/progress_reporter.hpp b/src/buildtool/serve_api/progress_reporting/progress_reporter.hpp
deleted file mode 100644
index 2162393d..00000000
--- a/src/buildtool/serve_api/progress_reporting/progress_reporter.hpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
-#define INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
-
-#include "src/buildtool/progress_reporting/base_progress_reporter.hpp"
-
-class ServeServiceProgressReporter {
- public:
- [[nodiscard]] static auto Reporter() noexcept -> progress_reporter_t;
-};
-
-#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
diff --git a/src/buildtool/serve_api/progress_reporting/statistics.hpp b/src/buildtool/serve_api/progress_reporting/statistics.hpp
deleted file mode 100644
index 6c1aa352..00000000
--- a/src/buildtool/serve_api/progress_reporting/statistics.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_STATISTICS_HPP
-#define INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_STATISTICS_HPP
-
-#include <atomic>
-
-class ServeServiceStatistics {
- public:
- [[nodiscard]] static auto Instance() noexcept -> ServeServiceStatistics& {
- static ServeServiceStatistics instance{};
- return instance;
- }
-
- void Reset() noexcept {
- num_cache_hits_ = 0;
- num_dispatched_ = 0;
- num_served_ = 0;
- }
- void IncrementCacheHitsCounter() noexcept { ++num_cache_hits_; }
- void IncrementDispatchedCounter() noexcept { ++num_dispatched_; }
- void IncrementServedCounter() noexcept { ++num_served_; }
-
- [[nodiscard]] auto CacheHitsCounter() const noexcept -> int {
- return num_cache_hits_;
- }
- [[nodiscard]] auto DispatchedCounter() const noexcept -> int {
- return num_dispatched_;
- }
- [[nodiscard]] auto ServedCounter() const noexcept -> int {
- return num_served_;
- }
-
- private:
- // locally cached export targets
- std::atomic<int> num_cache_hits_{};
- // export targets for which we have queried just serve
- std::atomic<int> num_dispatched_{};
- // export targets for which just serve responded
- std::atomic<int> num_served_{};
-};
-
-#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_PROGRESS_REPORTING_STATISTICS_HPP