fs: improve performance of recursive directory read - #65524
Conversation
|
Review requested:
|
|
cc @nodejs/fs |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65524 +/- ##
==========================================
- Coverage 90.06% 90.01% -0.06%
==========================================
Files 751 751
Lines 254919 255226 +307
Branches 48124 48171 +47
==========================================
+ Hits 229603 229748 +145
- Misses 16492 16623 +131
- Partials 8824 8855 +31
🚀 New features to boost your workflow:
|
codebytere
left a comment
There was a problem hiding this comment.
thanks for picking this up! fyi the table in the description is against main before #65487 landed, which already dropped the per-entry stat() and went to one binding call per directory, so most of that delta is gone. against current main (linux x64, means of 5 runs of this PR's benchmark, plus dir=test for a nested tree with 860 dirs / 13k entries) i get:
| main | this PR | |
|---|---|---|
promise, lib |
362 ops/s | 895 (+147 %) |
promise, test |
25.0 | 59.9 (+140 %) |
sync, lib |
850 | 1561 (+84 %) |
sync, test |
57.5 | 65.7 (+14 %) |
sync + withFileTypes, lib |
930 | 801 (−14 %) |
sync + withFileTypes, test |
55.4 | 56.8 (n.s.) |
any mode, test/parallel (flat) |
n.s. |
so the promises path is the clear win (it awaited one thread pool round trip per directory), sync is a modest win, and withFileTypes sync regresses on small trees, which i think is the marshalling (comment below). could you rerun against current main and update the description please?
Fixes: nodejs#58892 Refs: nodejs#52663 Signed-off-by: avivkeller <me@aviv.sh>
Currently, when recursively reading a directory, we do a few things which can be considered slow:
lstatover the JS version.Benchmarks:
Also,
Fixes #58892