Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dutree is slow compared to du #18

Open
lambda opened this issue Dec 21, 2018 · 2 comments
Open

dutree is slow compared to du #18

lambda opened this issue Dec 21, 2018 · 2 comments

Comments

@lambda
Copy link
Contributor

lambda commented Dec 21, 2018

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
@nachoparker
Copy link
Owner

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.

@lypanov
Copy link

lypanov commented Feb 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants