solidiquis / erdtree

A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.
https://crates.io/crates/erdtree
MIT License
2.39k stars 64 forks source link

Improve performance when using `--long` #251

Closed TomLonergan03 closed 7 months ago

TomLonergan03 commented 8 months ago

Previously, the unix extended attributes are always read no matter what. This is maybe not ideal, as it is very expensive to call for files which we will not display and leads to significantly (~300x with level = 2) worse runtimes recursing large directories. This is fixed by only calling unix::Attrs::from when it is a file which is going to be displayed.

This is my first PR here, so if I've missed anything please let me know.

Rough benchmarks

These are run with the path being my home directory, which consists of (per erd) 11650 directories, 124225 files, and 132 links. The command run is time erd -l --no-config -L 2 ~ for both cases, and all times are averaged over 5 runs.

Before

Executed in 81.01 secs
usr time 10.83 secs
sys time 15.58 secs

After

Executed in 0.24 secs
usr time 0.56 secs
sys time 0.47 secs
solidiquis commented 7 months ago

Amazing thanks! I'll be sure to include this in v4 which I'm currently working on.