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

make it faster #3

Open
stevekm opened this issue Aug 13, 2022 · 5 comments
Open

make it faster #3

stevekm opened this issue Aug 13, 2022 · 5 comments

Comments

@stevekm
Copy link
Owner

stevekm commented Aug 13, 2022

using regular du -shc * on a home dir with 17957 files (87GB) takes 0.8s but duh takes 20s

figure out how to make it faster

@stevekm
Copy link
Owner Author

stevekm commented Aug 13, 2022

refactor to use filepath.WalkDir (dca9bf4) only reduced execution time by about 3s on aforementioned home dir

need to do profiling and more investigation

@stevekm
Copy link
Owner Author

stevekm commented Aug 15, 2022

I think this must have something to do with the way that Golang does filesystem walking because in the profile, pretty much all the execution time is taken up by "syscall" entries, even after using filepath.WalkDir which supposedly reduces syscalls

@stevekm
Copy link
Owner Author

stevekm commented Aug 16, 2022

I think we don't need the nested DirSize call, we can probably make it faster like this;

https://go.dev/play/p/rReTZJ7o_-f

also more investigation shows that the act of retrieving file sizes in itself increases execution time by ~4x on MacBook Pro NVMe SSD so maybe even more on HDD

also consider parallel file size stat calls using something like os.ReadDir which does not recurse

@stevekm
Copy link
Owner Author

stevekm commented Aug 26, 2022

The new refactored SubDirSizes method in the latest master has brought execution time for duh much closer to du. In latest test, a home dir of ~150GB (849621 files) took du -shc ~ 32.765s, while duh took 46.614s

@stevekm stevekm closed this as completed Aug 26, 2022
@stevekm
Copy link
Owner Author

stevekm commented Aug 29, 2022

I tested the latest release 1.2.1 on an instance of WSL2 on Windows 10 and it was still 1/10th the speed of du -sh so I am gonna try to look into this more

@stevekm stevekm reopened this Aug 29, 2022
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

1 participant