Skip to content

feat(volo-thrift): improve shmipc fallback, reliability, and performance - #654

Open
shenyj3 wants to merge 6 commits into
mainfrom
agent/shmipc-transport-fallback
Open

feat(volo-thrift): improve shmipc fallback, reliability, and performance#654
shenyj3 wants to merge 6 commits into
mainfrom
agent/shmipc-transport-fallback

Conversation

@shenyj3

@shenyj3 shenyj3 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The previous .shmipc_fallback_address(...) implementation performed fallback inside MakeTransport, after the outer connection pool had already chosen the primary shmipc address as its key. If the shmipc attempt failed and UDS/TCP fallback succeeded, the fallback connection could be stored under the shmipc key and then reused as the wrong transport.

The shmipc path also had several reliability and performance issues:

  • concurrent first requests could initialize multiple SessionManager instances for the same address
  • failed or cancelled pingpong calls could leave unusable streams available for reuse
  • an EOF/error from the underlying reader could hide response bytes that were already buffered
  • large multi-slice shmipc responses were copied through an unnecessarily large intermediate decode buffer

Solution

  • Add public DialPlan and SelectedTransport types and a shared transport acquirer for pingpong and multiplex clients.
    • Walk fallback candidates before sending the request.
    • Pool UDS/TCP transports by the address that was actually dialed.
    • Let shmipc bypass the outer pool because its SessionManager already manages stream reuse.
    • Skip unsupported shmipc candidates for multiplex and continue with the next fallback.
    • Record the selected address and fallback attempt in the request context and transport stats.
  • Replace ClientBuilder::shmipc_fallback_address(...) with a per-request DialPlan injected through ClientContext; update the shmipc example accordingly.
  • Singleflight SessionManager initialization per address with OnceCell.
  • Close failed or cancelled shmipc RPC streams and only recycle successfully completed streams.
  • Return buffered response data before propagating an underlying close/error.
  • Use a smaller shmipc decode buffer so large multi-slice payloads can be read directly into their destination instead of being copied through the reader buffer.
  • Upgrade shmipc from 0.1.1 to 0.2.1 and bump volo to 0.12.4.

Impact

Fallback connections are now pooled under the correct address, stream failures and cancellation no longer leak or recycle dirty shmipc streams, and buffered responses remain readable when the peer closes immediately after sending. Multi-slice shmipc responses also avoid an unnecessary memory copy.

Validation

  • cargo +nightly fmt --all -- --check
  • cargo +nightly clippy -p volo-thrift --no-default-features --features shmipc,multiplex -- --deny warnings
  • cargo +nightly test -p volo-thrift --features shmipc,multiplex (44 passed)
  • cargo +nightly test -p volo --features shmipc (23 passed, 1 ignored)

@shenyj3
shenyj3 force-pushed the agent/shmipc-transport-fallback branch from 42ba042 to 5a275a0 Compare July 14, 2026 19:14
@shenyj3
shenyj3 marked this pull request as ready for review July 14, 2026 19:18
@shenyj3
shenyj3 requested review from a team July 14, 2026 19:18
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.96069% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.00%. Comparing base (58a9eeb) to head (1345054).

Files with missing lines Patch % Lines
volo-thrift/src/transport/dial.rs 87.97% 41 Missing ⚠️
volo-thrift/src/transport/pingpong/client.rs 0.00% 6 Missing ⚠️
volo-thrift/src/codec/default/mod.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
+ Coverage   54.11%   56.00%   +1.88%     
==========================================
  Files         165      166       +1     
  Lines       22072    22446     +374     
==========================================
+ Hits        11945    12570     +625     
+ Misses      10127     9876     -251     

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

Preserve buffered reads before surfacing stream errors, close cancelled shmipc RPC streams, and prevent failed streams from returning to the pool. Refresh the polling-to-eventfd dependency revision.
@shenyj3
shenyj3 force-pushed the agent/shmipc-transport-fallback branch from 41b76aa to f7b1e08 Compare August 19, 2026 03:49
@shenyj3 shenyj3 changed the title fix: make thrift transport fallback pool-aware feat(volo-thrift): improve shmipc fallback, reliability, and performance Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant