Skip to content

Conversation

@jasnell
Copy link
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

codspeed-hq bot commented Oct 23, 2025

CodSpeed Performance Report

Merging #5396 will improve performances by 42.29%

Comparing jasnell/http-headers-take-2 (1e23169) with main (7fa38f9)

Summary

⚡ 2 improvements
✅ 32 untouched
⏩ 9 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
constructor[ApiHeaders] 90.9 ms 63.9 ms +42.29%
set_append[ApiHeaders] 15.9 ms 11.3 ms +40.96%

Footnotes

  1. 9 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
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
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
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
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
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 from 37b85f0 to cd7bdc8 Compare October 28, 2025 18:26
@jasnell
Copy link
Collaborator Author

jasnell commented Oct 28, 2025

Further improved the revised implementation and added an additional benchmark.

  • The additional benchmark shows a ~31% performance improvement in a set/append case.
  • The common headers are now indexed and hashed at compile time to shave off additional work
  • jsg::ByteString is removed since it was largely a useless shell anyway. It's warning functionality was wasted on header names since we strictly validate those anyway, and has been replaced to only warn on header values. Given that use of jsg::ByteString was incurring an additional redundant scan on all header names and values this yielded a fairly good performance improvement.
  • Additional improvements are likely possible but this is already quite significant as it is.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from cd7bdc8 to 95b9cbc Compare October 28, 2025 20:36
@danlapid
Copy link
Collaborator

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

Bumping this
@harrishancock @kentonv @mikea @anonrig we need as many eyes as we can get on this, we can't get this change wrong again, important to optimise headers but we need to make sure we are right with our change

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 218beea to 3e413f7 Compare November 3, 2025 16:27
@jasnell
Copy link
Collaborator Author

jasnell commented Nov 3, 2025

@fhanau ... any advice on the linting issues here?

@fhanau

This comment was marked as resolved.

@fhanau

This comment was marked as resolved.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 3e413f7 to 5be0630 Compare November 3, 2025 20:02
Copy link
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.

I wish this PR had been organized into a series of individual optimizations that could be considered separately. It looks like a whole lot of stuff was mixed into one PR, and it's unclear to me which optimizations are actually wins. I see some that I'd actually expect to be losses, or to have no effect (but aren't worth the code complexity).

The PR is separated into several commits, but aside from the first commit, they are not separated in a helpful way, with several commits totally changing what was introduced in previous commits.

Can you please squash all the commits EXCEPT FOR the first one, so I can at least see a clean diff from old Headers to new Headers?

Random comments below are from skimming around but I haven't been able to review deeply.

@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from 5be0630 to c8c2182 Compare November 3, 2025 23:36
@jasnell

This comment was marked as resolved.

In preparation to re-apply Headers performance improvements
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch 2 times, most recently from 77b6d78 to e770ff6 Compare November 4, 2025 13:28
@jasnell jasnell requested a review from anonrig November 4, 2025 14:44
@jasnell jasnell force-pushed the jasnell/http-headers-take-2 branch from b2cdb63 to 1e23169 Compare November 4, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants