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

fs: improve error performance of opendirSync #49705

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Sep 18, 2023

fs/bench-opendirSync.js n=10000 bufferSize=128 type='existing'                    -0.15 %       ±1.56%  ±2.08%  ±2.71%
fs/bench-opendirSync.js n=10000 bufferSize=128 type='non-existing'        ***    109.56 %       ±3.93%  ±5.23%  ±6.81%
fs/bench-opendirSync.js n=10000 bufferSize=32 type='existing'                     -0.34 %       ±1.95%  ±2.60%  ±3.39%
fs/bench-opendirSync.js n=10000 bufferSize=32 type='non-existing'         ***    111.68 %       ±3.03%  ±4.03%  ±5.25%
fs/bench-opendirSync.js n=10000 bufferSize=4 type='existing'                      -1.19 %       ±1.44%  ±1.92%  ±2.51%
fs/bench-opendirSync.js n=10000 bufferSize=4 type='non-existing'          ***    104.85 %       ±8.18% ±11.01% ±14.59%

Ref: nodejs/performance#106

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Sep 18, 2023
@anonrig anonrig added performance Issues and PRs related to the performance of Node.js. needs-benchmark-ci PR that need a benchmark CI run. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 18, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 18, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

benchmark/fs/bench-opendirSync.js Outdated Show resolved Hide resolved
benchmark/fs/bench-opendirSync.js Outdated Show resolved Hide resolved
@anonrig anonrig added review wanted PRs that need reviews. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 19, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 19, 2023
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Could we improve error handling in JS in general before we move all of this into C++? I believe there's likely not a big difference anymore as soon as that's fixed.

@anonrig
Copy link
Member Author

anonrig commented Sep 19, 2023

Could we improve error handling in JS in general before we move all of this into C++? I believe there's likely not a big difference anymore as soon as that's fixed.

@BridgeAR There is also the cost of crossing the C++ and JavaScript boundary that'll still be there even after we improve the error creation performance.

@nodejs-github-bot
Copy link
Collaborator

@anonrig
Copy link
Member Author

anonrig commented Sep 20, 2023

cc @nodejs/cpp-reviewers can you review?

@joyeecheung
Copy link
Member

joyeecheung commented Sep 20, 2023

Could we improve error handling in JS in general before we move all of this into C++?

For the simple FS errors I think it would probably be pretty hard to make the JS error creation performance on-par with the C++ one if we want to hide internal frames. If we throw from C++, we hide them for free, the stack is only going to be captured when the user access error.stack, if they don't need it there's no cost paid. If we have to throw from JS, we need to capture the stack trace eagerly to hide internal frames. And not having to capture the stack trace is always going to be faster than having to do that.

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Sep 20, 2023
@targos
Copy link
Member

targos commented Sep 21, 2023

Shouldn't openDir (the C++ one) be also updated to remove the sync code now that it's in another function?

@anonrig
Copy link
Member Author

anonrig commented Sep 21, 2023

Shouldn't openDir (the C++ one) be also updated to remove the sync code now that it's in another function?

@targos OpenDir is still used with callback implementation. After working on Sync functions, I'll move to callback implementations and make OpenDir like functions to only handle promise implementations.

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 21, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 21, 2023
@nodejs-github-bot nodejs-github-bot merged commit 571ecbf into nodejs:main Sep 21, 2023
36 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 571ecbf

@RafaelGSS
Copy link
Member

I see the needs-benchmark-ci label, but I don't see any benchmark ci. Just a possible local benchmarks in the PR description.

@anonrig
Copy link
Member Author

anonrig commented Sep 21, 2023

@RafaelGSS I didn't follow up with the label I've added. I don't think it's necessary for this pull request since it's highly unlikely to cause regression.

@RafaelGSS
Copy link
Member

But would be great to have actual reliable numbers to share. People might see this PR when scrolling the CHANGELOG.

ruyadorno pushed a commit that referenced this pull request Sep 28, 2023
PR-URL: #49705
Refs: nodejs/performance#106
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
This was referenced Sep 28, 2023
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
PR-URL: nodejs#49705
Refs: nodejs/performance#106
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
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++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. fs Issues and PRs related to the fs subsystem / file system. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js. review wanted PRs that need reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants