Skip to content

http2: speed up response getHeaders - #66592

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
rozzilla:perf/http2/speed-up-response-get-headers
Oct 10, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
rozzilla:perf/http2/speed-up-response-get-headers

Conversation

@rozzilla

@rozzilla rozzilla commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Replace ObjectAssign in Http2ServerResponse.getHeaders() with an explicit
key-copy loop, preserving the null-prototype shallow copy. Add a benchmark
and compatibility coverage.

On Apple M2 / macOS, compared against
4fa5145:

Headers Throughput improvement
0 +37.30%
1 +149.27%
4 +180.65%
16 +229.59%
64 +256.02%

30 samples per binary and configuration, with 1,000,000 calls per sample.
These results measure getHeaders() throughput, not HTTP request throughput.

Copy validated header names directly into the shallow result instead
of using ObjectAssign on the internal null-prototype map.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net
  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.45%. Comparing base (554dd55) to head (3362b41).
⚠️ Report is 49 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66592      +/-   ##
==========================================
+ Coverage   90.44%   90.45%   +0.01%     
==========================================
  Files         791      791              
  Lines      276486   276568      +82     
  Branches    53092    53117      +25     
==========================================
+ Hits       250060   250169     +109     
+ Misses      16846    16802      -44     
- Partials     9580     9597      +17     
Files with missing lines Coverage Δ
lib/internal/http2/compat.js 97.25% <100.00%> (+0.01%) ⬆️

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pimterry pimterry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@aduh95 aduh95 added author ready PRs with CI started, the required approvals, and no outstanding review comments. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Oct 9, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark GHA (http2 / get-headers.js): https://github.com/nodejs/node/actions/runs/38037263644

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

                                          confidence improvement accuracy (*)    (**)   (***)
http2/get-headers.js headers=0 n=1000000         ***     33.00 %      ±12.38% ±16.33% ±20.95%
http2/get-headers.js headers=1 n=1000000         ***    186.95 %      ±26.41% ±34.89% ±44.90%
http2/get-headers.js headers=16 n=1000000        ***    262.96 %      ±30.59% ±40.41% ±52.04%
http2/get-headers.js headers=4 n=1000000         ***    224.45 %      ±28.45% ±37.59% ±48.39%
http2/get-headers.js headers=64 n=1000000        ***    298.00 %      ±32.70% ±43.21% ±55.65%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 5 comparisons, you can thus
expect the following amount of false-positive results:
  0.25 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.05 false positives, when considering a   1% risk acceptance (**, ***),
  0.01 false positives, when considering a 0.1% risk acceptance (***)

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 10, 2026
@nodejs-github-bot
nodejs-github-bot merged commit b823c3a into nodejs:main Oct 10, 2026
91 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in b823c3a

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants