Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory usage when extending event buffers is attributed to components #185

Closed
Tracked by #184
tobz opened this issue Aug 13, 2024 · 1 comment · Fixed by #261
Closed
Tracked by #184

Memory usage when extending event buffers is attributed to components #185

tobz opened this issue Aug 13, 2024 · 1 comment · Fixed by #261
Labels
area/memory Memory bounds and memory management. effort/intermediate Involves changes that can be worked on by non-experts but might require guidance. type/chore Updates to dependencies or general "administrative" tasks necessary to maintain the codebase/repo.

Comments

@tobz
Copy link
Member

tobz commented Aug 13, 2024

Context

Currently, the global event buffer pool is shared across components in order to move events through a topology. At startup, we allocate a fixed number of these buffers, but crucially, their capacity is empty. As the buffers are used, they are extended as needed.

This causes two main issues:

  • event buffers are a potential avenue of unbounded memory growth
  • the component that happens to end up causing the buffers to be resized gets stuck with the attributed memory usage

While the growth of these buffers generally won't actually be unbounded -- a lot of other bounds will come into play first -- their misattributed memory usage is problematic, because it can completely blow the budget of a component that otherwise doesn't allocate at all at runtime.

@tobz tobz added area/memory Memory bounds and memory management. type/chore Updates to dependencies or general "administrative" tasks necessary to maintain the codebase/repo. effort/intermediate Involves changes that can be worked on by non-experts but might require guidance. labels Aug 13, 2024
@tobz
Copy link
Member Author

tobz commented Aug 13, 2024

In terms of solutions, this would need to be two-fold:

  • event buffers would need to be of fixed-size
  • we would need a new object pool that was elastic and could drop unused items after some period of being idle/unused

This would give us the ability to have truly bounded usage -- max pool size * fixed event buffer size -- and to do so in a way that we could apply to the bounds of the topology itself, avoiding components getting hit with the memory usage attribution.

Fixed-size event buffers

This one is the most difficult because while writing such a buffer itself is trivial, using them is less so. Having to add in the code to handle the buffer being full, and then sending it and acquiring a new buffer, would be non-trivial and ugly. At present time, it would be very ugly/contrived with something like the DogStatsD source, based on how we thread through a pre-acquired EventBuffer to Deserializer. Some of the work @lukesteensen is doing might make that a non-issue if we lift up the code where we actually generate, and thus buffer, the events we decoded.

For the rest of the cases, we would potentially write helper adapters to encapsulate the logic of iterating over something that generates the events, and then manages the event buffer being written into, sending it out and acquiring a new one when full.

Elastic object pool

This would be pretty trivial, and would just involve needing to write the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/memory Memory bounds and memory management. effort/intermediate Involves changes that can be worked on by non-experts but might require guidance. type/chore Updates to dependencies or general "administrative" tasks necessary to maintain the codebase/repo.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant