Reuse deleted MIME field slots - #13455
Open
bneradt wants to merge 1 commit into
Open
Conversation
Long-lived MIME headers allocate field blocks as fields are added and removed. HPACK exercises this path heavily, while the current attempt to bound the block chain scans and destroys empty blocks during deletion. This maintains a deleted-slot free list through m_next_dup and consumes it before allocating another field block. Appending within a partially filled tail preserves established field order. The free list is rebuilt for copied or unmarshaled headers, and same-name duplicate order is preserved. This adds high-water churn, insertion-order, duplicate, copy, and marshal coverage. Fixes: apache#8466
bneradt
force-pushed
the
mime-field-free-list
branch
from
July 30, 2026 03:08
9e90d46 to
adc90e4
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/proxy/hdrs/MIME.cc:1712
- Pushing a deleted slot onto the free list updates m_free_slot via mime_hdr_field_slotnum(), which linearly scans all field blocks to compute a slot number. Because this executes on every field delete, it may become a hot cost in the HPACK churn scenario this PR is targeting.
If possible, avoid computing slot numbers via mime_hdr_field_slotnum() in this fast path (e.g., encode the free list in a way that retains the next slot number directly).
mh->m_free_slot = mime_hdr_field_slotnum(mh, field);
ink_release_assert(mh->m_free_slot >= 0);
src/proxy/hdrs/MIME.cc:1408
- This new free-list pop path computes the next head by calling mime_hdr_field_slotnum(), which does a linear scan over the field-block chain (see the note above that the function “needs to be removed” because it’s poorly performant). Since this runs on every allocation from the deleted-slot free list, it may offset some of the intended performance gain under HPACK churn.
Consider tracking the next free slot number without needing a block-chain scan (e.g., store the next-slot number alongside the free-list linkage, or otherwise avoid slotnum->pointer->slotnum round trips).
This issue also appears on line 1711 of the same file.
mh->m_free_slot = field->m_next_dup ? mime_hdr_field_slotnum(mh, field->m_next_dup) : MIME_FIELD_FREE_SLOT_NONE;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Long-lived MIME headers allocate field blocks as fields are added and
removed. HPACK exercises this path heavily, while the current attempt to
bound the block chain scans and destroys empty blocks during deletion.
This maintains a deleted-slot free list through m_next_dup and consumes
it before allocating another field block. Appending within a partially
filled tail preserves established field order. The free list is rebuilt
for copied or unmarshaled headers, and same-name duplicate order is
preserved.
This adds high-water churn, insertion-order, duplicate, copy, and
marshal coverage.
Fixes: #8466