Repository navigation
perf(workspace): optimize throughput across all crates and bump 23.4.0 - #70
Merged
Merged
Conversation
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.
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
Maximize end-to-end QPS and reduce per-request heap allocations across
every layer of the
hyperlanemonorepo (compress,type,core,macros,request, and all 40plugin/*crates) while keeping allpublic APIs, wire behavior, and opt-in plugin transparency 100%
unchanged, and bump the workspace release version from
23.3.2to23.4.0.Changes
compress/,type/):0..=16B), thread-localcompression scratch buffers, Brotli quality
4/ Deflate level4.DIGITS_200LUT, pointer-copy header assembly, zero-alloc upgradechecks, single-char splitters, shared
HEADER_ENTRY_POOL, raw-pointerASCII lowercasing, 8 KiB stack read fast path, and
#[doc(hidden)]Transport::{as_any_mut, supports_direct_response, poll_write_response}with backwards-compatible defaults.
core/):segment
RouteTrie(Static > Dynamic > Regex) with HashMap promotionand stack-allocated capture buffers.
InlineRequestFutureslot and add#[doc(hidden)]ServerHook::try_handle_syncfor zero-future synchronous hooks.Arc<Mutex<...>>locks from HTTP/2 and HTTP/3 directtransports via
Transport::as_any_mut(), recycle incoming HTTP/2HeaderMaps, emit structured responses directly over H2/H3 withoutHTTP/1.1 wire serialization round-trips, tune Quinn QUIC transport
config, and add zero-pool stack read/write fast paths in
TlsTransport.macros/):#[send]generated future states, eliminate#[upgrade]allocations, narrow
tail_is_trivial, parseItemFnonce, lowercompile-time header keys and
"External(...)"attribute keys at macroexpansion time, coalesce response headers via
set_headers_batch, anddeduplicate cookie lookups.
request/):IpAddrdirectly before DNS lookup (sync & async),cache-line pad pool stripes (
#[repr(align(64))]) with guardednon_empty_mask, add thread-local L1 H2 sender cache (H2_POOL_GEN),skip no-op TCP flush, add 4 KiB stack
MaybeUninitasync read fastpath, and fuse single-pass header parsing with SWAR ASCII validation.
plugin/*— all 40 plugins):ServerHook::try_handle_syncfast paths acrossall opt-in request/response hooks (preserving async fallback safety and
unconfigured zero-overhead transparency).
metricsacross 16 cache-line-padded shards using integernanosecond sums (eliminating float CAS loops); prebuild active
tenantcontext arrays; reuseContextattributeArcslots inplace (
metrics,audit,canary,auth); batch headers intracing,rate_limit,canary,sse; lazy-mint anonymoussessionIDs; cache-line padcircuit_breakerbuckets; use bitmaskjumping in
scheduler(CronMask::next_unix_secs_after); zero-allocenvlookups; and 8-byte word hashing inmq.Cargo.toml):[workspace.package].versionand internal[workspace.dependencies]pins from23.3.2to23.4.0.Verification
Real Benchmark Results (Apple Silicon macOS, Release Build, 0 Errors)
Official
hyperlane-performanceNative Suite23.3.2)23.4.0)h1_keepalive_c64h1_keepalive_c256h1-tls_keepalive_c64h2c_keepalive_c64h2-tls_keepalive_c64h3_keepalive_c64h3_1core_c32(alloc-count)h2c_1core_c32(alloc-count)Full-Stack 35-Scenario Benchmark (Core, Compression, Macros, Plugins, Client)
23.3.2)23.4.0)core_h1_pipelined16core_h1_dynamic32_pipecore_h1_regex16_pipecore_h1_headers_query_pipecore_h1_post_4kbcore_h1_compress_gzipcore_h1_compress_deflatecore_h1_compress_brotlicore_h2c_mux64macros_fullstack_pipeplugins_unconfigured_pipeplugins_configured_fullstack_pipeplugin_tracing_pipeplugin_metrics_pipeplugin_rate_limit_pipeplugin_cors_pipeplugin_security_pipeplugin_auth_jwt_pipeplugin_cache_hit_pipeplugin_etag_pipeplugin_circuit_breaker_pipeplugin_concurrency_pipeplugin_ip_filter_pipeplugin_session_pipeplugin_rewrite_pipeplugin_audit_pipeclient_async_h1_kaclient_async_h1_customclient_async_h1_postclient_sync_h1_kaclient_async_h2cclient_async_shortQuality Gates
crate sync: already in sync atv23.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
opt-in plugin contract; new internal extension methods on
TransportandServerHookcarry#[doc(hidden)]default implementations.