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,http2: speed up header validation and write coalescing by anonrig · Pull Request #65332 · nodejs/node

Conversation

@anonrig

@anonrig anonrig commented Aug 16, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This speeds up the HTTP/1 and HTTP/2 hot paths that show up in
writeHead()/end(), small-body writes, and HTTP/2 header serialization.

HTTP/1

  • Use the token lookup table for names of length <= 10 (Connection,
    Keep-Alive). Longer names stay on the regex path; a JS table over
    those lengths is slower than V8's regex.
  • Cache OutgoingMessage lenient-validation and skip statusMessage
    validation for the built-in reason phrases.
  • Reuse prebuilt HTTP/1.1 <code> <reason>\r\n status lines.
  • Avoid toLowerCase() for the common Title-Case / lowercase spellings
    of Connection, Content-Length, Transfer-Encoding, and friends.
  • Coalesce headers with small Buffer bodies into one socket.write().
  • When res.end(chunk) is used with Transfer-Encoding: chunked and
    headers have not been flushed, send headers + last chunk + terminator
    in a single write (headers copied as latin1 so obs-text is preserved).
  • Keep incoming header name/value bytes in a packed Buffer. rawHeaders
    / headers materialize JS strings only when read. The default server
    Host / Expect / body-header checks use flag bits and do not build
    req.headers.
  • IncomingMessage._dump() / dumped bodies skip Buffer::Copy via
    parser.setSkipBody().

HTTP/2

  • Skip toLowerCase() when header names are already lowercase.
  • Hoist buildNgHeaderString processing off a per-call closure.
  • Use a Set for sensitive / strict single-value header checks.
  • Reserve outgoing session storage while gathering
    nghttp2_session_mem_send chunks.

These are incremental, behavior-preserving changes. They do not move
end-to-end benchmark/http/simple.js by 50%. Local wrk numbers vs
upstream/main (same machine, release build, 2x 5s) for the JS write /
validation work:

config main this PR delta
buffer, len=4, chunked, c=50 84.6k req/s 91.2k +7.9%
bytes, len=4, chunked, c=50 78.2k 78.3k +0.1%
buffer, len=1024, chunked, c=50 73.4k 77.4k +5.4%
bytes, len=1024, content-length, c=50 77.0k 81.4k +5.8%

check_is_http_token for Connection is about +21%. Header-value
validation stays on regex (a JS Uint8Array scan was 30–50% slower).

The packed-header follow-up keeps bytes off the JS string heap until
something actually reads rawHeaders / headers. A per-request native
BaseObject was slower than creating the string array, so the bytes live
in one Buffer with flag bits for Host / Expect / body headers.

Tests

  • Extra checkInvalidHeaderChar cases in test/parallel/test-http-common.js.
  • test/parallel/test-http-chunked-end-coalesce.js checks the wire
    format of coalesced chunked end() (string, buffer, UTF-8, trailers,
    unusual Content-Length casing, latin1 header values).
  • test/parallel/test-http-native-headers.js checks lazy Host / Expect
    lookups and materialization on req.headers access.

Local: 405/405 test/parallel/test-http-* (HTTP/1) passed against a
release build of the packed-headers tree. Earlier 776/776
test-http* / test-https* / test-http2* passed on the same branch
before the Buffer packing tweak.

Sorry, something went wrong.

Uh oh!

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

bricss reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@nodejs-github-bot

nodejs-github-bot commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net
All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 16, 2026
@anonrig
anonrig force-pushed the cursor/http-http2-perf-f24c branch from 76c8e14 to 62327c4 Compare August 16, 2026 18:59
@anonrig

anonrig commented Aug 16, 2026

Copy link
Copy Markdown
Member Author

Local results from a release build of this branch vs upstream/main on the same machine (4 cores).

Correctness

  • 779/779 test-http* / test-https* / test-http2* (parallel + sequential + pummel + async-hooks) passed.
  • The earlier CI failures (test-http-response-cork, test-http-server-non-utf8-header) were from writing coalesced chunked headers with the body encoding. Fixed by copying headers as latin1 and relaxing the cork test to mustCallAtLeast.

benchmark/http/simple.js (wrk, duration=5, c=50, 2 runs)

type len encoding main req/s PR req/s delta
buffer 4 chunked 84,567 91,239 +7.9%
bytes 4 chunked 78,179 78,271 +0.1%
buffer 1024 chunked 73,366 77,353 +5.4%
bytes 1024 content-length 76,980 81,406 +5.8%

Micros (3 runs, ops/s)

A JS lookup table for all token lengths and for header-value checks was a regression (V8 regex is faster past ~10 bytes). Latest commit keeps regex for values and for tokens longer than 10, and uses the table for Connection / Keep-Alive:

bench main PR delta
check_is_http_token Connection 44.2M 53.7M +21%
check_is_http_token Content-Length 37.8M 36.6M ~noise
check_invalid_header_char keep-alive 51.3M 49.0M ~noise
set_header Connection 12.5M 12.8M +2%

HTTP/2 headers.js was within noise (−7% to +0%).

So the measurable end-to-end win is the small-Buffer / chunked end() coalescing, on the order of 5–8%, not 50%. I am not claiming a 50% HTTP/HTTP2 speedup from this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

ronag
ronag approved these changes Aug 16, 2026
View reviewed changes
@ronag
ronag requested a lite review from Copilot August 16, 2026 20:20
Copilot started reviewing on behalf of ronag August 16, 2026 20:20
View session
Copilot AI reviewed Aug 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes Node.js HTTP/1.1 and HTTP/2 hot paths around header validation/serialization and write coalescing to reduce per-request overhead in writeHead()/end() and small-body responses.

Changes:

  • HTTP/1: faster header-name token validation, cached lenient-validation, reused prebuilt status lines, avoided common-case toLowerCase(), and added header/body write coalescing (including a combined chunked end() write).
  • HTTP/1 server: avoid forcing req.headers construction when checking for Content-Length / Transfer-Encoding by scanning rawHeaders.
  • HTTP/2: reduce lowercasing overhead in header processing and reserve outgoing send storage to reduce reallocations.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/parallel/test-http-response-cork.js Updates expectations to allow fewer socket.write() calls due to new coalescing behavior.
test/parallel/test-http-common.js Adds more checkInvalidHeaderChar() test cases for strict vs lenient validation.
test/parallel/test-http-chunked-end-coalesce.js New test validating wire format when chunked res.end() is coalesced into a single write.
src/node_http2.cc Reserves outgoing HTTP/2 storage in send path to reduce reallocations.
lib/internal/http2/util.js Refactors nghttp2 header string building to reduce lowercasing/closure overhead and uses Set for strict single-value checks.
lib/internal/http2/core.js Avoids unconditional toLowerCase() in response header array scanning.
lib/_http_server.js Prebuilds HTTP/1.1 status lines and avoids unnecessary statusMessage validation for defaults; uses req._hasBodyHeaders() for optimizeEmptyRequests.
lib/_http_outgoing.js Coalesces headers with small bodies; adds combined chunked end() fast path; caches lenient-header-validation result; reduces common-case toLowerCase().
lib/_http_incoming.js Adds IncomingMessage.prototype._hasBodyHeaders() scanning rawHeaders to avoid constructing req.headers.
lib/_http_common.js Speeds up checkIsHttpToken() by using a lookup table for short names and regex for longer ones.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread lib/_http_outgoing.js Outdated
Comment on lines +1264 to +1276
}

write_(this, chunk, encoding, null, true);
write_(this, chunk, encoding, onFinish.bind(undefined, this), true);

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed. On the chunk path the user callback is now queued with queueEndCallback() before write_(), so a synchronous socket.write() (for example assignSocket() plus a custom Writable) cannot run onFinish() first and then treat the callback as already finished.

Covered by the new assignSocket() + sync end('hello', cb) case in test/parallel/test-http-outgoing-message-write-callback.js.

Sorry, something went wrong.

Uh oh!

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

All reactions
@anonrig

anonrig commented Aug 16, 2026

Copy link
Copy Markdown
Member Author

Follow-up: incoming header bytes now stay off the JS string heap until something actually reads them.

kOnHeadersComplete passes a packed Buffer (magic + count + flags + name/value bytes) instead of a JS string array or a per-request native BaseObject. IncomingMessage.rawHeaders / headers materialize strings only on first read. The default HTTP/1.1 server Host / Expect / Content-Length / Transfer-Encoding checks use flag bits written while packing, so simple.js-style handlers that never touch req.headers do not create header strings. _dump() sets parser.setSkipBody(true) so dumped bodies skip Buffer::Copy.

A first attempt used a NativeHttpHeaders BaseObject per request (Function::NewInstance + MakeWeak). That was slower than creating the JS string array — especially with many headers — so it was replaced with one Buffer.

test/parallel/test-http-native-headers.js covers the lazy Host check (including 400 without Host) and materialization. 405/405 test/parallel/test-http-* passed on the packed-buffer tree.

I am not updating the simple.js wrk table from this environment; run-to-run noise here is large enough to hide a real single-digit delta. The earlier +5–8% numbers are for the write/validation commits, not a claim that packed headers moved end-to-end simple.js by that much (wrk GETs have no body, and the handler never reads req.headers).

All reactions

Sorry, something went wrong.

Uh oh!

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

@codecov

codecov Bot commented Aug 16, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.53312% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.50%. Comparing base (c58ccfa) to head (62f65f6).

Files with missing lines Patch % Lines
src/node_http_parser.cc 85.30% 5 Missing and 26 partials ⚠️
lib/internal/http/outgoing.js 96.34% 6 Missing ⚠️
lib/internal/http/incoming.js 97.95% 3 Missing ⚠️
lib/internal/http2/util.js 98.68% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65332      +/-   ##
==========================================
- Coverage   90.52%   90.50%   -0.03%     
==========================================
  Files         805      805              
  Lines      285669   286151     +482     
  Branches    55151    55257     +106     
==========================================
+ Hits       258616   258991     +375     
- Misses      17173    17263      +90     
- Partials     9880     9897      +17     
Files with missing lines Coverage Δ
lib/internal/http/client.js 97.12% <100.00%> (+<0.01%) ⬆️
lib/internal/http/common.js 98.30% <100.00%> (-0.25%) ⬇️
lib/internal/http/server.js 95.02% <100.00%> (-1.64%) ⬇️
src/node_http2.cc 82.20% <100.00%> (+<0.01%) ⬆️
lib/internal/http2/util.js 93.02% <98.68%> (+0.02%) ⬆️
lib/internal/http/incoming.js 96.96% <97.95%> (-0.71%) ⬇️
lib/internal/http/outgoing.js 97.29% <96.34%> (-0.74%) ⬇️
src/node_http_parser.cc 84.26% <85.30%> (+0.19%) ⬆️

... and 34 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.
All reactions

Sorry, something went wrong.

Uh oh!

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

mcollina
mcollina approved these changes Aug 17, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

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

All reactions
@mcollina mcollina 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 Aug 17, 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 Aug 17, 2026
@nodejs-github-bot

nodejs-github-bot commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75902/

All reactions

Sorry, something went wrong.

Uh oh!

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

jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread lib/internal/http2/core.js Outdated
header = header.toLowerCase();
break;
}
}

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What impact does this actually have? I'd prefer not to micro-optimize these things if the benefit is only marginal. The more we micro-optimize this stuff the more difficult maintenance becomes.

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Agreed — the HTTP/2 header benches were within noise. Reverted this to an unconditional toLowerCase().

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread lib/internal/http2/util.js Outdated
const c = key.charCodeAt(i);
if (c >= 65 && c <= 90)
return key.toLowerCase();
}

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is an example of what I mean, this is introducing duplication that is more difficult to maintain.

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Removed asciiToLowerIfNeeded. buildNgHeaderString uses toLowerCase() again; the only leftover from that pass is the hoisted processor / SafeSet cleanup, which is not a second lowercasing helper.

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread lib/_http_incoming.js Outdated
const len = name.length;
if (len === 14) {
if (name === 'Content-Length' || name === 'content-length' ||
name === 'CONTENT-LENGTH' || name.toLowerCase() === 'content-length') {

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is there any evidence that the all-caps variations here are used often enough to warrant special casing? I've never seen it used in practice.

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No evidence they are common enough. Dropped the CONTENT-LENGTH / TRANSFER-ENCODING special cases. The materialized fallback still checks Title-Case, lowercase, and toLowerCase().

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread src/node_http_parser.cc Outdated
// Packed incoming headers: magic + count + flags + (nlen, vlen, name, value)*
// Kept as a Buffer so JS strings are created only when rawHeaders / headers
// are actually read. Avoids a native BaseObject per request.
constexpr uint32_t kNativeHeadersMagic = 0x5244484E; // 'NHDR'

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think you have an endianness bug here.

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes. The packed uint32_ts were memcpy'd in host order, while JS always read them as little-endian, which is what failed on s390x and AIX.

They are now written and read with explicit LE helpers (WriteU32LE / ReadU32LE). Magic 0x5244484E is the LE encoding of ASCII NHDR on every arch.

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread src/node_http_parser.cc
constexpr uint32_t kNativeHeaderFlagContentLength = 1 << 2;
constexpr uint32_t kNativeHeaderFlagTransferEncoding = 1 << 3;
constexpr uint32_t kNativeHeaderFlagTE = 1 << 4;
constexpr size_t kNativeHeadersPrefix = 12;

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It would be better to export these to the js side to avoid having to define two different sets

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Exported from C++ on HTTPParser: kNativeHeadersMagic, kNativeHeaderFlag*, kNativeHeadersCountOffset, kNativeHeadersFlagsOffset, and kNativeHeadersPrefix. JS reads those instead of keeping a second copy.

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread lib/_http_incoming.js Outdated
},
});

ObjectDefineProperty(IncomingMessage.prototype, 'rawHeaders', {

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is an observable change (data property -> prototype property) making this potentially semver-major

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The constructor still does this.rawHeaders = [], so a fresh IncomingMessage keeps an own data property.

When headers arrive packed, _setNativeHeaders installs an own accessor that materializes into an own writable data property on first get or set. It is not a prototype getter.

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell reviewed Aug 17, 2026
View reviewed changes
Comment thread lib/_http_common.js Outdated
calculateLenientFlags,
prepareError,
kSkipPendingData,
unpackHeaderList,

@jasnell jasnell Aug 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is this actually used anywhere? I couldn't find it if it is.

Sorry, something went wrong.

Uh oh!

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

All reactions

@anonrig anonrig Aug 18, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It was only used by test/parallel/test-http-parser.js. Removed the export; that test now materializes via internalBinding('http_parser').nativeHeadersToArray.

Sorry, something went wrong.

Uh oh!

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

All reactions
jasnell
jasnell requested changes Aug 17, 2026
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Coverage regressions and endianness bug, at the very least, need to be looked at before this lands. There are a number of questionable changes here (noted in comments);

Sorry, something went wrong.

Uh oh!

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

All reactions
@anonrig anonrig mentioned this pull request Aug 17, 2026
http: address review feedback for packed headers anonrig/node#20
Draft
@anonrig

anonrig commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

Addressed the review notes in the latest commits on this branch:

  • Endianness: packed header integers are little-endian on every architecture (the s390x / AIX failure).
  • Coverage: added tests for the packed-header binding helpers, exported constants, own-property rawHeaders, Host / Expect / TE / body-header lazy checks, materialization fallbacks, and the sync end(chunk, cb) race.
  • Other notes: HTTP/2 skip-toLowerCase micro-opts reverted, all-caps header special cases removed, layout constants exported from C++, rawHeaders remains an own property, unused unpackHeaderList export dropped.

Replies are on the individual threads.

All reactions

Sorry, something went wrong.

Uh oh!

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

@jasnell

jasnell commented Aug 18, 2026

Copy link
Copy Markdown
Member

commits are missing appropriate Signed-off-by

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Sep 19, 2026
http: cut per-request work on the server hot path anonrig/node#30
Draft
http: avoid toLowerCase on the server hot path #66120
Merged
nodejs-github-bot pushed a commit that referenced this pull request Sep 25, 2026
@anonrig
http: avoid toLowerCase on the server hot path
4bd56b3
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
HoonDongKang pushed a commit to HoonDongKang/node that referenced this pull request Sep 28, 2026
@anonrig @HoonDongKang
http: avoid toLowerCase on the server hot path
e294120
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
PR-URL: nodejs#66120
Refs: nodejs#65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
aduh95 pushed a commit that referenced this pull request Sep 28, 2026
@anonrig @aduh95
http: avoid toLowerCase on the server hot path
0697b10
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
aduh95 pushed a commit that referenced this pull request Sep 28, 2026
@anonrig @aduh95
http: avoid toLowerCase on the server hot path
0bb9802
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 23, 2026
@anonrig @aduh95
http: avoid toLowerCase on the server hot path
51759dd
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 28, 2026
@anonrig @aduh95
http: avoid toLowerCase on the server hot path
5c0bd39
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@anonrig @aduh95
http: avoid toLowerCase on the server hot path
6aab8e1
After #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: #65802
Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: a closed-source coding agent
PR-URL: #66120
Refs: #65332
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
@anonrig
http,http2: speed up header validation and write coalescing
62f65f6
Rebase onto the internal/http split. Lenient-validation caching and
default status-line caching already landed; this keeps the remaining
hot-path work:

- Check HTTP tokens of length <= 10 with the lookup table.
- Coalesce a small body with the header block, and send a chunked
  end(chunk) as one latin1 write when the header block is still pending.
- Recognize the usual Title-Case header names without toLowerCase().
- Keep incoming header bytes packed until rawHeaders or headers is read.
- Skip the parser body when a request is dumped.
- Hoist HTTP/2 header-string processing off a per-call closure and
  reserve outgoing session storage.

Assisted-by: Cursor
Signed-off-by: Yagiz Nizipli <[email protected]>
Co-authored-by: Yagiz Nizipli <[email protected]>
@cursor
cursor Bot force-pushed the cursor/http-http2-perf-f24c branch from 37317f2 to 62f65f6 Compare November 28, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@jasnell jasnell jasnell requested changes
@mcollina mcollina mcollina approved these changes
@ronag ronag ronag approved these changes

Requested changes must be addressed to merge this pull request.

Uh oh!

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

Assignees

No one assigned

Labels

lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

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.

6 participants

@anonrig @nodejs-github-bot @jasnell @mcollina @ronag
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.