GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: cut per-request work on the server hot path by anonrig · Pull Request #30 · anonrig/node

Conversation

@anonrig

@anonrig anonrig commented Sep 19, 2026 •
edited by cursor Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

What

Every HTTP/1.1 request was paying for work most applications never need:

  • requireHostHeader (on by default) and the Expect check both read req.headers, which builds the whole headers object and toLowerCase()s every name.
  • writeHead() rebuilt the status line, Date: line, and Keep-Alive pair on every response.
  • Each request allocated two bound functions (updateOutgoingData, resOnFinish).
  • The parser created a fresh V8 string for every header name, including tokens like Host that appear on every request.

This change:

  1. Scans rawHeaders with a non-allocating ASCII compare for Host / Expect / Content-Length / Transfer-Encoding.
  2. Caches the default status line, the complete Date: …\r\n line, and the Connection + Keep-Alive pair.
  3. Reuses one pending-data callback and one 'finish' listener per connection.
  4. Interns header names in the C++ parser (kInternalized) so repeated tokens share one V8 string.

Wire format is unchanged. req.headers is still lazy and still correct when the application reads it, including unusual HOST / EXPECT casing (test/parallel/test-http-server-raw-header-lookup.js).

Benchmarks

Release build (./configure --without-intl --without-npm), same machine, server pinned with taskset -c 0, client is wrk -t2 -c50. Baseline is this tree at dd5dfb5250 (current nodejs/node main). Opt is this PR.

Official Node benches (one 5s run each):

bench baseline this PR Δ
http/simple.js bytes,len=4,c=50 111,290 req/s 117,556 +5.6%
http/incoming_headers.js headers=20 109,783 124,238 +13.2%

wrk hello-world, 8 extra request headers, 5 interleaved rounds of 8s (distributions do not overlap):

handler baseline median this PR median Δ
res.end('hello') 101,799 115,613 +13.6%
same, but read req.headers.host 94,629 103,678 +9.6%

The extra-header case is the realistic one: browsers and proxies send Host plus several other fields, and requireHostHeader used to materialize all of them.

Tests

python3 tools/test.py --mode=release --shell <opt-node>: all test/parallel/test-http-*.js that I ran passed (408 files across three batches).

Related

Overlaps with nodejs#65802 and nodejs#65332. Differences from nodejs#65802: the raw-header scan does not allocate toLowerCase() copies, Expect is resolved without materializing req.headers, HTTP/1.0 TE uses the same path, and header names are interned in the parser.

AI

A closed-source coding agent helped write and measure this. The HTTP hot path (parserOnIncoming, _storeHeader, CreateHeaders) was read and checked against the existing tests before opening the PR. Benchmark numbers above are from the two release binaries on this machine, not from a model.

Refs: nodejs#65802
Refs: nodejs#65332

Open in Web Open in Cursor 

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cursor
cursor Bot force-pushed the cursor/http-perf-a3fb branch 2 times, most recently from fbe7035 to 1fda05a Compare September 19, 2026 03:01
ayush23chaudhary and others added 6 commits September 19, 2026 03:52
@ayush23chaudhary
diagnostics_channel: replace using with try-finally
b125121
Signed-off-by: Ayush Chaudhary <[email protected]>
PR-URL: nodejs#64251
Fixes: nodejs#64230
Reviewed-By: René <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@mcollina
buffer: add Buffer.stringLength()
22ab7d7
Add `Buffer.stringLength(input[, encoding])`, the counterpart of
`Buffer.byteLength()`: it returns the number of UTF-16 code units that
`buf.toString(encoding)` would produce, without decoding.

For UTF-8 the count is computed with simdutf. Invalid input is counted
with the same maximal-subpart replacement that the decoder applies, so
the result always matches `toString().length`. The other encodings are
computed from `byteLength` alone.

This lets code that accumulates streamed input check the result against
`buffer.constants.MAX_STRING_LENGTH` and size its memory budget before
decoding.

Refs: nodejs#66062
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: nodejs#66064
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
@panva
tls: preserve CN name constraints with OpenSSL 4.1
4d1ab3e
OpenSSL no longer applies DNS name constraints to the subject CN by
default, but tls.checkServerIdentity() still uses it without a DNS SAN.
Enable subject checking during chain verification only when no DNS SAN
exists, preserving the existing hostname verification policy.

Assisted-by: Codex
Signed-off-by: Filip Skokan <[email protected]>
PR-URL: nodejs#65957
Refs: https://openssl-library.org/post/2026-09-09-openssl-4.1-alpha/
Reviewed-By: Tim Perry <[email protected]>
@codebytere
inspector: fix connectToMainThread() abort without parent inspector
e98208b
`inspector.Session#connectToMainThread()` in a Worker aborted the
process on `CHECK_NOT_NULL(parent_handle_)` in
`Agent::ConnectToMainThread()` when the parent Environment was created
with `kNoCreateInspector`, as embedders that run their own inspector
(or none) do.

Throw the new `ERR_INSPECTOR_NOT_AVAILABLE` in that case, next to the
existing throw for a Worker whose own inspector is not initialized.

Refs: nodejs#35025
Signed-off-by: Shelley Vohr <[email protected]>
PR-URL: nodejs#65976
Reviewed-By: Kohei Ueno <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@mcollina
http: reduce per-request allocations in the server
357ba2f
Remove allocations and repeated work performed for every request:

- reuse a per-connection updateOutgoingData closure and a shared
  'finish' listener instead of binding two functions per request,
  reaching resOnFinish through the connection state stored on the
  response
- cache the ServerResponse options object per server (custom response
  classes keep receiving a fresh object)
- check for Host, Expect, Content-Length and Transfer-Encoding by
  scanning rawHeaders instead of materializing req.headers, which was
  built (with per-name toLowerCase calls) for every request even when
  the application never reads it
- cache the rendered status line per status code when the reason
  phrase is the default, skipping its character validation
- cache the complete 'Date: ...' header line in the utcDate cache and
  the keep-alive header pair for the current server settings
- compute the lenient-validation option chain once per message

Signed-off-by: Matteo Collina <[email protected]>
PR-URL: nodejs#65802
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
@anonrig
http: avoid toLowerCase on the server hot path
9b786ff
After nodejs#65802, Host/Expect/body checks still allocate
toLowerCase() copies and Expect/HTTP/1.0 TE still
read req.headers. Compare names without allocating,
read those values from rawHeaders, intern parser
header names, and skip Title-Case toLowerCase on
common outgoing fields.

Refs: nodejs#65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
@cursor
cursor Bot force-pushed the cursor/http-perf-a3fb branch from 16a6107 to 9b786ff Compare September 19, 2026 12:03
@anonrig
http: do not intern arbitrary parser header names
534f13d
Interning every parsed header name lets a client fill the V8
interned string table with unique tokens. Drop that and keep
names as ordinary strings.

Refs: nodejs#66120
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@anonrig @ayush23chaudhary @mcollina @panva @codebytere
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.