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 107 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

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

4 participants