Skip to content

url: optimize URLSearchParams set/delete duplicate handling#62266

Open
gurgunday wants to merge 1 commit intonodejs:mainfrom
gurgunday:perf/url-set-delete
Open

url: optimize URLSearchParams set/delete duplicate handling#62266
gurgunday wants to merge 1 commit intonodejs:mainfrom
gurgunday:perf/url-set-delete

Conversation

@gurgunday
Copy link
Member

This changes set and delete to use a single pass instead of repeated array.splice() while scanning

master:

url/url-searchparams-mutation.js n=10000 count=10 type="unique" method="set": 4,495,307.348658735
url/url-searchparams-mutation.js n=10000 count=1000 type="unique" method="set": 397,595.2168977331
> url/url-searchparams-mutation.js n=10000 count=10 type="duplicates" method="set": 2,309,513.092283293
> url/url-searchparams-mutation.js n=10000 count=1000 type="duplicates" method="set": 7,585.0868936063125
url/url-searchparams-mutation.js n=10000 count=10 type="unique" method="delete": 4,530,011.325028313
url/url-searchparams-mutation.js n=10000 count=1000 type="unique" method="delete": 305,692.37412161205
> url/url-searchparams-mutation.js n=10000 count=10 type="duplicates" method="delete": 2,222,098.772290428
> url/url-searchparams-mutation.js n=10000 count=1000 type="duplicates" method="delete": 7,601.665867066438

branch:

url/url-searchparams-mutation.js n=10000 count=10 type="unique" method="set": 4,314,296.500026965
url/url-searchparams-mutation.js n=10000 count=1000 type="unique" method="set": 398,303.2282476649
> url/url-searchparams-mutation.js n=10000 count=10 type="duplicates" method="set": 4,662,911.158019998
> url/url-searchparams-mutation.js n=10000 count=1000 type="duplicates" method="set": 199,327.60023302992
url/url-searchparams-mutation.js n=10000 count=10 type="unique" method="delete": 4,569,515.119611628
url/url-searchparams-mutation.js n=10000 count=1000 type="unique" method="delete": 284,133.96507300285
> url/url-searchparams-mutation.js n=10000 count=10 type="duplicates" method="delete": 5,081,732.037220638
> url/url-searchparams-mutation.js n=10000 count=1000 type="duplicates" method="delete": 213,852.28153652867

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/url

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Mar 15, 2026
@gurgunday gurgunday added the performance Issues and PRs related to the performance of Node.js. label Mar 15, 2026
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.67%. Comparing base (8ccbe8e) to head (07a4b40).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62266      +/-   ##
==========================================
- Coverage   89.68%   89.67%   -0.02%     
==========================================
  Files         676      676              
  Lines      206495   206576      +81     
  Branches    39537    39564      +27     
==========================================
+ Hits       185204   185243      +39     
- Misses      13435    13458      +23     
- Partials     7856     7875      +19     
Files with missing lines Coverage Δ
lib/internal/url.js 93.17% <100.00%> (+0.02%) ⬆️

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

Copy link
Member

@mertcanaltin mertcanaltin left a comment

Choose a reason for hiding this comment

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

lgtm

@H4ad
Copy link
Member

H4ad commented Mar 15, 2026

@gurgunday can we split this PR in two, so we can have benchmark introduced first and then the improvements? Or maybe split in two commits, then we can try use the benchmark commit as base to test the improvements on our CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants