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

path: change posix.join to use array #54331

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Conversation

HBSPS
Copy link
Contributor

@HBSPS HBSPS commented Aug 12, 2024

Change posix.join to use array.join instead of additional assignment.

                                                               confidence improvement accuracy (*)   (**)  (***)
path/join-posix.js n=100000 paths='/foo|bar||baz/asdf|quux|..'        ***      5.95 %       ±1.42% ±1.90% ±2.49%

Change posix.join to use array.join instead of additional assignment.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Aug 12, 2024
joined = arg;
else
joined += `/${arg}`;
path.push(arg);
Copy link
Member

Choose a reason for hiding this comment

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

Does this need a primordial?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I use ArrayPrototypePush, the benchmark result is as follows.

                                                               confidence improvement accuracy (*)   (**)  (***)
path/join-posix.js n=100000 paths='/foo|bar||baz/asdf|quux|..'                 0.20 %       ±0.63% ±0.84% ±1.09%

Copy link
Member

Choose a reason for hiding this comment

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

I think the primordial is needed here, regardless of benchmark results.

CC @nodejs/primordials

Copy link
Member

Choose a reason for hiding this comment

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

Using primordials are not required. If we see a critical performance impact, just like this, we should avoid using it.

Copy link
Member

Choose a reason for hiding this comment

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

How are they not required? This isn't the error path.

What about an alternative:

Suggested change
path.push(arg);
path[path.length - 1] = arg;

Copy link
Member

Choose a reason for hiding this comment

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

primordials are used elsewhere in this function, shouldn't they be used here, or removed from the other spots?

@aduh95 aduh95 added the needs-benchmark-ci PR that need a benchmark CI run. label Aug 12, 2024
@aduh95
Copy link
Contributor

aduh95 commented Aug 12, 2024

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

Results:

                                                               confidence improvement accuracy (*)   (**)  (***)
path/join-posix.js n=100000 paths='/foo|bar||baz/asdf|quux|..'        ***      5.10 %       ±0.85% ±1.14% ±1.48%

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 12, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 12, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.09%. Comparing base (9a4eb21) to head (af3b896).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54331      +/-   ##
==========================================
- Coverage   87.09%   87.09%   -0.01%     
==========================================
  Files         647      647              
  Lines      181849   181849              
  Branches    34891    34885       -6     
==========================================
- Hits       158380   158375       -5     
- Misses      16766    16779      +13     
+ Partials     6703     6695       -8     
Files Coverage Δ
lib/path.js 95.17% <100.00%> (ø)

... and 23 files with indirect coverage changes

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 13, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 14, 2024
@nodejs-github-bot nodejs-github-bot merged commit 6051826 into nodejs:main Aug 14, 2024
68 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 6051826

EarlyRiser42 pushed a commit to EarlyRiser42/node that referenced this pull request Aug 14, 2024
Change posix.join to use array.join instead of additional assignment.

PR-URL: nodejs#54331
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@HBSPS HBSPS deleted the path branch August 15, 2024 13:00
HBSPS added a commit to HBSPS/node that referenced this pull request Aug 15, 2024
Change path.join to use array dynamic allocation instead of push.

Refs: nodejs#54331
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
Change posix.join to use array.join instead of additional assignment.

PR-URL: #54331
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@RafaelGSS RafaelGSS mentioned this pull request Aug 19, 2024
targos pushed a commit that referenced this pull request Sep 21, 2024
Change posix.join to use array.join instead of additional assignment.

PR-URL: #54331
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.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. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants