-
Notifications
You must be signed in to change notification settings - Fork 129
Fix: Directories themselves do not contribute to size like they do in du #284
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
Fix: Directories themselves do not contribute to size like they do in du #284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for making this happen, it's much appreciated. I also love the PR description!
Do you think you could add a journey test that observes that directories now have a size?
Also, I wonder what adding another u128 to the structure does to its size. I am seeing the case where there are millions of files. Probably it doesn't matter as things like name
will be responsible for most of the memory usage, but it would be good to have something like assert_eq!(std::mem::size_of::<EntryData>(), X, "this shouldn't change unnoticed")
somewhere in the test-suite.
This is a dialogue and not a request, hence I am truly interested in what you think, and it would certainly be fine to merge as is otherwise.
Edit: I just realized that CI is already failing because of it:
Maybe we can give it a try and see what would happen if this was a boolean instead? |
Thanks for taking a look. Yes, on reflection I agree it makes sense to be cautious about adding that extra field to the Alternative 1 - Still try to add directory inode size in
|
That's great, if you prefer option 2 I will happily go with that. There might be an option 3, which is to real-world test the impact of the added 16 bytes. As option 2 will add complexity, I think we should benchmark the memory usage first, and then see what by what percentage the consumption rises. Also, please feel free to push these changes here right away, preferably in their own commit, then it's more straightforward to keep this endeavour in one place. |
2fc1953
to
be5a4f6
Compare
Sorry, I may have just pushed my changes onto yours with the adjustments of numbers, but I am done now. |
Thank you - once the numbers for Windows are adjusted, could you please squash the commits down into one? |
Cool thank you. To me these updated tests capture the fact that directories now have size, so no new journey test is needed. Do you agree? |
7004bd9
to
2966e82
Compare
2966e82
to
a93b28e
Compare
Fixed and squashed - hopefully good to go now. Cheers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, thank you!
And here is the new release: https://github.com/Byron/dua-cli/releases/tag/v2.30.1 . |
Hi! This closes #262 where directory inode sizes are mistakenly being excluded from total disk usage calculations. This PR brings the behaviour of
dua
in line with that ofdu
in both aggregate (f44e19d
) and interactive (ef1833a
) modes.For example, given a directory tree structured as followed
dua currently outputs


With these changes:
Some notes on the changes made:
!m.is_dir()
condition when traversing, as directory metadata can be handled just the same as non-directory file metadataown_size
field to theEntryData
struct, which stores the size just of the directory entry itself. Then, when updating our tree ofEntryData
nodes (in theset_entry_info_or_panic
function), we simply addown_size
to the total size of the directory's contents, which is computed just as before.du
, all directories are reported as consuming up a full block on disk regardless of whether reporting apparent size or disk usage.