Skip to content

querystring: precompute Latin-1 escapes - #66756

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
rozzilla:querystring-precompute-latin1-escapes
Nov 5, 2026
Merged

nodejs-github-bot merged 2 commits into
nodejs:mainfrom
rozzilla:querystring-precompute-latin1-escapes

Conversation

@rozzilla

@rozzilla rozzilla commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Precompute percent-encoded strings for the 128 non-ASCII Latin-1 characters instead of joining two byte escapes on every occurrence. This reduces repeated work when querystring and URLSearchParams serialize query parameters containing characters such as é. Other character ranges are unchanged; the tradeoff is a fixed 128-entry lookup table.

Benchmarks on Apple M2/macOS against dd7235c show higher throughput

  • Existing heavily encoded querystring.stringify workload (+31.9%)
  • Dense Latin-1 querystring.escape workloads (+48–56%)
  • Fresh URLSearchParams construction and serialization (+25–49% for dense Latin-1 and +4–11% for mixed ASCII/Latin-1)

Across 48 cases and 5,760 samples, eight gains in both comparisons were confirmed after Holm correction, with no statistically significant regressions, including startup controls.

Reuse precomputed escapes for Latin-1 characters instead of joining
two byte escapes on every occurrence. This reduces repeated work
when querystring and URLSearchParams serialize these characters.

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

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. querystring Issues and PRs related to the built-in querystring module. labels Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (dd7235c) to head (479d4b7).
⚠️ Report is 326 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66756      +/-   ##
==========================================
+ Coverage   90.48%   90.67%   +0.18%     
==========================================
  Files         791      797       +6     
  Lines      277204   278797    +1593     
  Branches    53311    53630     +319     
==========================================
+ Hits       250841   252791    +1950     
+ Misses      16760    16371     -389     
- Partials     9603     9635      +32     
Files with missing lines Coverage Δ
lib/internal/querystring.js 100.00% <100.00%> (ø)

... and 151 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 benchmark/url/percent-encode.js Resolved
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla
rozzilla requested a review from mcollina October 29, 2026 13:46

@mcollina mcollina 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

@mcollina mcollina added 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 29, 2026
@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 29, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@inoway46 inoway46 added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 1, 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 Nov 1, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@gurgunday gurgunday added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 5, 2026

@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 commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 5, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 544340a into nodejs:main Nov 5, 2026
77 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 544340a

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 5, 2026
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
Reuse precomputed escapes for Latin-1 characters instead of joining
two byte escapes on every occurrence. This reduces repeated work
when querystring and URLSearchParams serialize these characters.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: #66756
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. querystring Issues and PRs related to the built-in querystring module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants