[draft] threads: remove global packet pools #14236
Draft
+254
−141
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.
Non-urgent, just been sitting on this, and a QA run would be nice.
Replace global thread-local packet pools with packet pools owned by thread vars.
The idea is to remove global data such that a library user can have multiple instances of the Suricata engine that don't share any data. As library users can provide their own threads, and may utilize different threading infrastructure such as thread pools, we should do our best not to leak resources from one instance into another.
The downside is that we might lose some optimizations that thread-local storage can provide, such as a faster path to returning a packet to another thread's pool.
This is part of the overall idea that multiple instances of the Suricata engine should be able to co-exist in one process space without cross-contamination. This generally means getting rid of all global state. The packet pool was relatively easy to attack, with the drawback of losing an optimization. It's also a performance-critical module as well, so it's a good one to look at.
Other thoughts:
TODO: