diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-06 14:26:48 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-07 13:30:06 +0200 |
commit | 947a1e16e8079592773c055e86d9c4cbb8c305a8 (patch) | |
tree | af9c81f745aa61fc2cd601c9b67716221f2e56db /src/buildtool/execution_api/local/local_storage.cpp | |
parent | 51f8b186803292f111011d04d5291deb374dc34c (diff) | |
download | justbuild-947a1e16e8079592773c055e86d9c4cbb8c305a8.tar.gz |
LocalTreeMap: Drop the use of the map entirely
... as for remote execution, the map entries are only used
for the `install` subcommand. For local execution, much less
tree objects are read from CAS when using this map. However,
the performance benefit is barely measurable and therefore
we rather remove this map entirely to reduce complexity.
Diffstat (limited to 'src/buildtool/execution_api/local/local_storage.cpp')
-rw-r--r-- | src/buildtool/execution_api/local/local_storage.cpp | 77 |
1 files changed, 13 insertions, 64 deletions
diff --git a/src/buildtool/execution_api/local/local_storage.cpp b/src/buildtool/execution_api/local/local_storage.cpp index 483f664f..b8e8401c 100644 --- a/src/buildtool/execution_api/local/local_storage.cpp +++ b/src/buildtool/execution_api/local/local_storage.cpp @@ -113,78 +113,27 @@ auto LocalStorage::ReadObjectInfosRecursively( BazelMsgFactory::InfoStoreFunc const& store_info, std::filesystem::path const& parent, bazel_re::Digest const& digest) const noexcept -> bool { - // read from in-memory tree map - auto const* tree = tree_map_.GetTree(digest); - if (tree != nullptr) { - return std::all_of( - tree->begin(), - tree->end(), - [&store_info, &parent](auto const& entry) { - try { - // LocalTree (from tree_map_) is flat, no recursion needed - auto const& [path, info] = entry; - return store_info(parent / path, *info); - } catch (...) { // satisfy clang-tidy, store_info() could - return false; - } - }); - } - Logger::Log( - LogLevel::Debug, "tree {} not found in tree map", digest.hash()); - - // fallback read from CAS and cache it in in-memory tree map + // read from CAS if (Compatibility::IsCompatible()) { if (auto dir = ReadDirectory(this, digest)) { - auto tree = tree_map_.CreateTree(); return BazelMsgFactory::ReadObjectInfosFromDirectory( - *dir, - [this, &store_info, &parent, &tree](auto path, - auto info) { - if (IsTreeObject(info.type)) { - // LocalTree (from tree_map_) is flat, so - // recursively traverse subtrees and add blobs. - auto tree_store_info = - [&store_info, &tree, &parent](auto path, - auto info) { - auto tree_path = - path.lexically_relative(parent); - return tree.AddInfo(tree_path, info) and - store_info(path, info); - }; - return ReadObjectInfosRecursively( - tree_store_info, parent / path, info.digest); - } - return tree.AddInfo(path, info) and - store_info(parent / path, info); - }) and - tree_map_.AddTree(digest, std::move(tree)); + *dir, [this, &store_info, &parent](auto path, auto info) { + return IsTreeObject(info.type) + ? ReadObjectInfosRecursively( + store_info, parent / path, info.digest) + : store_info(parent / path, info); + }); } } else { if (auto entries = ReadGitTree(this, digest)) { - auto tree = tree_map_.CreateTree(); return BazelMsgFactory::ReadObjectInfosFromGitTree( - *entries, - [this, &store_info, &parent, &tree](auto path, - auto info) { - if (IsTreeObject(info.type)) { - // LocalTree (from tree_map_) is flat, so - // recursively traverse subtrees and add blobs. - auto tree_store_info = - [&store_info, &tree, &parent](auto path, - auto info) { - auto tree_path = - path.lexically_relative(parent); - return tree.AddInfo(tree_path, info) and - store_info(path, info); - }; - return ReadObjectInfosRecursively( - tree_store_info, parent / path, info.digest); - } - return tree.AddInfo(path, info) and - store_info(parent / path, info); - }) and - tree_map_.AddTree(digest, std::move(tree)); + *entries, [this, &store_info, &parent](auto path, auto info) { + return IsTreeObject(info.type) + ? ReadObjectInfosRecursively( + store_info, parent / path, info.digest) + : store_info(parent / path, info); + }); } } return false; |