deno
deno copied to clipboard
perf(node/fs): speedup fs.readdir + async
trafficstars
Whilst working on Node compat issues I noticed that we could make the family of readdir* functions a lot faster
- Avoid shape transition when
withFileTypesoption is used - Add fast path for usages without
withFileTypesto skip allocations on both the JS and Rust side - Call ops directly instead of layering on top of
Deno.*JS APIs.
| Benchmark | main (iter/s) | PR (iter/s) |
|---|---|---|
| fs.readdir | 1,141.0 | 2,287.8 |
| fs.readdirSync | 1,434.9 | 2,406.8 |
| fs.readdir + withFileTypes | 1,101.0 | 1,407.2 |
| fs.readdirSync + withFileTypes | 1,372.8 | 1,481.9 |
I've removed the old dirent tests because they were constructing Dirent instances directly which is disallowed in node types. Instead, I've ported those tests to two actual readdir ones that assert based on the actual result.
@marvinhagemeister is this something we can land?
closing because old