Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: improve urlpattern regexp performance #57136

Merged

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Feb 19, 2025

Thanks to @erikcorry's recommendation, we can speed up regexp performance of URLPattern

Benchmarks show no improvement, but I believe that is due to our lack of proper benchmark cases. (we don't have any benchmarks that use *)

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1658

confidence improvement accuracy (*)   (**)  (***)
url/urlpattern-parse.js n=100000 pattern='"[https://(sub.)?example(.com/)foo](https://(sub.)/?example(.com/)foo)"'                                                                  -0.34 %       ±0.57% ±0.76% ±1.01%
url/urlpattern-parse.js n=100000 pattern='{"hostname":"xn--caf-dma.com"}'                                                                *     -0.50 %       ±0.48% ±0.64% ±0.84%
url/urlpattern-parse.js n=100000 pattern='{"pathname":"/([[a-z]--a])"}'                                                                        -0.31 %       ±0.34% ±0.45% ±0.59%
url/urlpattern-parse.js n=100000 pattern='{"pathname":"/foo","search":"bar","hash":"baz","baseURL":"https://example.com:8080/"}'                -0.07 %       ±0.34% ±0.46% ±0.59%
url/urlpattern-test.js n=100000 pattern='"[https://(sub.)?example(.com/)foo](https://(sub.)/?example(.com/)foo)"'                                                             *      0.72 %       ±0.63% ±0.84% ±1.10%
url/urlpattern-test.js n=100000 pattern='{"hostname":"xn--caf-dma.com"}'                                                                       -0.39 %       ±0.89% ±1.20% ±1.58%
url/urlpattern-test.js n=100000 pattern='{"pathname":"/([[a-z]--a])"}'                                                                   *      0.74 %       ±0.59% ±0.78% ±1.02%
url/urlpattern-test.js n=100000 pattern='{"pathname":"/foo","search":"bar","hash":"baz","baseURL":"https://example.com:8080/"}'                  0.20 %       ±0.75% ±0.99% ±1.29%

@anonrig anonrig requested a review from jasnell February 19, 2025 14:08
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Feb 19, 2025
@anonrig anonrig requested a review from mcollina February 19, 2025 14:09
Copy link

codecov bot commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.03%. Comparing base (baa60ce) to head (87d5b72).
Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #57136   +/-   ##
=======================================
  Coverage   89.03%   89.03%           
=======================================
  Files         665      665           
  Lines      193408   193408           
  Branches    37279    37273    -6     
=======================================
+ Hits       172206   172209    +3     
+ Misses      13886    13885    -1     
+ Partials     7316     7314    -2     
Files with missing lines Coverage Δ
src/node_url_pattern.cc 86.61% <100.00%> (+0.92%) ⬆️

... and 28 files with indirect coverage changes

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 19, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 19, 2025
@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. review wanted PRs that need reviews. labels Feb 19, 2025
@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 20, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 21, 2025
@nodejs-github-bot nodejs-github-bot merged commit 9e6a62f into nodejs:main Feb 21, 2025
78 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 9e6a62f

acidiney pushed a commit to acidiney/node that referenced this pull request Feb 23, 2025
PR-URL: nodejs#57136
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
targos pushed a commit that referenced this pull request Feb 24, 2025
PR-URL: #57136
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
targos pushed a commit that referenced this pull request Feb 25, 2025
PR-URL: #57136
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. review wanted PRs that need reviews. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants