fs: improve error performance of writevSync#50038
fs: improve error performance of writevSync#50038nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
|
Feel free to suggest improvements in the benchmark file |
|
Afaik in c++ returning a value is slower than modifying a variable passed as parameter (by ref). |
benchmark/fs/bench-writevSync.js
Outdated
| fs.writeFileSync(path, 'Some content.'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| type: ['valid'], |
There was a problem hiding this comment.
Please add an invalid type to benchmarks
There was a problem hiding this comment.
@anonrig I would appreciate help creating a good bench script for my first PR 🙏
src/node_file.cc
Outdated
| } else { // writeBuffers(fd, chunks, pos, undefined, ctx) | ||
| CHECK_EQ(argc, 5); | ||
| } else { | ||
| FSReqWrapSync req_wrap_sync; |
benchmark/fs/bench-writevSync.js
Outdated
| bench.start(); | ||
| for (let i = 0; i < n; i++) { | ||
| try { | ||
| fs.writevSync(fd, [buffer]); |
There was a problem hiding this comment.
In order to remove dead code elimination store the result of this operation and assert it when the benchmark finishes.
|
Did you swap the old and new node binary parameters when comparing the benchmarks or is that actually a 58% performance regression? |
c522003 to
1f60944
Compare
|
FWIW the changes currently result in: I'm guessing this should instead be more about improving the error case? |
1f60944 to
3c2e4ad
Compare
benchmark/fs/bench-writevSync.js
Outdated
|
|
||
| bench.start(); | ||
| for (let i = 0; i < n; i++) { | ||
| try { |
There was a problem hiding this comment.
We don't need a try/catch on valid part
benchmark/fs/bench-writevSync.js
Outdated
| fs.closeSync(fd); | ||
| break; | ||
| case 'invalid': | ||
| fd = tmpdir.resolve(`.non-existing-file-${process.pid}`); |
There was a problem hiding this comment.
This is not a file descriptor. The variable name suggests fd
3c2e4ad to
2a2ca8b
Compare
2a2ca8b to
4babf4d
Compare
|
Landed in bf0f078 |
PR-URL: nodejs#50038 Refs: nodejs/performance#106 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
PR-URL: #50038 Refs: nodejs/performance#106 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
PR-URL: nodejs#50038 Refs: nodejs/performance#106 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Local benchmark:
Ref: nodejs/performance#106