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 — url: speed up WHATWG URL parsing by anonrig · Pull Request #65361 · nodejs/node

Conversation

@anonrig

@anonrig anonrig commented Aug 18, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Speeds up new URL() / URL.parse() on the common path: already-serialized ASCII hrefs.

The binding currently always:

  1. Copies the V8 string into a UTF-8 buffer (Utf8Value)
  2. Parses with Ada
  3. Allocates a new V8 string from href, even when it is byte-identical to the input

Typical URLs (https://example.com/path, the whatwg-url-parse benchmark corpus) are one-byte ASCII and already in serialized form. This change:

  • Parses one-byte ASCII inputs in place via v8::String::ValueView (no UTF-8 copy)
  • Returns the original V8 string when href == input (no second string allocation)
  • Avoids copying the base URL into a temporary std::string just to parse it
  • Applies the same in-place parse to update() (setters re-parse an already-serialized href)
  • Delays URLContext allocation until parse finishes, and initializes it in one shot from urlComponents
  • Skips `${input}` when the value is already a string

Non-ASCII inputs still go through Utf8Value. Those results are never reused as the original string, because UTF-8 conversion may replace unpaired surrogates.

Benchmark

Same machine, Release build, benchmark/url/whatwg-url-parse.js e=12. Repeated runs:

Config Before (ops/s) After (ops/s) Change
short / no base 7.82M 9.29M +19%
long / no base 2.50M 2.75M +10%
short / with base 2.94M 3.39M +15%

dot (needs path normalization, so a new href string) is unchanged.

Review follow-up

  • reuse_input defaults to nullptr. Base-URL parse and update() omit it so we skip the O(n) href == input compare when the original V8 string will not be reused.

Tests

  • test/parallel/test-whatwg-url-*.js and test-url-*.js: 54 pass, 1 skip
  • WPT url: 5107 pass, 0 unexpected failures
  • New test/parallel/test-whatwg-url-parse-fast-path.js covers already-serialized ASCII hrefs, trailing-slash and dot-segment normalization, base resolution, non-string input, invalid input, unpaired surrogates, IDN, and setters

Assisted-by: Cursor

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 18, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url
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 c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Aug 18, 2026
@anonrig
anonrig requested review from jasnell and mcollina August 18, 2026 01:33
This was referenced Aug 18, 2026
url: speed up URLSearchParams #65363
Merged
url: speed up URLPattern anonrig/node#24
Open
url: speed up URLPattern #65364
Open
@codecov

codecov Bot commented Aug 18, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08738% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.11%. Comparing base (13fcd6f) to head (7589246).
⚠️ Report is 93 commits behind head on main.

Files with missing lines Patch % Lines
src/node_url.cc 93.18% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65361      +/-   ##
==========================================
- Coverage   91.85%   90.11%   -1.74%     
==========================================
  Files         400      752     +352     
  Lines      178855   252356   +73501     
  Branches    27319    47474   +20155     
==========================================
+ Hits       164283   227413   +63130     
- Misses      14243    16224    +1981     
- Partials      329     8719    +8390     
Files with missing lines Coverage Δ
lib/internal/url.js 93.28% <100.00%> (+13.12%) ⬆️
src/node_url.cc 78.94% <93.18%> (ø)

... and 490 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.

jasnell
jasnell previously requested changes Aug 18, 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.

AI agents are not permitted to Signed-off-by

Sorry, something went wrong.

Uh oh!

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

All reactions
mcollina
mcollina approved these changes Aug 18, 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
@cursor
cursor Bot force-pushed the cursor/url-parse-performance-603e branch from b9884e1 to a66b5bc Compare August 18, 2026 11:39
@anonrig

anonrig commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

Removed the Signed-off-by trailer from the commit(s). An AI agent cannot attest the DCO.

All reactions

Sorry, something went wrong.

Uh oh!

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

@cursor
cursor Bot force-pushed the cursor/url-parse-performance-603e branch from a66b5bc to 39c4db7 Compare August 18, 2026 12:49
@anonrig
url: speed up WHATWG URL parsing
47af16c
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
@cursor
cursor Bot force-pushed the cursor/url-parse-performance-603e branch 2 times, most recently from fa5ca3f to ed31ad0 Compare August 18, 2026 18:09
gurgunday
gurgunday reviewed Aug 18, 2026
View reviewed changes

@gurgunday gurgunday 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.

I think we can avoid always comparing the strings here?

Base parsing and setters discard reuse_input, so here we can avoid an O(n) comparison no?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/node_url.cc Resolved

Uh oh!

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

Comment thread src/node_url.cc Resolved

Uh oh!

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

Comment thread src/node_url.cc Resolved

Uh oh!

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

Comment thread src/node_url.cc Resolved

Uh oh!

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

Comment thread src/node_url.cc Resolved

Uh oh!

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

@cursor
cursor Bot force-pushed the cursor/url-parse-performance-603e branch from ed31ad0 to 47af16c Compare August 18, 2026 18:43
@jasnell
jasnell dismissed their stale review August 18, 2026 22:53

Resolved

mertcanaltin
mertcanaltin approved these changes Aug 19, 2026
View reviewed changes

@mertcanaltin mertcanaltin 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, I think we can seperate PR same improvement for canParse?

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/url-parse-performance-603e branch 2 times, most recently from faad7a6 to caa85b0 Compare August 20, 2026 18:57
@anonrig
url: skip unused href reuse comparison
7589246
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
@cursor
cursor Bot force-pushed the cursor/url-parse-performance-603e branch from caa85b0 to 7589246 Compare August 20, 2026 18:57
@anonrig
anonrig requested review from jasnell, joyeecheung and lemire August 20, 2026 18:57
mcollina
mcollina approved these changes Aug 21, 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 21, 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 21, 2026
@nodejs-github-bot

nodejs-github-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot

nodejs-github-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot

nodejs-github-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

lemire
lemire approved these changes Aug 21, 2026
View reviewed changes
gurgunday
gurgunday approved these changes Aug 21, 2026
View reviewed changes

@gurgunday gurgunday 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
@nodejs-github-bot

nodejs-github-bot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot

nodejs-github-bot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@anonrig anonrig added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. labels Aug 23, 2026
@nodejs-github-bot

nodejs-github-bot commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2df4ce7...a8f9a7f

All reactions

Sorry, something went wrong.

Uh oh!

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

nodejs-github-bot pushed a commit that referenced this pull request Aug 23, 2026
@anonrig @nodejs-github-bot
url: speed up WHATWG URL parsing
130fe36
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 23, 2026
@anonrig @nodejs-github-bot
url: skip unused href reuse comparison
a8f9a7f
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
@nodejs-github-bot nodejs-github-bot closed this Aug 23, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 23, 2026
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@anonrig @aduh95
url: speed up WHATWG URL parsing
e3c28db
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@anonrig @aduh95
url: skip unused href reuse comparison
5cc1bc8
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@anonrig @aduh95
url: speed up WHATWG URL parsing
2a64032
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@anonrig @aduh95
url: skip unused href reuse comparison
f032c22
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 25, 2026
2026-08-26, Version 26.8.0 (Current) #65551
Merged
aduh95 pushed a commit that referenced this pull request Aug 27, 2026
@anonrig @aduh95
url: speed up WHATWG URL parsing
5227981
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 27, 2026
@anonrig @aduh95
url: skip unused href reuse comparison
ef6bb9a
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
@github-actions github-actions Bot mentioned this pull request Sep 7, 2026
2026-09-08, Version 24.21.0 'Krypton' (LTS) #65873
Merged
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
@anonrig @aduh95
url: speed up WHATWG URL parsing
c99a2a9
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
@anonrig @aduh95
url: skip unused href reuse comparison
3f7d916
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
@anonrig @aduh95
url: speed up WHATWG URL parsing
58390f8
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
@anonrig @aduh95
url: skip unused href reuse comparison
a500256
Callers that never reuse the original V8 string (base URL parse and
setters) now omit reuse_input so ParseUrlFromV8String does not
compare href against the input.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Cursor
PR-URL: #65361
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gürgün Dayıoğlu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@lemire lemire lemire approved these changes
@gurgunday gurgunday gurgunday approved these changes
@jasnell jasnell Awaiting requested review from jasnell
@joyeecheung joyeecheung Awaiting requested review from joyeecheung
+1 more reviewer
@mertcanaltin mertcanaltin mertcanaltin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

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.

7 participants

@anonrig @nodejs-github-bot @mcollina @lemire @jasnell @mertcanaltin @gurgunday
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 01402503 — 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.