Uh oh!
There was an error while loading. Please reload this page.
url: speed up WHATWG URL parsing - #65361
Conversation
nodejs-github-bot
commented
Aug 18, 2026
Review requested:
|
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
jasnell
left a comment
There was a problem hiding this comment.
AI agents are not permitted to Signed-off-by
b9884e1 to
a66b5bcCompareanonrig
commented
Aug 18, 2026
Removed the |
a66b5bc to
39c4db7CompareParse 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 <yagiz@nizipli.com> Assisted-by: Cursor
fa5ca3f to
ed31ad0Compare
gurgunday
left a comment
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ed31ad0 to
47af16cCompare
mertcanaltin
left a comment
There was a problem hiding this comment.
LGTM, I think we can seperate PR same improvement for canParse?
faad7a6 to
caa85b0CompareCallers 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 <yagiz@nizipli.com> Assisted-by: Cursor
caa85b0 to
7589246Comparenodejs-github-bot
commented
Aug 21, 2026
nodejs-github-bot
commented
Aug 21, 2026
nodejs-github-bot
commented
Aug 21, 2026
nodejs-github-bot
commented
Aug 22, 2026
nodejs-github-bot
commented
Aug 22, 2026
nodejs-github-bot
commented
Aug 23, 2026
Landed in 2df4ce7...a8f9a7f |
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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 <yagiz@nizipli.com> Assisted-by: Cursor PR-URL: #65361 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Speeds up
new URL()/URL.parse()on the common path: already-serialized ASCII hrefs.The binding currently always:
Utf8Value)href, even when it is byte-identical to the inputTypical URLs (
https://example.com/path, thewhatwg-url-parsebenchmark corpus) are one-byte ASCII and already in serialized form. This change:v8::String::ValueView(no UTF-8 copy)href == input(no second string allocation)std::stringjust to parse itupdate()(setters re-parse an already-serialized href)URLContextallocation until parse finishes, and initializes it in one shot fromurlComponents`${input}`when the value is already a stringNon-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:short/ no baselong/ no baseshort/ with basedot(needs path normalization, so a new href string) is unchanged.Review follow-up
reuse_inputdefaults tonullptr. Base-URL parse andupdate()omit it so we skip the O(n)href == inputcompare when the original V8 string will not be reused.Tests
test/parallel/test-whatwg-url-*.jsandtest-url-*.js: 54 pass, 1 skipurl: 5107 pass, 0 unexpected failurestest/parallel/test-whatwg-url-parse-fast-path.jscovers already-serialized ASCII hrefs, trailing-slash and dot-segment normalization, base resolution, non-string input, invalid input, unpaired surrogates, IDN, and settersAssisted-by: Cursor