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.
Description
This Pull Request adds range compaction and shrinking functionality to optimize memory usage in the QUIC range management system. The key changes include:
New Functions:
QuicRangeCompact: Merges overlapping or adjacent subranges to reduce fragmentation and improve search performance.QuicRangeShrink: Dynamically reduces the allocation size of the subranges array when usage is significantly below allocated capacity.QuicRangeCalculateShrinkLength: Helper function to determine optimal shrink thresholds based on configurable parameters.Integration: Modified existing range operations (
QuicRangeAddRange,QuicRangeRemoveRange,QuicRangeSetMin,QuicRangeRemoveSubranges) to automatically compact ranges after modifications that could create adjacent subranges.These optimizations are particularly beneficial for long-running, highly fragmented QUIC connections where range operations accumulate over time, helping to maintain efficient memory usage and performance.
Remediates the problem in #5450, but still does not prevent worst case mentioned.
Testing
Existing unit tests for range operations (in
src/test/) should continue to pass and provide coverage for basic functionality. Additional tests are recommended for:Documentation
No user-facing documentation impact, as these are internal implementation optimizations. If any public APIs are indirectly affected, ensure API documentation remains accurate.