Skip to content

Commit 8689045

Browse files
laramielcopybara-github
authored andcommitted
kvstore/gcs_grpc updates:
* Minor consistency and other changes for gcs_grpc ops. * Add additional tests for gcs_grpc read, with a few tensorstore::Batch cases. * Cleanup tsan issue in gcs_grpc_testbench hooks. PiperOrigin-RevId: 833977592 Change-Id: I1ea1003ae0ce61418afe8837444ad587d9e4360a
1 parent bcd9d4e commit 8689045

File tree

11 files changed

+517
-269
lines changed

11 files changed

+517
-269
lines changed

tensorstore/internal/grpc/grpc_mock.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "absl/time/clock.h"
2626
#include "absl/time/time.h"
2727
#include "grpc/grpc_security_constants.h"
28-
#include "grpc/support/log.h"
28+
#include "grpc/support/log.h" // IWYU pragma: keep
2929
#include "grpcpp/channel.h" // third_party
3030
#include "grpcpp/completion_queue.h" // third_party
3131
#include "grpcpp/create_channel.h" // third_party
@@ -35,6 +35,7 @@
3535
#include "grpcpp/server.h" // third_party
3636
#include "grpcpp/server_builder.h" // third_party
3737
#include "grpcpp/server_context.h" // third_party
38+
#include "grpcpp/support/status.h" // third_party // IWYU pragma: keep
3839

3940
namespace tensorstore {
4041
namespace grpc_mocker {
@@ -117,7 +118,7 @@ class MockGrpcServer {
117118
builder.SetSyncServerOption(::grpc::ServerBuilder::NUM_CQS, 2)
118119
.SetSyncServerOption(::grpc::ServerBuilder::MIN_POLLERS, 1)
119120
.SetSyncServerOption(::grpc::ServerBuilder::MAX_POLLERS, 2)
120-
.SetSyncServerOption(::grpc::ServerBuilder::CQ_TIMEOUT_MSEC, 10000);
121+
.SetSyncServerOption(::grpc::ServerBuilder::CQ_TIMEOUT_MSEC, 1000);
121122

122123
builder.AddListeningPort(
123124
"localhost:0", grpc::experimental::LocalServerCredentials(LOCAL_TCP),

tensorstore/kvstore/batch_util.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class BatchReadEntry : public Batch::Impl::Entry {
221221
// This may be useful for implementing retry logic.
222222
template <typename DerivedEntry>
223223
std::unique_ptr<DerivedEntry> MigrateExistingRequestsToNewEntry(
224-
span<Request> existing_requests) {
224+
tensorstore::span<Request> existing_requests) {
225225
using Self =
226226
BatchReadEntry<DerivedDriver, RequestType, BatchEntryKeyMember...>;
227227
static_assert(std::is_base_of_v<Self, DerivedEntry>);
@@ -248,7 +248,7 @@ class BatchReadEntry : public Batch::Impl::Entry {
248248
//
249249
// This may be useful for setting error results.
250250
template <typename Request>
251-
void SetCommonResult(span<const Request> requests,
251+
void SetCommonResult(tensorstore::span<const Request> requests,
252252
Result<kvstore::ReadResult>&& result) {
253253
if (requests.empty()) return;
254254
for (size_t i = 1; i < requests.size(); ++i) {
@@ -263,12 +263,13 @@ void SetCommonResult(span<const Request> requests,
263263
template <typename Requests>
264264
void SetCommonResult(const Requests& requests,
265265
Result<kvstore::ReadResult>&& result) {
266-
SetCommonResult(span<const typename Requests::value_type>(requests),
267-
std::move(result));
266+
SetCommonResult(
267+
tensorstore::span<const typename Requests::value_type>(requests),
268+
std::move(result));
268269
}
269270

270271
template <typename Request>
271-
void SortRequestsByStartByte(span<Request> requests) {
272+
void SortRequestsByStartByte(tensorstore::span<Request> requests) {
272273
std::sort(requests.begin(), requests.end(),
273274
[](const Request& a, const Request& b) {
274275
return a.byte_range.inclusive_min < b.byte_range.inclusive_min;
@@ -278,7 +279,7 @@ void SortRequestsByStartByte(span<Request> requests) {
278279
// Resolves coalesced requests with the appropriate cord subranges.
279280
template <typename Request>
280281
void ResolveCoalescedRequests(ByteRange coalesced_byte_range,
281-
span<Request> coalesced_requests,
282+
tensorstore::span<Request> coalesced_requests,
282283
kvstore::ReadResult&& read_result) {
283284
for (auto& request : coalesced_requests) {
284285
kvstore::ReadResult sub_read_result;
@@ -311,8 +312,8 @@ void ResolveCoalescedRequests(ByteRange coalesced_byte_range,
311312
// coalesced_byte_range, span<Request> coalesced_requests)` to be invoked
312313
// for each coalesced set of requests.
313314
template <typename Request, typename Predicate, typename Callback>
314-
void ForEachCoalescedRequest(span<Request> requests, Predicate predicate,
315-
Callback callback) {
315+
void ForEachCoalescedRequest(tensorstore::span<Request> requests,
316+
Predicate predicate, Callback callback) {
316317
static_assert(IsByteRangeReadRequestLikeV<Request>);
317318

318319
SortRequestsByStartByte(requests);

tensorstore/kvstore/gcs_grpc/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ tensorstore_cc_test(
9494
deps = [
9595
":gcs_grpc",
9696
":mock_storage_service",
97+
"//tensorstore:batch",
9798
"//tensorstore:context",
9899
"//tensorstore/internal:flat_cord_builder",
99100
"//tensorstore/internal/grpc:grpc_mock",

tensorstore/kvstore/gcs_grpc/gcs_grpc.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696

9797
// protos
9898
#include "google/protobuf/empty.pb.h"
99-
#include "google/storage/v2/storage.grpc.pb.h"
10099
#include "google/storage/v2/storage.pb.h"
101100

102101
namespace jb = tensorstore::internal_json_binding;
@@ -114,7 +113,6 @@ using ::tensorstore::kvstore::ListEntry;
114113
using ::tensorstore::kvstore::ListReceiver;
115114
using ::tensorstore::kvstore::SupportedFeatures;
116115

117-
using ::google::storage::v2::Storage;
118116

119117
namespace tensorstore {
120118
namespace internal_gcs_grpc {

0 commit comments

Comments
 (0)