diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-10 17:02:38 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-11 10:21:28 +0200 |
commit | 140e8c993b9d5d4490c1f657affced2d48abf4af (patch) | |
tree | e93cdc3d5715e998296c7918464055b3b99996f8 /src/buildtool/execution_api/remote/bazel | |
parent | 42fdba2e30e020e4f3709b17cb828cd3ca015873 (diff) | |
download | justbuild-140e8c993b9d5d4490c1f657affced2d48abf4af.tar.gz |
Drop unused directory map
The BazelNetworkReader contains an optimization for reading directories
in case the remote execution (in compatible mode) supports the GetTree
request. This is, however not the case for many remote exeuciton
services, including our own single-node execution service. So the
code is basically untested and rarely used, if at all. Moreover,
justbuild is usually used in native mode and using compatibility
mode is expected to handle tree operations less efficient.
Therefore, remove this basically dead code and decrease complexity
this way.
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel')
3 files changed, 2 insertions, 64 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index fe6ad757..f15d421d 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -191,11 +191,8 @@ auto BazelApi::CreateAction( else { if (IsTreeObject(info.type)) { // read object infos from sub tree and call retrieve recursively - auto request_remote_tree = alternative != nullptr - ? std::make_optional(info.digest) - : std::nullopt; - auto reader = TreeReader<BazelNetworkReader>{ - network_->CreateReader(), std::move(request_remote_tree)}; + auto reader = + TreeReader<BazelNetworkReader>{network_->CreateReader()}; auto const result = reader.RecursivelyReadTreeLeafs( info.digest, output_paths[i]); if (not result or diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp index 6f125d67..4580cf22 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp @@ -21,11 +21,8 @@ #include <unordered_set> #include <utility> -#include "src/buildtool/common/artifact_digest_factory.hpp" #include "src/buildtool/common/protocol_traits.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp" -#include "src/buildtool/execution_api/common/message_limits.hpp" -#include "src/buildtool/file_system/object_type.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/back_map.hpp" @@ -40,32 +37,8 @@ BazelNetworkReader::BazelNetworkReader( cas_{*cas}, hash_function_{hash_function} {} -BazelNetworkReader::BazelNetworkReader( - BazelNetworkReader&& other, - std::optional<ArtifactDigest> request_remote_tree) noexcept - : instance_name_{other.instance_name_}, - cas_{other.cas_}, - hash_function_{other.hash_function_} { - if (not IsNativeProtocol() and request_remote_tree) { - // Query full tree from remote CAS. Note that this is currently not - // supported by Buildbarn revision c3c06bbe2a. - auto full_tree = - cas_.GetTree(instance_name_, - ArtifactDigestFactory::ToBazel(*request_remote_tree), - MessageLimits::kMaxGrpcLength); - auxiliary_map_ = MakeAuxiliaryMap(std::move(full_tree)); - } -} - auto BazelNetworkReader::ReadDirectory(ArtifactDigest const& digest) const noexcept -> std::optional<bazel_re::Directory> { - if (auxiliary_map_) { - auto it = auxiliary_map_->find(digest); - if (it != auxiliary_map_->end()) { - return it->second; - } - } - if (auto blob = ReadSingleBlob(digest)) { if (auto const content = blob->ReadContent()) { return BazelMsgFactory::MessageFromString<bazel_re::Directory>( @@ -152,25 +125,6 @@ auto BazelNetworkReader::IsNativeProtocol() const noexcept -> bool { return ProtocolTraits::IsNative(hash_function_.GetType()); } -auto BazelNetworkReader::MakeAuxiliaryMap( - std::vector<bazel_re::Directory>&& full_tree) const noexcept - -> std::optional<DirectoryMap> { - ExpectsAudit(not IsNativeProtocol()); - - DirectoryMap result; - result.reserve(full_tree.size()); - for (auto& dir : full_tree) { - try { - result.emplace(ArtifactDigestFactory::HashDataAs<ObjectType::File>( - hash_function_, dir.SerializeAsString()), - std::move(dir)); - } catch (...) { - return std::nullopt; - } - } - return result; -} - auto BazelNetworkReader::ReadSingleBlob(ArtifactDigest const& digest) const noexcept -> std::optional<ArtifactBlob> { return cas_.ReadSingleBlob(instance_name_, digest); diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp index f7915446..fb138844 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp @@ -19,7 +19,6 @@ #include <functional> #include <optional> #include <string> -#include <unordered_map> #include <unordered_set> #include <vector> @@ -42,10 +41,6 @@ class BazelNetworkReader final { gsl::not_null<BazelCasClient const*> const& cas, HashFunction hash_function) noexcept; - BazelNetworkReader( - BazelNetworkReader&& other, - std::optional<ArtifactDigest> request_remote_tree) noexcept; - [[nodiscard]] auto ReadDirectory(ArtifactDigest const& digest) const noexcept -> std::optional<bazel_re::Directory>; @@ -79,17 +74,9 @@ class BazelNetworkReader final { const noexcept -> std::vector<ArtifactBlob>; private: - using DirectoryMap = - std::unordered_map<ArtifactDigest, bazel_re::Directory>; - std::string const instance_name_; BazelCasClient const& cas_; HashFunction hash_function_; - std::optional<DirectoryMap> auxiliary_map_; - - [[nodiscard]] auto MakeAuxiliaryMap( - std::vector<bazel_re::Directory>&& full_tree) const noexcept - -> std::optional<DirectoryMap>; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_TREE_READER_HPP |