-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: optimize fs.cpSync
js calls
#53614
Conversation
02e0883
to
d7d4ae8
Compare
bebf131
to
2d5fb50
Compare
cc @nodejs/tsc @nodejs/fs appreciate your input on which path to take. previous pr:
this pr:
|
2d5fb50
to
6a216bd
Compare
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
6a216bd
to
371d7a7
Compare
Windows compilation is failing:
|
@nodejs/platform-windows any idea why this build is failing? |
Building locally, I got this:
|
This is also in the log from the CI. Based on the error message, this looks very similar to what we had in #53600 because std::filesystem::path::value_type is different on POSIX and Windows. |
371d7a7
to
e2c27ae
Compare
This comment was marked as outdated.
This comment was marked as outdated.
It seems I forgot a |
e2c27ae
to
a590e84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
Landed in 88027e8 |
PR-URL: #53614 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #53614 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
? std::filesystem::symlink_status(src_path, error_code) | ||
: std::filesystem::status(src_path, error_code); | ||
if (error_code) { | ||
return env->ThrowUVException(EEXIST, "lstat", nullptr, src.out()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong, the error code should be properly translated instead of being directly mapped to EEXIST, there are many other reasons why this could fail.
ToNamespacedPath(env, &src); | ||
THROW_IF_INSUFFICIENT_PERMISSIONS( | ||
env, permission::PermissionScope::kFileSystemRead, src.ToStringView()); | ||
auto src_path = std::filesystem::path(src.ToStringView()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BufferValue
converts the string to UTF8, on Windows this requires automatic conversion for char8_t to work which may not be supported by the version of MSVC we use, I think that may be the source of bugs like #54476
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no, this is simply broken on Windows, because this just gets returned in char. It needs to be returned as std::u8string/std::u8string_view instead.
#53612 is required to do a benchmark
A different approach to #53541
cc @nodejs/performance @nodejs/cpp-reviewers @billywhizz @jasnell @nodejs/fs
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1573/
Small win on happy path, and probably high win on error path: