Skip to content

querystring: precompute Latin-1 escapes - #66756

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:querystring-precompute-latin1-escapes
Open

rozzilla wants to merge 1 commit 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.50%. Comparing base (dd7235c) to head (bcfe0f4).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66756      +/-   ##
==========================================
+ Coverage   90.48%   90.50%   +0.01%     
==========================================
  Files         791      797       +6     
  Lines      277204   277509     +305     
  Branches    53311    53323      +12     
==========================================
+ Hits       250841   251165     +324     
+ Misses      16760    16750      -10     
+ Partials     9603     9594       -9     
Files with missing lines Coverage Δ
lib/internal/querystring.js 100.00% <100.00%> (ø)

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

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. querystring Issues and PRs related to the built-in querystring module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants