Fix for High Mempool Drops on UDP Connections #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We were seeing issues with UDP performance, especially with connection-level subscriptions. Mempool usage would spike and after a while lead to high drop rates.
Observing that every packet that passes the packet-level filtering step will be passed along to the connection table and either processed or inserted.
When an ongoing UDP connection is removed from the connection table (e.g., application-layer parsed and filter didn't match), there's nothing to keep subsequent packets from being re-inserted when the next packet is received.
This PR keeps UDP connections around in the connection table in a "dropped" state until the timerwheel ages them out. This seemed like the most straightforward approach - open to other ideas.
Tested: ran log_dns and log_quic (anonymized IPs) on offline and online mode, with both application-layer data and connections. Mempool usage stayed relatively stable and output still looks correct. In contrast, without this commit, mem usage steadily increases (and doesn't go down) over time when run for multiple minutes.
For example, logging DNS and QUIC connections had 12% drop rate after 80 seconds without this commit and 0.002% drop rate after 80 seconds with this commit.
Note - see some documentation of the issue here: #37 (comment)