Skip to content

perf(workspace): optimize throughput across all crates and bump 23.4.0 - #70

Merged
vshengbro merged 1 commit into
masterfrom
perf/extreme-qps-optimization
Dec 4, 2026
Merged

vshengbro merged 1 commit into
masterfrom
perf/extreme-qps-optimization

Conversation

@vshengbro

Copy link
Copy Markdown
Member

Summary

Maximize end-to-end QPS and reduce per-request heap allocations across
every layer of the hyperlane monorepo (compress, type, core,
macros, request, and all 40 plugin/* crates) while keeping all
public APIs, wire behavior, and opt-in plugin transparency 100%
unchanged, and bump the workspace release version from 23.3.2 to
23.4.0.

Changes

  • Compression & Wire (compress/, type/):
    • Inline bit-exact XXH3-64 short-key hashing (0..=16 B), thread-local
      compression scratch buffers, Brotli quality 4 / Deflate level 4.
    • Add DIGITS_200 LUT, pointer-copy header assembly, zero-alloc upgrade
      checks, single-char splitters, shared HEADER_ENTRY_POOL, raw-pointer
      ASCII lowercasing, 8 KiB stack read fast path, and #[doc(hidden)]
      Transport::{as_any_mut, supports_direct_response, poll_write_response}
      with backwards-compatible defaults.
  • Server Core (core/):
    • Replace linear dynamic/regex route scanning with an arena-backed
      segment RouteTrie (Static > Dynamic > Regex) with HashMap promotion
      and stack-allocated capture buffers.
    • Unify request/route/response inline execution into a single 768 B
      InlineRequestFuture slot and add #[doc(hidden)]
      ServerHook::try_handle_sync for zero-future synchronous hooks.
    • Remove Arc<Mutex<...>> locks from HTTP/2 and HTTP/3 direct
      transports via Transport::as_any_mut(), recycle incoming HTTP/2
      HeaderMaps, emit structured responses directly over H2/H3 without
      HTTP/1.1 wire serialization round-trips, tune Quinn QUIC transport
      config, and add zero-pool stack read/write fast paths in TlsTransport.
  • Proc Macros (macros/):
    • Halve #[send] generated future states, eliminate #[upgrade]
      allocations, narrow tail_is_trivial, parse ItemFn once, lower
      compile-time header keys and "External(...)" attribute keys at macro
      expansion time, coalesce response headers via set_headers_batch, and
      deduplicate cookie lookups.
  • HTTP Client (request/):
    • Parse literal IpAddr directly before DNS lookup (sync & async),
      cache-line pad pool stripes (#[repr(align(64))]) with guarded
      non_empty_mask, add thread-local L1 H2 sender cache (H2_POOL_GEN),
      skip no-op TCP flush, add 4 KiB stack MaybeUninit async read fast
      path, and fuse single-pass header parsing with SWAR ASCII validation.
  • Plugin Suite (plugin/* — all 40 plugins):
    • Implement zero-future ServerHook::try_handle_sync fast paths across
      all opt-in request/response hooks (preserving async fallback safety and
      unconfigured zero-overhead transparency).
    • Shard metrics across 16 cache-line-padded shards using integer
      nanosecond sums (eliminating float CAS loops); prebuild active
      tenant context arrays; reuse Context attribute Arc slots in
      place (metrics, audit, canary, auth); batch headers in
      tracing, rate_limit, canary, sse; lazy-mint anonymous
      session IDs; cache-line pad circuit_breaker buckets; use bitmask
      jumping in scheduler (CronMask::next_unix_secs_after); zero-alloc
      env lookups; and 8-byte word hashing in mq.
  • Release (Cargo.toml):
    • Bump [workspace.package].version and internal
      [workspace.dependencies] pins from 23.3.2 to 23.4.0.

Verification

Real Benchmark Results (Apple Silicon macOS, Release Build, 0 Errors)

Official hyperlane-performance Native Suite

Scenario Baseline (23.3.2) After (23.4.0) Delta
h1_keepalive_c64 174,474.8 RPS 175,274.0 RPS +0.5%
h1_keepalive_c256 171,289.2 RPS 175,859.2 RPS +2.7%
h1-tls_keepalive_c64 172,256.5 RPS 172,835.0 RPS +0.3%
h2c_keepalive_c64 157,940.2 RPS 161,635.8 RPS +2.3%
h2-tls_keepalive_c64 151,307.5 RPS 158,845.2 RPS +5.0%
h3_keepalive_c64 15,214.8 RPS 77,708.2 RPS +410.7% (5.1x)
h3_1core_c32 (alloc-count) 6,719.0 RPS (11.0 allocs / 1,434.2 B) 78,049.5 RPS (9.0 allocs / 865.3 B) +1,061.6% (11.6x, -39.7% B)
h2c_1core_c32 (alloc-count) 6.7 allocs / 1,006.9 B 4.7 allocs / 790.9 B -29.9% allocs / -21.5% B

Full-Stack 35-Scenario Benchmark (Core, Compression, Macros, Plugins, Client)

Scenario Baseline (23.3.2) After (23.4.0) Delta
core_h1_pipelined16 2,356,486.9 RPS 2,411,209.0 RPS +2.3%
core_h1_dynamic32_pipe 1,033,027.9 RPS 2,008,100.3 RPS +94.4%
core_h1_regex16_pipe 1,799,737.5 RPS 2,001,606.8 RPS +11.2%
core_h1_headers_query_pipe 593,791.1 RPS 795,354.5 RPS +33.9%
core_h1_post_4kb 255,930.8 RPS 274,890.7 RPS +7.4%
core_h1_compress_gzip 118,620.7 RPS 137,374.6 RPS +15.8%
core_h1_compress_deflate 123,348.5 RPS 137,332.1 RPS +11.3%
core_h1_compress_brotli 58,518.5 RPS 107,501.0 RPS +83.7%
core_h2c_mux64 259,100.1 RPS 271,149.0 RPS +4.7%
macros_fullstack_pipe 1,255,355.0 RPS 1,481,015.4 RPS +18.0%
plugins_unconfigured_pipe 1,617,597.0 RPS 2,130,238.2 RPS +31.7%
plugins_configured_fullstack_pipe 295,613.3 RPS 373,741.4 RPS +26.4%
plugin_tracing_pipe 971,391.4 RPS 1,208,107.4 RPS +24.4%
plugin_metrics_pipe 1,371,206.1 RPS 1,611,345.7 RPS +17.5%
plugin_rate_limit_pipe 1,288,383.1 RPS 1,520,732.2 RPS +18.0%
plugin_cors_pipe 1,369,095.5 RPS 1,590,787.0 RPS +16.2%
plugin_security_pipe 927,279.0 RPS 1,010,650.2 RPS +9.0%
plugin_auth_jwt_pipe 828,868.5 RPS 932,451.2 RPS +12.5%
plugin_cache_hit_pipe 1,631,660.6 RPS 1,851,075.1 RPS +13.4%
plugin_etag_pipe 1,401,747.6 RPS 1,877,082.6 RPS +33.9%
plugin_circuit_breaker_pipe 1,566,357.1 RPS 2,146,752.0 RPS +37.1%
plugin_concurrency_pipe 1,401,558.5 RPS 1,809,276.9 RPS +29.1%
plugin_ip_filter_pipe 1,406,716.1 RPS 1,847,551.9 RPS +31.3%
plugin_session_pipe 1,339,738.1 RPS 1,883,500.0 RPS +40.6%
plugin_rewrite_pipe 1,511,787.3 RPS 2,114,117.6 RPS +39.8%
plugin_audit_pipe 1,545,541.8 RPS 2,129,131.0 RPS +37.8%
client_async_h1_ka 17,629.7 RPS 28,951.8 RPS +64.2%
client_async_h1_custom 154,076.2 RPS 179,489.1 RPS +16.5%
client_async_h1_post 16,786.6 RPS 28,264.8 RPS +68.4%
client_sync_h1_ka 13,966.0 RPS 21,899.9 RPS +56.8%
client_async_h2c 109,996.0 RPS 115,420.8 RPS +4.9%
client_async_short 16,526.1 RPS 28,786.7 RPS +74.2%

Quality Gates

  • crate sync: already in sync at v23.4.0.
  • cargo run -p hyperlane-cli -- fmt (x2) + --check, crate fmt --check, cargo fmt --all -- --check: passed with 0 diffs.
  • audit_rust_standards.py: 56/56 PASS.
  • rust_pre_commit.py: exit 0 (all 5 phases passed).
  • cargo clippy --workspace --all-features --all-targets -- -D warnings: 0 warnings.
  • cargo check --release --workspace --all-features: passed.
  • cargo test --workspace --all-features: all workspace tests passed.

Notes

  • Zero breaking changes to any public type, trait, macro, wire behavior, or
    opt-in plugin contract; new internal extension methods on Transport and
    ServerHook carry #[doc(hidden)] default implementations.
  • No new third-party dependencies were added.

Maximize end-to-end throughput and cut per-request allocations across
all 49 crates in the Hyperlane workspace without breaking any public
API, wire contract, or opt-in plugin behavior, and bump workspace
version to 23.4.0.

Key optimizations:
- compress & type: tune compression fast paths and thread-local
  scratch buffers, inline XXH3-64 short-key hashing (0..=16 B), add
  DIGITS_200 LUT, zero-alloc upgrade checks, single-char splitters,
  shared HEADER_ENTRY_POOL, raw-pointer ASCII lowercasing, 8 KiB stack
  read fast path, and direct Transport response hooks.
- core: add arena-backed segment RouteTrie (Static > Dynamic > Regex)
  with HashMap promotion, unify inline request execution into a single
  768 B slot, remove Arc<Mutex> on H2/H3 direct transports via
  as_any_mut, recycle H2 HeaderMaps, stream H2/H3 responses directly,
  tune Quinn QUIC transport config, and add stack read/write fast paths
  in TlsTransport.
- macros: halve #[send] future states, remove upgrade allocations,
  narrow trivial-tail checks, pre-lowercase compile-time header keys
  and External(...) attribute keys, coalesce response headers via
  set_headers_batch, and deduplicate cookie lookups.
- request: parse literal IpAddr before DNS resolution, cache-line pad
  pool stripes, add thread-local L1 H2 sender cache, skip no-op TCP
  flushes, add 4 KiB stack async read fast path, and fuse header
  parsing with SWAR ASCII validation.
- plugins: add ServerHook::try_handle_sync fast path across all 40
  opt-in plugins, shard metrics across 16 cache-line-padded shards
  with integer nanosecond sums, prebuild tenant contexts, reuse
  Context attribute Arc buffers in place, accelerate scheduler cron
  bitmask jumps, and eliminate per-request allocations on hot paths.
@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Dec 4, 2026
@vshengbro
vshengbro merged commit 8899692 into master Dec 4, 2026
9 checks passed
@vshengbro
vshengbro deleted the perf/extreme-qps-optimization branch December 4, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant