You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(mux): the Mux::timeouts and Context::backend_streams tables still allocate per session #1613
#1612 cut the allocations of a mux session's setup and left two sites it named as a follow-up: the hashbrown tables of Mux::timeouts and Context::backend_streams. Both are created per session and allocate a control/bucket array on their first insert, so a plain H1 request (one request per connection) still pays heap allocations for two tables that, in the common case, hold one frontend handle, one backend handle and one backend entry listing a single stream.
Mux::timeouts: HashMap<Token, TimeoutContainer> is built with HashMap::from([(frontend_token, container)]) in lib/src/http.rs (session creation and the PROXY-protocol upgrade) and lib/src/https.rs (TLS handshake upgrade). Its keys are the frontend token, always present for the session's lifetime, plus one token per live backend connection.
Context::backend_streams: HashMap<Token, Vec<GlobalStreamId>> is the backend-token → linked-streams reverse index. A session almost always holds one backend connection, and an H1 backend carries one stream at a time.
Proposal
Mux::timeouts: keep the frontend handle in a named field (its key is fixed for the session) and the backend handles in an inline-first container with an overflow map, the same shape as BackendConnections in perf(mux): cut the allocations of a session's setup #1612.
Context::backend_streams: an inline slot for the first backend token with a fallback to the table for multi-backend sessions.
Same semantics, including any observable iteration order; no new dependency; no refactor beyond these two sites.
Measure per site with crate::test_allocations and end to end (H1, H2, H2 multiplexed) with an LD_PRELOAD malloc counter, before and after.
Activity
perf(mux): keep a session's wheel handles and backend reverse index i…