Skip to content

Reuse deleted MIME field slots - #13455

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:mime-field-free-list
Open

Reuse deleted MIME field slots#13455
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:mime-field-free-list

Conversation

@bneradt

@bneradt bneradt commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

@bneradt bneradt added this to the 11.0.0 milestone Jul 30, 2026
Copilot AI review requested due to automatic review settings July 30, 2026 01:29
@bneradt bneradt self-assigned this Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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
Copilot AI review requested due to automatic review settings July 30, 2026 03:08
@bneradt
bneradt force-pushed the mime-field-free-list branch from 9e90d46 to adc90e4 Compare July 30, 2026 03:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MIME Field Free List

2 participants