perf: shard pool, lazy snapshots, DNS cache, thinner bodies#75
Merged
Conversation
Reduce lock contention and cloning on the request hot path: - Shard the connection pool by address hash (32 shards) with a shared coalescing index so multi-host acquire/release no longer serializes on one global mutex. - Share a single Arc<Address> across dual-stack / multi-endpoint route plans. - Store follow-up RequestSnapshot headers and extensions behind Arc so auth and retry rebuilds avoid repeated full-map clones when only metadata is used. - Reclaim ResponseBody::text() buffers via Bytes::into() when uniquely owned.
Build on the rebased pool sharding work: - Capture follow-up RequestSnapshot headers/extensions only when redirects, retries, or authenticators can rebuild the request (light mode for single-shot). - Default clients use CachingDnsResolver (30s positive / 5s negative TTL) over the system resolver to cut repeated lookups under connection churn. - Hold request-admission permits via response extensions into CallLifecycleBody, removing an extra BoxBody wrapper on returned responses. Also merges pool sharding with the #74 eviction-hook teardown path.
fannnzhang
force-pushed
the
perf/rust-hotpath-optimizations
branch
from
July 11, 2026 09:15
e325fc7 to
db62506
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Performance work on top of merged #74 (
mainnow includes connection teardown / connect budgets). This branch was rebased onto that tip so pool sharding and eviction hooks live in one coherent pool implementation.Already in the rebased commit
Arc<Address>across dual-stack route candidatesResponseBody::text()reclaims uniqueBytesbuffersThis update
RequestSnapshot: only clone headers/extensions when redirects, retries, or authenticators can rebuild the request; single-shot paths stay lightCachingDnsResolver: default client DNS path caches positive (30s) / negative (5s) results overSystemDnsResolverCallLifecycleBody, dropping oneBoxBodylayerset_eviction_hook/remove_without_hook/ unhealthy-in-use keep) with the sharded layoutTest plan
cargo test -p openwire --lib --all-features(225 passed)cargo test -p openwire --test integration --all-features(121 passed)cargo test -p openwire-tokio --lib(including DNS cache unit test)cargo clippy --workspace --all-targets --all-features --keep-going -- -D warningscargo fmt --allmainafter fix: harden connection lifecycle, connect budgets, and follow-up paths #74 merge; force-pushed with lease