Repository navigation
performance: optimize per-service memory allocations - #1695
Conversation
Before we allocate * 1312 bytes for eviction mpsc. We replace this with a lighter mpsc. see hyperium/hyper#4057 for more context * 512 bytes for another part of the same mpsc; remoevd * 512 bytes for the tokio task; we now build it lazily New: 320 bytes per service (87% reduction) Signed-off-by: John Howard <john.howard@solo.io>
4df2b94 to
fcf32f7
Compare
There was a problem hiding this comment.
Pull request overview
This PR reduces per-service memory overhead in the load balancer by replacing the eviction event channel implementation and making the eviction worker task start lazily on first eviction, instead of eagerly at EndpointSet construction.
Changes:
- Replaced the eviction event channel from
tokio::sync::mpsctofutures::channel::mpscwith a smaller buffer. - Introduced
EvictionWorkerStateandEvictionStarterto lazily spawn the eviction worker only when needed. - Updated eviction scheduling to ensure the worker is started before sending eviction events, and simplified
maybe_sleep_untilby usingpending()when no timer is needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
stevenctl
left a comment
There was a problem hiding this comment.
lgtm, for my own knowledge when is it appropriate to use one mpsc impl or the other?
Before yesterday I thought: always use tokio. But tokio has a |
Before we allocate * 1312 bytes for eviction mpsc. We replace this with a lighter mpsc. see hyperium/hyper#4057 for more context * 512 bytes for another part of the same mpsc; remoevd * 512 bytes for the tokio task; we now build it lazily New: 320 bytes per service (87% reduction) 5k services before/after: <img width="1885" height="760" alt="2026-04-29_14-56-15" src="https://github.com/user-attachments/assets/4cf1c233-507c-4c76-9778-9f7fb9cf8248" /> Signed-off-by: John Howard <john.howard@solo.io> Signed-off-by: John Howard <john.howard@solo.io>
Before we allocate
Excessive per-connection memory cause by channel hyperium/hyper#4057 for more context
New: 320 bytes per service (87% reduction)
5k services before/after:

Signed-off-by: John Howard john.howard@solo.io