diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-01-10 16:28:34 +0100 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2023-02-27 20:59:25 +0100 |
commit | 80a82e4e8bd4ff2fba980690e14d416dfa4f79a8 (patch) | |
tree | 89fffc855b671b0ba369071171c2f11b68114a52 /src/other_tools/ops_maps/repo_fetch_map.cpp | |
parent | 67a388abe3e5de939771bf22f61d0f78b2ca2f63 (diff) | |
download | justbuild-80a82e4e8bd4ff2fba980690e14d416dfa4f79a8.tar.gz |
Just-MR: Add progress reporting for fetch command
Co-authored-by: Sascha Roloff <sascha.roloff@huawei.com>
Diffstat (limited to 'src/other_tools/ops_maps/repo_fetch_map.cpp')
-rw-r--r-- | src/other_tools/ops_maps/repo_fetch_map.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/other_tools/ops_maps/repo_fetch_map.cpp b/src/other_tools/ops_maps/repo_fetch_map.cpp index 890e8518..39474b12 100644 --- a/src/other_tools/ops_maps/repo_fetch_map.cpp +++ b/src/other_tools/ops_maps/repo_fetch_map.cpp @@ -16,6 +16,8 @@ #include "src/buildtool/execution_api/local/local_cas.hpp" #include "src/buildtool/file_system/file_storage.hpp" +#include "src/other_tools/just_mr/progress_reporting/progress.hpp" +#include "src/other_tools/just_mr/progress_reporting/statistics.hpp" #include "src/other_tools/just_mr/utils.hpp" auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, @@ -26,16 +28,20 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, auto logger, auto /* unused */, auto const& key) { - // if archive available as a git tree ID stored to file, - // that's good enough, as it means it needs no fetching - auto tree_id_file = JustMR::Utils::GetArchiveTreeIDFile( - key.repo_type, key.archive.content); + // get corresponding distfile auto distfile = (key.archive.distfile ? key.archive.distfile.value() : std::filesystem::path(key.archive.fetch_url) .filename() .string()); + // if archive available as a git tree ID stored to file, + // that's good enough, as it means it needs no fetching + auto tree_id_file = JustMR::Utils::GetArchiveTreeIDFile( + key.repo_type, key.archive.content); if (not FileSystemManager::Exists(tree_id_file)) { + // start work reporting + JustMRProgress::Instance().TaskTracker().Start(key.archive.origin); + JustMRStatistics::Instance().IncrementQueuedCounter(); // make sure content is in CAS content_cas_map->ConsumeAfterKeysReady( ts, @@ -43,6 +49,7 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, [fetch_dir, content = key.archive.content, distfile, + origin = key.archive.origin, setter, logger]([[maybe_unused]] auto const& values) { // content is now in CAS @@ -70,6 +77,9 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, } // success (*setter)(true); + // report work done + JustMRProgress::Instance().TaskTracker().Stop(origin); + JustMRStatistics::Instance().IncrementExecutedCounter(); } else { (*logger)( @@ -112,6 +122,8 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, } // success (*setter)(true); + // report cache hit + JustMRStatistics::Instance().IncrementCacheHitsCounter(); } else { (*logger)(fmt::format("Content {} could not be found in CAS", |