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 fchownSync #49920

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

Conversation

evelez7
Copy link

@evelez7 evelez7 commented Sep 28, 2023

Credit to @CanadaHonk for the benchmark using file descriptors.

fs/bench-fchownSync.js n=1000 type='existing'                    -4.45 %      ±10.42% ±13.91% ±18.21%
fs/bench-fchownSync.js n=1000 type='non-existing'        ***    107.40 %       ±5.36%  ±7.19%  ±9.48%

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++. 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 Sep 28, 2023
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 28, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 28, 2023
@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the performance Issues and PRs related to the performance of Node.js. label Sep 28, 2023
@evelez7
Copy link
Author

evelez7 commented Sep 29, 2023

Fixed error by moving validation back to fs.js and corrected types in node_file.cc.

@anonrig
Copy link
Member

anonrig commented Sep 30, 2023

Hey @evelez7, can you handle the conflicts? You'll see that sync.js file is removed on main branch.

@anonrig
Copy link
Member

anonrig commented Sep 30, 2023

@evelez7 Your changes include the fs/sync.js file. Can you remove it?

@evelez7
Copy link
Author

evelez7 commented Sep 30, 2023

@evelez7 Your changes include the fs/sync.js file. Can you remove it?

Sorry about that, thought it was removed in the rebase.

try {
return fs.openSync(x, 'r');
} catch {
return 1 << 30;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this only be part of the non-existing case?

int err = uv_fs_fchown(nullptr, &req, fd, uid, gid, nullptr);
FS_SYNC_TRACE_END(fchown);
if (err < 0) {
return env->ThrowUVException(err, "fchown");
Copy link
Member

@joyeecheung joyeecheung Oct 6, 2023

Choose a reason for hiding this comment

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

This does not need a new binding, it can just be done by switching SyncCall to SyncCallAndThrowOnError in the original FChownSync implementation.

@aduh95
Copy link
Contributor

aduh95 commented May 11, 2024

This needs a rebase.

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++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants