Skip to content

Conversation

@ss-es
Copy link
Contributor

@ss-es ss-es commented Dec 2, 2025

This PR lowers the channel sizes for both the internal and external event streams.

Since these channels are implemented internally as a VecDeque, we are allocating a large RawVec equal to the channel capacity on initialization. For the internal event stream this is mostly inconsequential, since the vector holds Arc references (so even an array with 100,000 entries only takes up a few megabytes).

On the other hand, for the external event stream, which holds structs like QuorumProposal, this results in a ~200+ MB virtual allocation at startup. This memory is not immediately physically allocated to the program (because it will likely exceed MMAP_THRESHOLD for the allocator), but instead becomes available as we append to the vector. Broadcasts to the channel will always append to the array in memory (because VecDeque is a circular buffer), increasing the physical memory usage. Even when we drop entries at the head of the VecDeque, we do not free any of the initial segments of memory (of course, doing this in a circular buffer would be counterproductive), so this manifests as a memory leak up until we reach the end of the underlying array at ~200 MB (or more).

@ss-es ss-es enabled auto-merge (squash) December 2, 2025 20:21
@ss-es ss-es disabled auto-merge December 3, 2025 21:57
@ss-es ss-es merged commit 7c10665 into main Dec 3, 2025
114 of 116 checks passed
@ss-es ss-es deleted the ss/update-event-stream-size branch December 3, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants