diff options
Diffstat (limited to 'src')
7 files changed, 14 insertions, 10 deletions
diff --git a/src/buildtool/execution_api/common/common_api.cpp b/src/buildtool/execution_api/common/common_api.cpp index 69cd86fb..47542bc0 100644 --- a/src/buildtool/execution_api/common/common_api.cpp +++ b/src/buildtool/execution_api/common/common_api.cpp @@ -214,7 +214,7 @@ auto UpdateContainerAndUpload( // that we never store unnecessarily more data in the container than we need // per remote transfer. try { - if (blob.data->size() > kMaxBatchTransferSize) { + if (blob.data->size() > MessageLimits::kMaxGrpcLength) { // large blobs use individual stream upload if (not uploader( std::unordered_set<ArtifactBlob>{{std::move(blob)}})) { @@ -228,7 +228,8 @@ auto UpdateContainerAndUpload( content_size += blob.data->size(); } - if (content_size + blob.data->size() > kMaxBatchTransferSize) { + if (content_size + blob.data->size() > + MessageLimits::kMaxGrpcLength) { // swap away from original container to allow move during // upload std::unordered_set<ArtifactBlob> tmp_container{}; diff --git a/src/buildtool/execution_api/common/message_limits.cpp b/src/buildtool/execution_api/common/message_limits.cpp index 8a96d1bf..21247e70 100644 --- a/src/buildtool/execution_api/common/message_limits.cpp +++ b/src/buildtool/execution_api/common/message_limits.cpp @@ -16,5 +16,6 @@ #include <grpc/grpc.h> -static_assert(kMaxBatchTransferSize < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH, +static_assert(MessageLimits::kMaxGrpcLength < + GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH, "Max batch transfer size too large."); diff --git a/src/buildtool/execution_api/common/message_limits.hpp b/src/buildtool/execution_api/common/message_limits.hpp index c2b1b5f7..65b747a2 100644 --- a/src/buildtool/execution_api/common/message_limits.hpp +++ b/src/buildtool/execution_api/common/message_limits.hpp @@ -17,7 +17,9 @@ #include <cstddef> -// Max size for batch transfers -inline constexpr std::size_t kMaxBatchTransferSize = 3UL * 1024 * 1024; +struct MessageLimits final { + // Maximum length of a gprc message. + static constexpr std::size_t kMaxGrpcLength = 3UL * 1024 * 1024; +}; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_COMMON_MESSAGE_LIMITS_HPP diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp index 0024ea97..8a3eb335 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp @@ -659,7 +659,7 @@ auto BazelCasClient::CreateBatchRequestsMaxSize( request.set_instance_name(instance_name); request_builder(&request, blob); if (accumulating_request.ByteSizeLong() + request.ByteSizeLong() > - kMaxBatchTransferSize) { + MessageLimits::kMaxGrpcLength) { result.emplace_back(std::move(accumulating_request)); accumulating_request = std::move(request); } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp index 7b15b667..823148f0 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -86,7 +86,7 @@ auto BazelNetwork::DoUploadBlobs( std::vector<IteratorType> to_stream; to_stream.reserve(blobs.size()); for (auto it = blobs.begin(); it != blobs.end(); ++it) { - if (it->data->size() > kMaxBatchTransferSize) { + if (it->data->size() > MessageLimits::kMaxGrpcLength) { to_stream.push_back(it); } } 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 ad61c944..4626c997 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp @@ -51,7 +51,7 @@ BazelNetworkReader::BazelNetworkReader( auto full_tree = cas_.GetTree(instance_name_, ArtifactDigestFactory::ToBazel(*request_remote_tree), - kMaxBatchTransferSize); + MessageLimits::kMaxGrpcLength); auxiliary_map_ = MakeAuxiliaryMap(std::move(full_tree)); } } @@ -254,7 +254,7 @@ namespace { for (auto it = begin; it != end; ++it) { std::size_t const blob_size = it->size(); size += blob_size; - if (blob_size == 0 or size > kMaxBatchTransferSize) { + if (blob_size == 0 or size > MessageLimits::kMaxGrpcLength) { return it; } } diff --git a/src/buildtool/storage/garbage_collector.cpp b/src/buildtool/storage/garbage_collector.cpp index 0f4dcdae..3ad0f481 100644 --- a/src/buildtool/storage/garbage_collector.cpp +++ b/src/buildtool/storage/garbage_collector.cpp @@ -167,7 +167,7 @@ auto GarbageCollector::TriggerGarbageCollection( // Otherwise, an interruption of the process during compactification // would lead to an invalid old generation. if (not GarbageCollector::Compactify(storage_config, - kMaxBatchTransferSize)) { + MessageLimits::kMaxGrpcLength)) { Logger::Log(LogLevel::Error, "Failed to compactify the youngest generation."); return false; |