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: refactor pathToFileURL to native #55476

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Oct 20, 2024

As suggested in #54545 (comment), let's see if it's faster.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Oct 20, 2024
@aduh95
Copy link
Contributor Author

aduh95 commented Oct 20, 2024

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

Results
confidence improvement accuracy (*)   (**)  (***)
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null?key=param&bool' method='pathToFileURL'                    ***     26.63 %       ±0.93% ±1.25% ±1.66%
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null?key=param&bool#hash' method='pathToFileURL'               ***     39.81 %       ±0.88% ±1.18% ±1.57%
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null' method='pathToFileURL'                                   ***     29.59 %       ±0.59% ±0.79% ±1.03%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool' method='fileURLToPath'             ***     -1.33 %       ±0.28% ±0.37% ±0.48%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool' method='pathToFileURL'             ***     11.62 %       ±0.29% ±0.38% ±0.50%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool#hash' method='fileURLToPath'        ***     -2.27 %       ±0.38% ±0.50% ±0.66%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool#hash' method='pathToFileURL'        ***     22.66 %       ±0.39% ±0.52% ±0.68%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null' method='fileURLToPath'                            ***     -1.64 %       ±0.30% ±0.40% ±0.52%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null' method='pathToFileURL'                            ***      7.78 %       ±0.57% ±0.76% ±1.01%

lib/internal/url.js Outdated Show resolved Hide resolved
@RedYetiDev RedYetiDev added whatwg-url Issues and PRs related to the WHATWG URL implementation. needs-benchmark-ci PR that need a benchmark CI run. and removed lib / src Issues and PRs related to general changes in the lib or src directory. labels Oct 20, 2024
src/node_url.cc Outdated Show resolved Hide resolved
src/node_url.cc Outdated Show resolved Hide resolved
src/node_url.cc Outdated Show resolved Hide resolved
src/node_url.cc Outdated Show resolved Hide resolved
@anonrig
Copy link
Member

anonrig commented Oct 20, 2024

Amazing work. This will really improve the performance and make a huge impact.

lib/internal/url.js Outdated Show resolved Hide resolved
src/node_url.cc Outdated
@@ -75,6 +75,73 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
CHECK_NOT_NULL(binding);
}

std::string EncodePathChars(const std::string& input_str, bool windows) {
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking nit: Really not a big fan of bool arguments to methods like this. Would prefer an enum.

Copy link
Member

Choose a reason for hiding this comment

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

PS: If you use a template argument you can make isWindows checks a constexpr and eliminate the branch.

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 75.51020% with 12 lines in your changes missing coverage. Please review.

Project coverage is 88.41%. Comparing base (11fbdd8) to head (ba078a0).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
src/node_url.cc 72.50% 1 Missing and 10 partials ⚠️
lib/internal/url.js 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #55476   +/-   ##
=======================================
  Coverage   88.41%   88.41%           
=======================================
  Files         653      653           
  Lines      187497   187449   -48     
  Branches    36101    36087   -14     
=======================================
- Hits       165767   165734   -33     
+ Misses      14968    14951   -17     
- Partials     6762     6764    +2     
Files with missing lines Coverage Δ
src/node_url.h 100.00% <ø> (ø)
lib/internal/url.js 97.72% <88.88%> (-0.33%) ⬇️
src/node_url.cc 82.54% <72.50%> (-1.69%) ⬇️

... and 44 files with indirect coverage changes

@aduh95
Copy link
Contributor Author

aduh95 commented Oct 21, 2024

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

Results
confidence improvement accuracy (*)   (**)  (***)
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null?key=param&bool' method='pathToFileURL'                    ***     29.14 %       ±0.92% ±1.24% ±1.64%
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null?key=param&bool#hash' method='pathToFileURL'               ***     46.62 %       ±0.25% ±0.34% ±0.44%
url/whatwg-url-to-and-from-path.js n=5000000 input='/dev/null' method='pathToFileURL'                                   ***     29.72 %       ±0.29% ±0.39% ±0.51%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool' method='fileURLToPath'             ***     -0.97 %       ±0.30% ±0.40% ±0.53%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool' method='pathToFileURL'             ***     16.86 %       ±0.42% ±0.57% ±0.75%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool#hash' method='fileURLToPath'                -0.37 %       ±0.45% ±0.59% ±0.77%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null?key=param&bool#hash' method='pathToFileURL'        ***     28.00 %       ±0.32% ±0.42% ±0.55%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null' method='fileURLToPath'                             **     -1.12 %       ±0.76% ±1.01% ±1.33%
url/whatwg-url-to-and-from-path.js n=5000000 input='file:///dev/null' method='pathToFileURL'                            ***     10.49 %       ±0.49% ±0.66% ±0.88%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-benchmark-ci PR that need a benchmark CI run. 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.

5 participants