Skip to content

fix(connlib): always return buffers to pool after sending#7891

Merged
thomaseizinger merged 1 commit intomainfrom
chore/no-grow-memory-datagrams
Jan 28, 2025
Merged

fix(connlib): always return buffers to pool after sending#7891
thomaseizinger merged 1 commit intomainfrom
chore/no-grow-memory-datagrams

Conversation

@thomaseizinger
Copy link
Member

Within the GsoQueue data structure, we keep a hash map indexed by source, destination and segment length of UDP packets pointing to a buffer for those payloads. What we intended to do here is to return the buffer to the pool after we sent the payload. What we failed to realise is that putting another buffer into the hash map means we have a buffer allocated for a certain destination address and segment length! This buffer would only get reused for the exact same address and segment length, causing memory usage to balloon over time.

To fix this, we wrap the DatagramBuffer in an additional Option. This allows us to actually remove it from the hash map and return the buffer for future use to the buffer pool.

Resolves: #7866.
Resolves: #7747.

@vercel
Copy link

vercel bot commented Jan 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:16am

Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice find.

@thomaseizinger thomaseizinger added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit 6789b0b Jan 28, 2025
111 checks passed
@thomaseizinger thomaseizinger deleted the chore/no-grow-memory-datagrams branch January 28, 2025 02:12
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.

Ensure buffer pool is bounded Reduce memory usage on iOS

2 participants