Skip to content

Commit

Permalink
Merge branch 'main' into release-please--branches--main
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo authored Feb 12, 2025
2 parents 4e20341 + 7b49152 commit 1c607c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions storage/internal/benchmarks/client_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"cloud.google.com/go/storage"
"cloud.google.com/go/storage/experimental"
"golang.org/x/net/http2"
"google.golang.org/api/option"
htransport "google.golang.org/api/transport/http"
Expand Down Expand Up @@ -137,6 +138,7 @@ func initializeClientPools(ctx context.Context, opts *benchmarkOptions) func() {
readBufferSize: opts.readBufferSize,
connectionPoolSize: opts.connPoolSize,
endpoint: opts.endpoint,
useGRPCBidiReads: opts.gRPCBidiReads,
})
},
opts.numClients,
Expand Down Expand Up @@ -179,6 +181,7 @@ type clientConfig struct {
useJSON bool // only applicable to HTTP Clients
setGCSFuseOpts bool // only applicable to HTTP Clients
connectionPoolSize int // only applicable to GRPC Clients
useGRPCBidiReads bool // only applicable to GRPC Clients
}

func initializeHTTPClient(ctx context.Context, config clientConfig) (*storage.Client, error) {
Expand Down Expand Up @@ -247,6 +250,9 @@ func initializeGRPCClient(ctx context.Context, config clientConfig) (*storage.Cl
if config.readBufferSize != useDefault {
opts = append(opts, option.WithGRPCDialOption(grpc.WithReadBufferSize(config.readBufferSize)))
}
if config.useGRPCBidiReads {
opts = append(opts, experimental.WithGRPCBidiReads())
}

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

Expand Down
15 changes: 12 additions & 3 deletions storage/internal/benchmarks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ type benchmarkOptions struct {
minChunkSize int64
maxChunkSize int64

appendWrites bool
appendWrites bool
gRPCBidiReads bool

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

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

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

Expand Down Expand Up @@ -233,8 +236,14 @@ func parseFlags() {
}
}

if opts.appendWrites && (opts.api != grpcAPI && opts.api != directPath) {
log.Fatalf("--append_writes requires GRPC or DirectPath; got %v", opts.api)
if opts.api != grpcAPI && opts.api != directPath {
if opts.appendWrites {
log.Fatalf("--append_writes requires GRPC or DirectPath; got %v", opts.api)
}

if opts.gRPCBidiReads {
log.Fatalf("--grpc_bidi_reads requires GRPC or DirectPath; got %v", opts.api)
}
}
}

Expand Down

0 comments on commit 1c607c8

Please sign in to comment.