Skip to content

Commit 7b49152

Browse files
authored
feat(storage): Benchmark with experimental MRD. (#11501)
Allow benchmarks to use the experimental MultiRangeDownloader for normal range reads. Note that this does not use a single MultiRangeDownloader across multiple reads, which is supported but would require a more invasive change to the benchmark.
1 parent e99577b commit 7b49152

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

storage/internal/benchmarks/client_pool.go

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"cloud.google.com/go/storage"
25+
"cloud.google.com/go/storage/experimental"
2526
"golang.org/x/net/http2"
2627
"google.golang.org/api/option"
2728
htransport "google.golang.org/api/transport/http"
@@ -137,6 +138,7 @@ func initializeClientPools(ctx context.Context, opts *benchmarkOptions) func() {
137138
readBufferSize: opts.readBufferSize,
138139
connectionPoolSize: opts.connPoolSize,
139140
endpoint: opts.endpoint,
141+
useGRPCBidiReads: opts.gRPCBidiReads,
140142
})
141143
},
142144
opts.numClients,
@@ -179,6 +181,7 @@ type clientConfig struct {
179181
useJSON bool // only applicable to HTTP Clients
180182
setGCSFuseOpts bool // only applicable to HTTP Clients
181183
connectionPoolSize int // only applicable to GRPC Clients
184+
useGRPCBidiReads bool // only applicable to GRPC Clients
182185
}
183186

184187
func initializeHTTPClient(ctx context.Context, config clientConfig) (*storage.Client, error) {
@@ -247,6 +250,9 @@ func initializeGRPCClient(ctx context.Context, config clientConfig) (*storage.Cl
247250
if config.readBufferSize != useDefault {
248251
opts = append(opts, option.WithGRPCDialOption(grpc.WithReadBufferSize(config.readBufferSize)))
249252
}
253+
if config.useGRPCBidiReads {
254+
opts = append(opts, experimental.WithGRPCBidiReads())
255+
}
250256

251257
client, err := storage.NewGRPCClient(ctx, opts...)
252258

storage/internal/benchmarks/main.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ type benchmarkOptions struct {
8282
minChunkSize int64
8383
maxChunkSize int64
8484

85-
appendWrites bool
85+
appendWrites bool
86+
gRPCBidiReads bool
8687

8788
forceGC bool
8889
connPoolSize int
@@ -145,6 +146,7 @@ func (b *benchmarkOptions) String() string {
145146
fmt.Sprintf("range offset:\t\t%d - %d bytes ", b.minReadOffset, b.maxReadOffset),
146147
fmt.Sprintf("range size:\t\t%d bytes (0 -> full object)", b.rangeSize),
147148
fmt.Sprintf("append writes:\t\t%t", b.appendWrites),
149+
fmt.Sprintf("gRPC bidi reads:\t%t", b.gRPCBidiReads),
148150
fmt.Sprintf("connection pool size:\t%d (GRPC)", b.connPoolSize),
149151
fmt.Sprintf("num workers:\t\t%d (max number of concurrent benchmark runs at a time)", b.numWorkers),
150152
fmt.Sprintf("force garbage collection:%t", b.forceGC),
@@ -189,6 +191,7 @@ func parseFlags() {
189191
flag.Int64Var(&opts.maxChunkSize, "max_chunksize", useDefault, "max chunksize in bytes")
190192

191193
flag.BoolVar(&opts.appendWrites, "append_writes", false, "use the append writer")
194+
flag.BoolVar(&opts.gRPCBidiReads, "grpc_bidi_reads", false, "use BidiReadObject for gRPC reads")
192195

193196
flag.IntVar(&opts.connPoolSize, "connection_pool_size", 4, "GRPC connection pool size")
194197

@@ -233,8 +236,14 @@ func parseFlags() {
233236
}
234237
}
235238

236-
if opts.appendWrites && (opts.api != grpcAPI && opts.api != directPath) {
237-
log.Fatalf("--append_writes requires GRPC or DirectPath; got %v", opts.api)
239+
if opts.api != grpcAPI && opts.api != directPath {
240+
if opts.appendWrites {
241+
log.Fatalf("--append_writes requires GRPC or DirectPath; got %v", opts.api)
242+
}
243+
244+
if opts.gRPCBidiReads {
245+
log.Fatalf("--grpc_bidi_reads requires GRPC or DirectPath; got %v", opts.api)
246+
}
238247
}
239248
}
240249

0 commit comments

Comments
 (0)