Skip to content

url: use indexed appends in search params getAll - #66872

Open
rozzilla wants to merge 3 commits into
nodejs:mainfrom
rozzilla:url-optimize-searchparams-getall
Open

rozzilla wants to merge 3 commits into
nodejs:mainfrom
rozzilla:url-optimize-searchparams-getall

Conversation

@rozzilla

Copy link
Copy Markdown
Contributor

Use indexed appends instead of primordial push calls when collecting
matching values in URLSearchParams.getAll(). This reduces the cost of
reading repeated query parameters while preserving result order.

Local benchmarks on Apple M2/macOS with V8 15.6 show higher throughput:

  • Existing two- and three-match workloads: +20.4% and +29.4%.
  • Consumed-result reads with multiple matches: +28.5–106.8%.
  • Parsing a fresh query and retrieving 256 matching values: +8.9%.

Across 36 cases and 4,320 samples, nine gains were confirmed in both
comparison directions after Holm correction. No corrected-significant
regressions were detected.

Use indexed writes when collecting matching parameter values.
This improves getAll throughput without changing result order.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
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 Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (531d28f) to head (5fff1bc).
⚠️ Report is 151 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66872      +/-   ##
==========================================
+ Coverage   90.49%   90.66%   +0.16%     
==========================================
  Files         797      797              
  Lines      278221   278262      +41     
  Branches    53462    53509      +47     
==========================================
+ Hits       251786   252293     +507     
+ Misses      16809    16339     -470     
- Partials     9626     9630       +4     
Files with missing lines Coverage Δ
lib/internal/url.js 93.40% <100.00%> (ø)

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

Comment thread test/parallel/test-whatwg-url-searchparams-getall-results.js Outdated
Comment thread benchmark/url/url-searchparams-getAll.js Outdated
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla
rozzilla requested a review from gurgunday October 26, 2026 10:29

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@gurgunday gurgunday added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 26, 2026
@gurgunday

Copy link
Copy Markdown
Member

FYI for others,

const arr = [];
arr[arr.length] = 'X'

Keeps an array PACKED in all active release lines, so it is a valid optimization for avoiding Primordials

@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 Oct 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@H4ad H4ad added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 26, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 29, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Oct 29, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

This pull request has multiple commits, but no landing policy was selected.

Add commit-queue-squash PRs the Commit Queue should land as one squashed commit. to land it as one commit, or commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. to land the commits separately.

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/66872
�[36m⠋�[39m Loading data for nodejs/node/pull/66872
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/66872
�[36m⠋�[39m Getting reviews from nodejs/node/pull/66872
�[36m⠋�[39m Getting comments from nodejs/node/pull/66872
�[36m⠋�[39m Getting commits from nodejs/node/pull/66872
✔  Done loading data for nodejs/node/pull/66872
----------------------------------- PR info ------------------------------------
Title      url: use indexed appends in search params getAll (#66872)
   ⚠  Could not retrieve the email or name of the PR's author from user's GitHub profile!
Branch     rozzilla:url-optimize-searchparams-getall -> nodejs:main
Labels     whatwg-url, author ready, needs-ci, commit-queue
Commits    3
 - url: use indexed appends in search params getAll
 - update
 - update
Committers 1
 - Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66872
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/66872
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 20 Oct 2026 09:35:05 GMT
   ✔  Approvals: 1
   ✔  - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/66872#pullrequestreview-5654170027
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-10-26T18:57:45Z: https://ci.nodejs.org/job/node-test-pull-request/78675/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78675/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78675/
�[36m⠙�[39m Querying API for job/node-test-pull-request/78675/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
�[36m⠹�[39m Querying API for job/node-test-pull-request/78675/
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
�[36m⠹�[39m Querying API for job/node-test-pull-request/78675/
�[36m⠹�[39m Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
�[36m⠸�[39m Downloading patch for 66872
�[36m⠸�[39m Downloading patch for 66872
From https://github.com/nodejs/node
 * branch                  refs/pull/66872/merge -> FETCH_HEAD
✔  Fetched commits as 510d84c330e8..5fff1bc73ec5
--------------------------------------------------------------------------------
[main aca3e74402] url: use indexed appends in search params getAll
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Tue Oct 20 11:33:15 2026 +0200
 3 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 benchmark/url/url-searchparams-getAll.js
 create mode 100644 test/parallel/test-whatwg-url-searchparams-getall-results.js
[main 018d1d547d] update
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Mon Oct 26 11:17:14 2026 +0100
 1 file changed, 24 deletions(-)
 delete mode 100644 test/parallel/test-whatwg-url-searchparams-getall-results.js
[main fd94f9dc1f] update
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Mon Oct 26 11:28:56 2026 +0100
 1 file changed, 46 deletions(-)
 delete mode 100644 benchmark/url/url-searchparams-getAll.js
   ✔  Patches applied
There are 3 commits in the PR. Attempting autorebase.
(node:618) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/6)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
url: use indexed appends in search params getAll

Use indexed writes when collecting matching parameter values.
This improves getAll throughput without changing result order.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66872
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
[detached HEAD 1c8da5dbc0] url: use indexed appends in search params getAll
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Tue Oct 20 11:33:15 2026 +0200
 3 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 benchmark/url/url-searchparams-getAll.js
 create mode 100644 test/parallel/test-whatwg-url-searchparams-getall-results.js
Rebasing (3/6)
Rebasing (4/6)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
update

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66872
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
[detached HEAD 0b9a5f07d7] update
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Mon Oct 26 11:17:14 2026 +0100
 1 file changed, 24 deletions(-)
 delete mode 100644 test/parallel/test-whatwg-url-searchparams-getall-results.js
Rebasing (5/6)
Rebasing (6/6)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
update

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66872
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
[detached HEAD 925a2d12b1] update
 Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
 Date: Mon Oct 26 11:28:56 2026 +0100
 1 file changed, 46 deletions(-)
 delete mode 100644 benchmark/url/url-searchparams-getAll.js
Successfully rebased and updated refs/heads/main.
--------------------------------------------------------------------------------
   ℹ  Add `commit-queue-squash` label to land the PR as one commit, or `commit-queue-rebase` to land as separate commits.

View workflow run

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

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants