Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(storage): Use ReadHandle for faster re-connect #11510

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions storage/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,15 @@ func (c *grpcStorageClient) NewMultiRangeDownloader(ctx context.Context, params

ctx = gax.InsertMetadataIntoOutgoingContext(ctx, contextMetadataFromBidiReadObject(req)...)

openStream := func() (*bidiReadStreamResponse, context.CancelFunc, error) {
openStream := func(readHandle ReadHandle) (*bidiReadStreamResponse, context.CancelFunc, error) {
if err := applyCondsProto("grpcStorageClient.BidiReadObject", params.gen, params.conds, r); err != nil {
return nil, nil, err
}
if readHandle != nil {
req.GetReadObjectSpec().ReadHandle = &storagepb.BidiReadHandle{
Handle: readHandle,
}
}
var stream storagepb.Storage_BidiReadObjectClient
var resp *storagepb.BidiReadObjectResponse
cc, cancel := context.WithCancel(ctx)
Expand Down Expand Up @@ -1158,7 +1163,7 @@ func (c *grpcStorageClient) NewMultiRangeDownloader(ctx context.Context, params
}

// For the first time open stream without adding any range.
resp, cancel, err := openStream()
resp, cancel, err := openStream(nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1419,7 +1424,7 @@ func (r *gRPCBidiReader) reopenStream(failSpec []rangeSpec) error {
r.cancel()
}

res, cancel, err := r.reopen()
res, cancel, err := r.reopen(r.readHandle)
if err != nil {
return err
}
Expand Down Expand Up @@ -1894,7 +1899,7 @@ type gRPCBidiReader struct {
settings *settings
readHandle ReadHandle
readID int64
reopen func() (*bidiReadStreamResponse, context.CancelFunc, error)
reopen func(ReadHandle) (*bidiReadStreamResponse, context.CancelFunc, error)
readSpec *storagepb.BidiReadObjectSpec
data chan []rangeSpec
ctx context.Context
Expand Down
Loading