Skip to content

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

Description

@TysonAndre

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions