Skip to content

perf: shard pool, lazy snapshots, DNS cache, thinner bodies#75

Merged
fannnzhang merged 2 commits into
mainfrom
perf/rust-hotpath-optimizations
Jul 11, 2026
Merged

perf: shard pool, lazy snapshots, DNS cache, thinner bodies#75
fannnzhang merged 2 commits into
mainfrom
perf/rust-hotpath-optimizations

Conversation

@fannnzhang

@fannnzhang fannnzhang commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Performance work on top of merged #74 (main now 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

  • 32-way address-hash pool sharding + shared H2 coalescing index
  • Shared Arc<Address> across dual-stack route candidates
  • ResponseBody::text() reclaims unique Bytes buffers

This update

  • Lazy RequestSnapshot: only clone headers/extensions when redirects, retries, or authenticators can rebuild the request; single-shot paths stay light
  • CachingDnsResolver: default client DNS path caches positive (30s) / negative (5s) results over SystemDnsResolver
  • Thinner body stack: request-admission permits ride response extensions into CallLifecycleBody, dropping one BoxBody layer
  • Pool merge keeps fix: harden connection lifecycle, connect budgets, and follow-up paths #74 eviction hooks (set_eviction_hook / remove_without_hook / unhealthy-in-use keep) with the sharded layout

Test 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 warnings
  • cargo fmt --all
  • Rebased onto main after fix: harden connection lifecycle, connect budgets, and follow-up paths #74 merge; force-pushed with lease

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
fannnzhang force-pushed the perf/rust-hotpath-optimizations branch from e325fc7 to db62506 Compare July 11, 2026 09:15
@fannnzhang fannnzhang changed the title perf: shard the connection pool and cut hot-path allocations perf: shard pool, lazy snapshots, DNS cache, thinner bodies Jul 11, 2026
@fannnzhang
fannnzhang merged commit 763bc73 into main Jul 11, 2026
7 checks passed
@fannnzhang
fannnzhang deleted the perf/rust-hotpath-optimizations branch July 11, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant