Uh oh!
There was an error while loading. Please reload this page.
fs: improve error performance for fsyncSync - #49880
Conversation
fsyncSyncfsyncSyncUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Nit: If you moved this function to c++, it would improve the happy path (existing file)
There was a problem hiding this comment.
That's a good opinion!
I think you just need to add CHECK_GE(fd,0) to C++.
Do you have a better idea?
There was a problem hiding this comment.
We need to replicate the behavior of getValidatedFd in C++ and throw the correct error.
const getValidatedFd = hideStackFrames((fd, propName = 'fd') => {
if (ObjectIs(fd, -0)) {
return 0;
}
validateInt32(fd, propName, 0);
return fd;
});
There was a problem hiding this comment.
I added the implementation in C++.
I'm not sure if this implementation is correct.
also I updated the benchmark.
When I check it locally, the performance is strange.
Please review again.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e1ebe02 to
c710f94Compare764386f to
ad76d06CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Sep 27, 2023
joyeecheung
left a comment
There was a problem hiding this comment.
I think the diff can be a lot simpler if you just change the sync branch of the original implementations instead of repeating the code in a new binding..(and if you only introduce new bindings, the original sync branch would be dead code..) also I think this breaks --trace-sync-io?
anonrig
commented
Sep 30, 2023
Hey @pluris can you rebase this pull request? You'll see that |
| inline int GetValidatedFd(Environment* env, Local<Value> value) { | ||
| if (!value->IsInt32()) { | ||
| env->isolate()->ThrowException(ERR_INVALID_ARG_TYPE( |
There was a problem hiding this comment.
I think this should be a ValidateInt32 if we want to start moving the validation to C++. Also this is not entirely on-par with the original implementation - the original implementation would print the value in a readable format in the case it's not a number, and this does not give any information about the invalid argument, which would make it harder for users to fix the error. We could also just don't move the error validation code now and leave it in JS if it's not ready to take on implementing proper argument validation + printing in C++.
There was a problem hiding this comment.
@joyeecheung Thank you for your comment.
You are right. As you said, I think we need to think more about the implementation of GetValidateFd(). First, I will remove this addition to C++ and change it to the original implementation.
cfd9354 to
fcffde8CompareUh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Oct 4, 2023
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
nodejs-github-bot
commented
Oct 4, 2023
nodejs-github-bot
commented
Oct 9, 2023
nodejs-github-bot
commented
Oct 12, 2023
nodejs-github-bot
commented
Oct 20, 2023
Landed in fbd08ec |
PR-URL: #49880 Refs: nodejs/performance#106 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #49880 Refs: nodejs/performance#106 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Refs: nodejs/performance#106