url: speed up WHATWG URL parsing - #65361
Open
anonrig wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
This was referenced Aug 18, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65361 +/- ##
==========================================
- Coverage 91.85% 90.13% -1.73%
==========================================
Files 400 752 +352
Lines 178855 251898 +73043
Branches 27319 47378 +20059
==========================================
+ Hits 164283 227037 +62754
- Misses 14243 16185 +1942
- Partials 329 8676 +8347
🚀 New features to boost your workflow:
|
jasnell
requested changes
Aug 18, 2026
jasnell
left a comment
Member
There was a problem hiding this comment.
AI agents are not permitted to Signed-off-by
cursor
Bot
force-pushed
the
cursor/url-parse-performance-603e
branch
from
August 18, 2026 11:39
b9884e1 to
a66b5bc
Compare
Member
Author
|
Removed the |
cursor
Bot
force-pushed
the
cursor/url-parse-performance-603e
branch
from
August 18, 2026 12:49
a66b5bc to
39c4db7
Compare
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 Co-authored-by: Cursor Agent <cursoragent@cursor.com>
cursor
Bot
force-pushed
the
cursor/url-parse-performance-603e
branch
2 times, most recently
from
August 18, 2026 18:09
fa5ca3f to
ed31ad0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.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