Skip to content

feat(storage): implement internal pre-warmed stream dispatch and caching for BiDi reads#16259

Open
kalragauri wants to merge 3 commits into
googleapis:mainfrom
kalragauri:feat/fast-open
Open

feat(storage): implement internal pre-warmed stream dispatch and caching for BiDi reads#16259
kalragauri wants to merge 3 commits into
googleapis:mainfrom
kalragauri:feat/fast-open

Conversation

@kalragauri

@kalragauri kalragauri commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR lays the groundwork to support eager streaming for BiDi reads in the GCS async gRPC client. It multiplexes read ranges into the handshake packets and builds the internal object descriptor caching layer.

NOTE: This PR is restricted to internal updates. Public API changes will be introduced in a subsequent PR.

Key Changes

  • Updates internal streaming factories to conditionally append read_ranges into standard metadata headers on the very first BidiReadObjectRequest.
  • Missing offsets or limits natively fall back to 0. This delegates unbounded reads, tail reads, or standard range boundaries to the GCS backend.
  • The pre-warmed stream cache is strictly bound to identical offsets and limits.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for an initial read range (pre-warmed cache range) in the asynchronous storage client, allowing the client to skip making a new request on a cache hit. The review feedback highlights a critical use-after-move bug in AsyncConnectionImpl::Open, fragile member initialization order in ObjectDescriptorImpl, and a style guide violation regarding default parameters in an internal namespace, which requires reordering the constructor parameters and updating its callers.

Comment thread google/cloud/storage/internal/async/connection_impl.cc Outdated
Comment thread google/cloud/storage/internal/async/object_descriptor_impl.cc Outdated
Comment thread google/cloud/storage/internal/async/object_descriptor_impl.h Outdated
Comment thread google/cloud/storage/internal/async/connection_impl.cc Outdated
Comment thread google/cloud/storage/internal/async/object_descriptor_impl_test.cc Outdated
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.24138% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.27%. Comparing base (e493b2d) to head (e944f9d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...le/cloud/storage/internal/async/connection_impl.cc 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16259      +/-   ##
==========================================
- Coverage   92.27%   92.27%   -0.01%     
==========================================
  Files        2214     2214              
  Lines      206505   206629     +124     
==========================================
+ Hits       190556   190667     +111     
- Misses      15949    15962      +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalragauri kalragauri force-pushed the feat/fast-open branch 2 times, most recently from 511f07a to 91619d4 Compare July 15, 2026 09:43
@kalragauri kalragauri marked this pull request as ready for review July 15, 2026 09:48
@kalragauri kalragauri requested review from a team as code owners July 15, 2026 09:48
->Open({std::move(spec),
google::cloud::internal::MergeOptions(std::move(opts),
connection_->options()),
/*initial_read_range=*/absl::nullopt})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in all the cases will there be only one read range or we can give multiple read ranges?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, we are only allowing a single range. This optimization targets the 2 round trip penalty of stream setup + read intent. Once the stream is open, subsequent ranges can be multiplexed onto the established stream asynchronously without blocking the initial application threads.

For advanced use cases that require scattered multiplexed reads, ObjectDescriptorImpl already supports assigning multiple concurrent read_ids downstream once the session is opened:

auto const id = ++read_id_generator_;
it->active_ranges.emplace(id, range);
auto& read_range = *it->stream->next_request.add_read_ranges();
read_range.set_read_id(id);
read_range.set_read_offset(p.start);
read_range.set_read_length(p.length);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I understand that we have feature for sending multiple read requests later, but I think in a request we can send 100 read ranges and we are adding this feature to make our api faster. I just want to know whether sending multiple request with Open would make it more faster or sending one read range would be enough to warm up the stream?

@kalragauri kalragauri requested a review from v-pratap July 16, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants