summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-04-03 17:35:40 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-04-04 09:51:02 +0200
commit5b1cff33886090b018ef16ed3abc509601e838da (patch)
tree83aed59bd1b55ce4146aad9e30dac8f86fd54aed /src
parentf2052ea627d1df8d6a427096d4146a70fcb15548 (diff)
downloadjustbuild-5b1cff33886090b018ef16ed3abc509601e838da.tar.gz
just: Interleave graph dumping with other tasks
... and only as late as possible wait for that parallel task. Serializing a large task to JSON can take several seconds and as building does not depend on it, we shouldn't delay the build for with extra information.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/main/main.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 108b9798..158b4a9b 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -26,6 +26,7 @@
#include <optional>
#include <set>
#include <string>
+#include <thread>
#include <utility>
#include <variant>
#include <vector>
@@ -1182,26 +1183,31 @@ auto main(int argc, char* argv[]) -> int {
not_eligible);
}
- analyse_result->result_map.ToFile(
- arguments.analysis.graph_file, &stats, &progress);
- analyse_result->result_map.ToFile</*kIncludeOrigins=*/false>(
- arguments.analysis.graph_file_plain, &stats, &progress);
- auto const [artifacts, runfiles] =
+ auto const artifacts_runfiles =
ReadOutputArtifacts(analyse_result->target);
- if (arguments.analysis.artifacts_to_build_file) {
- DumpArtifactsToBuild(
- artifacts,
- runfiles,
- *arguments.analysis.artifacts_to_build_file);
- }
- if (arguments.cmd == SubCommand::kAnalyse) {
- DiagnoseResults(*analyse_result, arguments.diagnose);
- ReportTaintedness(*analyse_result);
+
+ auto const& [artifacts, runfiles] = artifacts_runfiles;
+ auto dump_and_cleanup = [&]() {
+ analyse_result->result_map.ToFile(
+ arguments.analysis.graph_file, &stats, &progress);
+ analyse_result->result_map.ToFile</*kIncludeOrigins=*/false>(
+ arguments.analysis.graph_file_plain, &stats, &progress);
+ if (arguments.analysis.artifacts_to_build_file) {
+ DumpArtifactsToBuild(
+ artifacts_runfiles.first,
+ artifacts_runfiles.second,
+ *arguments.analysis.artifacts_to_build_file);
+ }
// Clean up in parallel
{
TaskSystem ts{arguments.common.jobs};
analyse_result->result_map.Clear(&ts);
}
+ };
+ if (arguments.cmd == SubCommand::kAnalyse) {
+ DiagnoseResults(*analyse_result, arguments.diagnose);
+ dump_and_cleanup();
+ ReportTaintedness(*analyse_result);
if (profile) {
(*profile)->Write(kExitSuccess);
}
@@ -1217,11 +1223,7 @@ auto main(int argc, char* argv[]) -> int {
analyse_result->result_map.CacheTargets();
auto cache_artifacts = CollectNonKnownArtifacts(cache_targets);
- // Clean up analyse_result map, now that it is no longer needed
- {
- TaskSystem ts{arguments.common.jobs};
- analyse_result->result_map.Clear(&ts);
- }
+ std::thread dump_and_cleanup_thread(dump_and_cleanup);
Logger::Log(
LogLevel::Info,
@@ -1241,6 +1243,7 @@ auto main(int argc, char* argv[]) -> int {
std::move(blobs),
std::move(trees),
std::move(cache_artifacts));
+ dump_and_cleanup_thread.join();
if (build_result) {
WriteTargetCacheEntries(
cache_targets,