René's URL Explorer Experiment


Title: `new URLSearchParams(string)` is quadratic when the pairs have no `=` · Issue #67652 · nodejs/node · GitHub

Open Graph Title: `new URLSearchParams(string)` is quadratic when the pairs have no `=` · Issue #67652 · nodejs/node

X Title: `new URLSearchParams(string)` is quadratic when the pairs have no `=` · Issue #67652 · nodejs/node

Description: Version v26.13.1. The same line is in lib/internal/url.js on main, v26.x and v24.x. It is not in v22.x or v20.x. Platform Darwin 25.6.0 arm64 (macOS, Apple silicon) Subsystem url What steps will reproduce the bug? node -e 'const t = perf...

Open Graph Description: Version v26.13.1. The same line is in lib/internal/url.js on main, v26.x and v24.x. It is not in v22.x or v20.x. Platform Darwin 25.6.0 arm64 (macOS, Apple silicon) Subsystem url What steps will re...

X Description: Version v26.13.1. The same line is in lib/internal/url.js on main, v26.x and v24.x. It is not in v22.x or v20.x. Platform Darwin 25.6.0 arm64 (macOS, Apple silicon) Subsystem url What steps will re...

Opengraph URL: https://github.com/nodejs/node/issues/67652

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`new URLSearchParams(string)` is quadratic when the pairs have no `=`","articleBody":"### Version\n\nv26.13.1. The same line is in `lib/internal/url.js` on `main`, `v26.x` and `v24.x`. It is not in `v22.x` or `v20.x`.\n\n### Platform\n\n```text\nDarwin 25.6.0 arm64 (macOS, Apple silicon)\n```\n\n### Subsystem\n\nurl\n\n### What steps will reproduce the bug?\n\n```sh\nnode -e 'const t = performance.now(); new URLSearchParams(\"a&\".repeat(262144)); console.log(performance.now() - t)'\n```\n\nThat is a 512 KB string. It takes about 1.6 s. The same number of pairs written `a=b&` takes 7.5 ms.\n\nA fuller script, median of 5 runs per cell, times in ms:\n\n```js\nimport querystring from \"node:querystring\";\n\nconst median = (run) => {\n  const times = [];\n  for (let round = 0; round \u003c 5; round += 1) {\n    const started = performance.now();\n    run();\n    times.push(performance.now() - started);\n  }\n  return times.sort((a, b) => a - b)[2].toFixed(1);\n};\n\nconsole.log(process.version, process.arch, process.platform);\nconsole.log(\"pairs\\t'a&'\\t'a=&'\\t'a=b&'\\t'&'\\tqs.parse('a&')\");\nfor (const pairs of [16_384, 32_768, 65_536, 131_072, 262_144]) {\n  console.log(\n    [\n      pairs,\n      median(() => new URLSearchParams(\"a&\".repeat(pairs))),\n      median(() => new URLSearchParams(\"a=&\".repeat(pairs))),\n      median(() => new URLSearchParams(\"a=b&\".repeat(pairs))),\n      median(() => new URLSearchParams(\"&\".repeat(pairs))),\n      median(() => querystring.parse(\"a&\".repeat(pairs), \"&\", \"=\", { maxKeys: 0 })),\n    ].join(\"\\t\")\n  );\n}\n```\n\nOutput on v26.13.1, arm64, darwin:\n\n| pairs | `a&` | `a=&` | `a=b&` | `&` | `querystring.parse` of `a&` |\n| ---: | ---: | ---: | ---: | ---: | ---: |\n| 16,384 | 6.6 | 0.6 | 0.5 | 0.2 | 1.2 |\n| 32,768 | 24.7 | 1.8 | 1.1 | 0.5 | 2.2 |\n| 65,536 | 98.0 | 2.1 | 1.9 | 0.9 | 1.7 |\n| 131,072 | 428.8 | 3.7 | 3.6 | 1.7 | 3.1 |\n| 262,144 | 1631.3 | 7.3 | 7.5 | 3.4 | 6.1 |\n\nOnly the `a&` column grows fourfold when the input doubles.\n\nThe same cost is reachable from a request body, because `formData()` parses an urlencoded body with `URLSearchParams`:\n\n```js\nconst body = \"a&\".repeat(262144);\nconst started = performance.now();\nawait new Request(\"http://localhost/\", {\n  method: \"POST\",\n  headers: { \"content-type\": \"application/x-www-form-urlencoded\" },\n  body,\n}).formData();\nconsole.log(performance.now() - started); // 1552 ms; 21 ms for \"a=b&\".repeat(262144)\n```\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time. The condition is a long run of pairs with no `=` after them in the string. One `=` at the very end does not help: `\"a&\".repeat(262144) + \"a=b\"` takes the same time.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nTime linear in the length of the string, as for `a=&`, `a=b&` and `querystring.parse`. v22 and v20 do not have this loop.\n\n### What do you see instead?\n\nQuadratic time. The parse is synchronous, so the event loop is blocked for all of it. A server that calls `request.formData()` on an urlencoded body of a few MB stops answering every other request for minutes. Extrapolating the table, a 21 MB body is about 10.5 million pairs and about 45 minutes. A 21 MB body of `a&` sent to an HTTP server that calls `request.formData()` held the CPU at 99% for over 4 minutes with no answer, and the run was stopped there.\n\n### Additional information\n\nThe cause is in `parseParams` in `lib/internal/url.js`, added by #65363 (\"url: speed up URLSearchParams\", commit 4b3bba58dd):\n\n```js\nwhile (i \u003c len) {\n  let amp = qs.indexOf('&', i);\n  if (amp === -1) {\n    amp = len;\n  }\n  if (amp !== i) {\n    const eq = qs.indexOf('=', i);   // scans to the end of the string when no '=' follows\n    if (eq === -1 || eq > amp) {\n      out.push(encoded ? decodeFormComponent(qs, i, amp) : qs.slice(i, amp), '');\n    } else {\n      ...\n```\n\nFor each pair, `qs.indexOf('=', i)` searches from the pair's start to the next `=` anywhere in the string. When there is none, or it is far away, every pair scans the rest of the string.\n\nKeeping the last `=` position across pairs makes it linear, since a position past the current `&` is still the right answer for the next pair:\n\n```js\nlet eq = -2;\nwhile (i \u003c len) {\n  let amp = qs.indexOf('&', i);\n  if (amp === -1) {\n    amp = len;\n  }\n  if (amp !== i) {\n    if (eq !== -1 && eq \u003c i) {\n      eq = qs.indexOf('=', i);\n    }\n    if (eq === -1 || eq > amp) {\n      ...\n```\n\nI copied the undecoded branch of the loop into a script and timed both versions, median of 5 runs, in ms. The two return the same array for `a&` and `a=b&` repeated 1,000 times, `a&b=c&&d=&=e&f`, 50 pairs of `a&` followed by `x=y`, and the empty string.\n\n| pairs of `a&` | current loop | with the cached `=` |\n| ---: | ---: | ---: |\n| 65,536 | 97.3 | 1.2 |\n| 131,072 | 385.5 | 2.7 |\n| 262,144 | 1554.4 | 5.0 |\n\nI have not run Node's own test suite or benchmarks against that change.\n","author":{"url":"https://github.com/aayushbtw","@type":"Person","name":"aayushbtw"},"datePublished":"2026-11-20T13:07:43Z","url":"https://github.com/nodejs/node/issues/67652"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5b318e9a-b26c-78ac-65b8-a4e37ae90b5a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA64E:AFBD9:BC443F:F92744:6B01C481
html-safe-nonce0f98645a4a3c27c7721d5c32a1ea3709562a5f34c178b668f1c8db85e43af965
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjRFOkFGQkQ5OkJDNDQzRjpGOTI3NDQ6NkIwMUM0ODEiLCJ2aXNpdG9yX2lkIjoiNTI3OTU3MDQ2ODU5MDk2MTc5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac00c9942844ff3e868878e773279d42e3e7a7168f31356f0aa9e1364510fba548
hovercard-subject-tagissue:6512030336
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67652/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1684d0b9c858a561f4faa22af10df8d4487fa988ceafe5294ce1479ac0f8e0a3/nodejs/node/issues/67652
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1684d0b9c858a561f4faa22af10df8d4487fa988ceafe5294ce1479ac0f8e0a3/nodejs/node/issues/67652
og:image:altVersion v26.13.1. The same line is in lib/internal/url.js on main, v26.x and v24.x. It is not in v22.x or v20.x. Platform Darwin 25.6.0 arm64 (macOS, Apple silicon) Subsystem url What steps will re...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameaayushbtw
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/67652#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67652
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67652
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/67652
Reloadhttps://github.com/nodejs/node/issues/67652
Reloadhttps://github.com/nodejs/node/issues/67652
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues637 (637)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67652
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67652
#67653https://github.com/nodejs/node/pull/67653
new URLSearchParams(string) is quadratic when the pairs have no =https://github.com/nodejs/node/issues/67652#top
#67653https://github.com/nodejs/node/pull/67653
https://github.com/aayushbtw
aayushbtwhttps://github.com/aayushbtw
on Nov 20, 2026https://github.com/nodejs/node/issues/67652#issue-6512030336
#65363https://github.com/nodejs/node/pull/65363
4b3bba5https://github.com/nodejs/node/commit/4b3bba58dd64b1b6a3d23cc5690ae90f966a3085
aayushbtwhttps://github.com/aayushbtw
on Nov 20, 2026https://github.com/nodejs/node/issues/67652#event-36772232109
url: keep the next '=' across pairs in parseParamshttps://github.com/aayushbtw/node/commit/bf418cfc1669508ebab6d54095988eaeaf856ac4
bf418cfhttps://github.com/aayushbtw/node/commit/bf418cfc1669508ebab6d54095988eaeaf856ac4
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/67652
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67652
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.