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

Twemproxy does not release memory for mbufs: Free list garbage collection approach #665

Open
TysonAndre opened this issue Feb 25, 2022 · 1 comment

Comments

@TysonAndre
Copy link
Collaborator

Currently, memory is added to a free list manually with malloc but never freed.

During spikes in traffic or latency or large requests, entries get added, growing twemproxy's memory usage.

If there are too many free list entries, some should be removed from the singly linked list.

  • Maybe do this in the main loop, select() with 0 timeout before the select() with sleep (if sufficient time passed since last cleanup) and do cleanup if there are no events to process.
  • Maintain some minimum free list size so that low traffic use cases don't call free/malloc too often during bursts of traffic. Make it configurable to raise?
  • Keep track of how many were in use the last N times, sampling, and allow something like max() * 3 + C for some C value
  • Limit maximum freed in a single call to avoid impacting p99 latency too much

Related to #664 and #553

@kukey
Copy link
Contributor

kukey commented Apr 27, 2022

Not only mbufs, also has msg and conncection.

I think use background thread solve this is better.

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

No branches or pull requests

2 participants