You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I compared dutree to my usual go-to solution of du -h -d3 | sort -h on my src directory, and it is much slower.
This is on macOS, and this is after having run these a few times to warm up caches.
I suspect the reason for this is that you're doing too many syscalls; the code seems to use Path to refer to files in many places, and then does various tests on those paths, which mean extra system calls to query the same information multiple times. I would recommend instead passing around DirEntry, from which many attributes can be queried without extra system calls, or even better using the walkdir crate which is a pretty well optimized directory walker that provides its own slightly richer DirEntry that caches additional metadata.
$ time sh -c 'du -h -d3 | gsort -h'
...
real 0m36.430s
user 0m1.801s
sys 0m14.163s
$ time dutree --aggr=100m -d3
...
163.37 real 11.67 user 104.74 sys
The text was updated successfully, but these errors were encountered:
Thanks for your suggestions, they make sense. That being said, I don't think you can exactly compare both programs, since dutree needs to do other things such as order the results recursively. print the tree and color the output according to the file extension.
Another good improvement would be to actually use pointers for the tree structure.
dutree is horribly slow in comparison to anything else frankly. Even a full blown GNOME graphical tool is faster (baobob). ncdu rips through the directory. I simply gave up on dutree ever returning anything useful for anything more than a trivial directory. I'm running this against an SD card with horrible access times so the OP seems to be spot on with his deductions. That or your algos are quadratic.
I compared
dutree
to my usual go-to solution ofdu -h -d3 | sort -h
on mysrc
directory, and it is much slower.This is on macOS, and this is after having run these a few times to warm up caches.
I suspect the reason for this is that you're doing too many syscalls; the code seems to use
Path
to refer to files in many places, and then does various tests on those paths, which mean extra system calls to query the same information multiple times. I would recommend instead passing aroundDirEntry
, from which many attributes can be queried without extra system calls, or even better using thewalkdir
crate which is a pretty well optimized directory walker that provides its own slightly richerDirEntry
that caches additional metadata.The text was updated successfully, but these errors were encountered: