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(router): route_from_request still allocates for original_authority and the trie path #1589
#1584 measured three heap allocations left per routed request inside Router::route_from_request (lib/src/protocol/mux/router.rs). Two of them need no public API change:
route_from_request copies the request authority (host.to_owned()) into HttpContext::original_authority on every request. The only reader is the X-Forwarded-Host injection of apply_request_rewrites_and_headers, which fires only when the frontend rewrites the host. HttpContext::authority is never mutated by routing, so the pre-rewrite value is still there when that header is built; the field's own documentation already says it is None when no host rewrite happened.
Router::lookup (lib/src/router/mod.rs) hands the trie a Vec::with_capacity(16) to record the wildcard/regex segments it matched, so every tree lookup allocates, including a literal host that records nothing.
Proposal
Populate original_authority only when a host rewrite applies, from HttpContext::authority, so a request without a host rewrite copies nothing.
Record the trie segments into a fixed 16-slot stack buffer that spills to a Vec only past 16 non-literal segments; TrieMatches and TrieNode::lookup_with_path stay as they are.
Pin both with the crate's counting test allocator.
Out of scope: the cluster id cloned out of the route table (ClusterId = String in sozu-command-lib) and SessionManager::track_cluster_connection.
Activity
perf(router): copy no authority and allocate no trie path per request (…