Skip to content

feat(storage): add speculative open hedging to AsyncClient::Open - #16612

Draft
ajayky-os wants to merge 4 commits into
googleapis:mainfrom
ajayky-os:feat/storage-bidi-open-hedging
Draft

ajayky-os wants to merge 4 commits into
googleapis:mainfrom
ajayky-os:feat/storage-bidi-open-hedging

Conversation

@ajayky-os

@ajayky-os ajayky-os commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stacked PR (Part 3 of 3): Stacked on #16613 (fix(storage): make OpenStream and OpenObject cancellation-safe), #16715 (refactor(storage): extract HedgeLimiter from HedgingThreadPool), and #16716 (impl(storage): add HedgedOpenStream coordinator for async Open).

Summary

Extends storage_experimental::EnableReadHedgingOption to storage::AsyncClient::Open() (BidiReadObject) by wiring AsyncConnectionImpl::Open() to HedgedOpenStream (#16716) and HedgeLimiter (#16715), racing slow initial stream-open handshakes against delayed speculative attempts on the gRPC CompletionQueue.

Motivation

Opening a BidiReadObject stream requires a multi-step handshake (Start() -> initial Write() -> first Read() returning object metadata and a BidiReadObjectHandle) and can experience severe tail-latency spikes when an individual subchannel, backend task, or DirectPath/CloudPath route stalls during connection setup or backend routing. Previously, EnableReadHedgingOption only hedged synchronous storage::Client::ReadObject() streams, leaving storage::AsyncClient::Open() vulnerable to single-attempt open stalls until the per-stream stall timeout (DownloadStallTimeoutOption) expired.

Racing the initial Open() handshake against bounded, delayed speculative Open() attempts cuts BidiReadObject open tail latency without duplicating any subsequent ObjectDescriptor::Read() ranged-read payload transfers or spawning dedicated worker thread pools.

Changes

  • AsyncConnectionImpl Wiring (google/cloud/storage/internal/async/connection_impl.{h,cc}):
    • Initializes connection-wide HedgeLimiter (ReadHedgeRateLimitOption, MaxConcurrentHedgesOption, MaxTotalHedgesOption) and HedgedReadMetrics when EnableReadHedgingOption is enabled at client creation.
    • Preserves a zero-overhead disabled fast path in AsyncConnectionImpl::Open(): short-circuits on hedge_limiter_ && !hedge_limiter_->IsTotalBudgetSpent() before any Options hash-map lookups and moves retry/backoff/current into clean_resume_factory last with zero extra atomic shared_ptr refcount traffic.
    • Attaches TrackedFeature::kReadHedging (x-goog-storage-cpp-features) strictly to initial hedged Open() attempts (OpenHedging::kEnabled), keeping MSO standby streams and mid-stream descriptor resumes unhedged and untagged (OpenHedging::kDisabled).
  • Public Documentation (google/cloud/storage/options.h, google/cloud/storage/async/client.h):
    • Documents AsyncClient::Open() support (including per-call overrides, connection-wide limiter options, and storage::AsyncClient::InitialReadRanges behavior) on EnableReadHedgingOption, MaxTotalHedgesOption, ReadHedgeDelayOption, MaxReadHedgesOption, and AsyncClient::Open(), and notes sync-only options (MaximumHedgeBufferOption, ReadThreadPoolSizeOption, HedgingThreadPoolSizeOption).
  • Integration Tests (google/cloud/storage/internal/async/connection_impl_open_test.cc):

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 2, 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 implements experimental request hedging for storage::AsyncClient::Open() stream-open handshakes. It introduces the HedgedOpenOperation class to manage racing the primary stream-open attempt against delayed speculative attempts, and extracts HedgeLimiter from HedgingThreadPool to enforce connection-wide concurrency and rate limits. Additionally, it refactors OpenObject and OpenStream to support robust cancellation during the stream-open handshake, and adds comprehensive unit tests to verify these new behaviors. I have no feedback to provide as there are no review comments.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.68595% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.81%. Comparing base (4a2bfb0) to head (4be7490).

Files with missing lines Patch % Lines
.../storage/internal/async/hedged_open_stream_test.cc 96.81% 10 Missing ⚠️
google/cloud/storage/internal/hedge_limiter.h 85.45% 8 Missing ⚠️
...torage/internal/async/connection_impl_open_test.cc 98.66% 3 Missing ⚠️
...cloud/storage/internal/async/hedged_open_stream.cc 98.48% 3 Missing ⚠️
google/cloud/storage/internal/async/open_object.cc 87.50% 2 Missing ⚠️
...oogle/cloud/storage/internal/hedge_limiter_test.cc 98.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16612      +/-   ##
==========================================
+ Coverage   92.78%   92.81%   +0.02%     
==========================================
  Files        2277     2281       +4     
  Lines      228147   229185    +1038     
==========================================
+ Hits       211696   212718    +1022     
- Misses      16451    16467      +16     

☔ 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.

@ajayky-os
ajayky-os force-pushed the feat/storage-bidi-open-hedging branch 2 times, most recently from 14cafcc to c7ed0e3 Compare November 26, 2026 14:54
@ajayky-os
ajayky-os force-pushed the feat/storage-bidi-open-hedging branch from c7ed0e3 to 4be7490 Compare November 26, 2026 14:55

This branch was successfully deployed

1 active (outdated) deployment
false — e3c716f2 Deployed Nov 2, 2026 by ajayky-os via Save PR ref #12774
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.

1 participant