Conversation
|
Why was this PR closed? The change checks out. It looks correct and it's and 2.5x faster. Overall, not a huge impact but likely a good enough small win. What I would say, @zirkelc, AI-assisted contributions are fine but Less Is More. The wall of Obviously-AI-Generated-Text tends to turn people off regardless of whether the code change is correct. |
I wanted to provide as much context as possible, so the maintainers could better judge the results. But I understand that maintainers already have to deal with much more issues/prs, and reading an unnecessary long PR just wastes everybody's time. Lesson learned, will do better the next time! :-) |
This relates to...
getCookies(headers), which parses theCookierequest header, e.g. in servers built on undici'sHeaders.Rationale
Each
name=valuepair was split withpiece.split('='), destructured with a rest element, and the value was joined back with'=': an array, a second array and a join per pair. The name is the text before the first=, and the value is everything after it, so oneindexOf('=')and twoslicecalls give the same result. A pair without=still maps its trimmed text to''.Changes
lib/web/cookies/index.js: the loop above.Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
N/A
Verification (this branch vs
328ab843)Headline numbers are standalone: one revision per process, 8 alternating process pairs, minimum of 100 runs per process, with an identical-code control (base against base) run the same way.
getCookies(12 pairs) +getSetCookies(5) +setCookieThe paired runs this branch was verified with (they decide experiments, they do not set the claim): full suite -8.43% / -18.05%, focused -18.86% / -18.25%. The suite totals do not move (+0.49% / -0.40%):
getCookiesis one of twelve cases.Observable surface
=, empty names, missing=, whitespace,__proto__) and hand-picked ones is identical.WPT (
npm run test:wpt: /fetch, /mimesniff, /xhr, /websockets, /eventsource) was run locally on328ab843and on this branch: per test and per case, pass/fail is identical across all 1 282 test files.Note on CI:
Test with Node.js 22 compiled --without-intlalready fails onmainat328ab843, before this change.Reproducing the numbers
The harness (A/B runner, guard, differential, focused and standalone runners) lives in
perf/on the campaign branch: zirkelc/undici@afde9423/perf (the plan and the experiment log with all discarded experiments are in the same directory). It needs Node 24 (it runs.mtsdirectly) and no install beyondnpm ci.A row marked
?has an interquartile band that crosses zero in that run; judge by two runs that agree, and by the standalone numbers.perf/cases.mts, the workloads these numbers come fromStatus
Companion PRs from the same campaign: #5901 (perf(fetch): avoid redundant request state in the Request constructor), #5902 (perf(websocket): mask frames without a mask array, four bytes per step), #5903 (perf(webidl): check ByteString code units with a native scan)