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.
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
|
Landed in 88027e8 |
PR-URL: #53614 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #53614 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
| ? 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.
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.
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.
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: