Skip to content

Reworking Headers impl#5396

Merged
jasnell merged 2 commits intomainfrom
jasnell/http-headers-take-2
Dec 1, 2025
Merged

Reworking Headers impl#5396
jasnell merged 2 commits intomainfrom
jasnell/http-headers-take-2

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Oct 23, 2025

Needs careful review. It does improve performance but the impl is a bit more complex. Fiddled around with a number of other perf tweaks but nothing that really moved the needle enough to justify the increased complexity. Not entirely sold on this impl so be brutal in reviews.

@jasnell jasnell requested review from a team as code owners October 23, 2025 01:33
@jasnell jasnell marked this pull request as draft October 23, 2025 01:53
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 7f431f6 to b94d316 Compare October 23, 2025 02:30
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 23, 2025

CodSpeed Performance Report

Merging #5396 will improve performances by 44.01%

Comparing jasnell/http-headers-take-2 (00269d5) with main (1711af3)

Summary

⚡ 2 improvements
✅ 55 untouched
⏩ 30 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
constructor[ApiHeaders] 97.3 ms 67.6 ms +44.01%
set_append[ApiHeaders] 16.9 ms 11.9 ms +41.6%

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 4 times, most recently from 8191e31 to 7f84859 Compare October 23, 2025 15:09
@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Oct 23, 2025

Internal tests are failing because the refactor changes the ordering of the headers in places... will need to see if we can preserve the order but first want to see if this has a positive impact on performance overall... waiting for benchmark results to be updated.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 21b09a3 to b59e107 Compare October 23, 2025 16:13
@jasnell jasnell marked this pull request as ready for review October 23, 2025 16:41
@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Oct 23, 2025

Marking as ready for review but there are still some internal test updates I'll need to do on the internal repo.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 7ac27f1 to 7c52fb0 Compare October 23, 2025 17:02
@danlapid
Copy link
Copy Markdown
Collaborator

Whenever this is done I want as many reviewers as we can get on this, incl Harris, Kenton, Mike, Yagiz, etc.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 0a4c8f0 to 7c52fb0 Compare October 23, 2025 19:53
@jasnell jasnell requested a review from mikea October 23, 2025 23:15
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 2e794b4 to fb81688 Compare October 24, 2025 23:40
@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Oct 24, 2025

Note for reviewers: while it likely is possible to get more performance gain with additional tweaks on this, the emphasis for review should be on correctness and ensuring that the revised implementation does not introduce new bugs, etc. We can tweak additional performance knobs separately in follow up PRs.

Copy link
Copy Markdown
Member

@kentonv kentonv left a comment

Choose a reason for hiding this comment

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

Only skimmed briefly but I think there's an opportunity for big gains here by taking advantage of the tables that are already available in HttpOverCapnpFactory.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 38a2fab to 37b85f0 Compare October 28, 2025 00:47
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 4 times, most recently from a9e29f2 to b682105 Compare November 7, 2025 17:55
@guybedford
Copy link
Copy Markdown
Contributor

guybedford commented Nov 7, 2025

The only implementation I saw in the diff for checkGuard is:

void checkGuard() {
    JSG_REQUIRE(guard == Guard::NONE, TypeError, "Can't modify immutable headers.");
  }

which doesn't include forbidden headers, but please let me know if I'm missing anything. My question was specifically about forbidden headers and I completely understand if they are omitted, was just trying to point out gaps.

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Nov 7, 2025

ah, right, yeah we don't (and have never) implemented the forbidden headers bit.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from b682105 to d55e9e5 Compare November 7, 2025 20:16
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 76e21b5 to e1d82a8 Compare November 10, 2025 17:41
@kentonv
Copy link
Copy Markdown
Member

kentonv commented Nov 14, 2025

The force-push https://github.com/cloudflare/workerd/compare/d55e9e51ffe9a606bc70ddd2353c82fd8979f08c..76e21b53212977137242f65a82b664444181a611 seems to contain a combination of changes specific to this PR, and also a rebase on master, which breaks incremental reviews.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from e1d82a8 to 4b01259 Compare November 14, 2025 23:37
@github-actions

This comment was marked as outdated.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 150d95f to 8ae24b9 Compare November 26, 2025 21:00
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 8ae24b9 to 92ca822 Compare December 1, 2025 20:40
In preparation to re-apply Headers performance improvements
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 92ca822 to 00269d5 Compare December 1, 2025 21:47
@jasnell jasnell merged commit e776bb1 into main Dec 1, 2025
65 of 70 checks passed
@jasnell jasnell deleted the jasnell/http-headers-take-2 branch December 1, 2025 23:29
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.

8 participants