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

cargo-cache reports wrongly disk usage #75

Open
tesuji opened this issue Oct 28, 2019 · 5 comments
Open

cargo-cache reports wrongly disk usage #75

tesuji opened this issue Oct 28, 2019 · 5 comments

Comments

@tesuji
Copy link

tesuji commented Oct 28, 2019

cargo-cache reports wrongly disk usage

% ls -l /home/lzutao/.cargo/bin
total 74M
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 cargo*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 cargo-clippy*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 cargo-fmt*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 cargo-miri*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 clippy-driver*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rls*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rustc*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rustdoc*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rustfmt*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rust-gdb*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rust-lldb*
-rwxr-xr-x 12 lzutao lzutao 6.2M Oct 28 10:10 rustup*
% du -sch /home/lzutao/.cargo/bin
6.2M    /home/lzutao/.cargo/bin
6.2M    total
% cargo-cache 
Cargo cache '/home/lzutao/.cargo':

Total:                            987.55 MB
  12 installed binaries:           77.55 MB
  Registry:                       874.45 MB
    Registry index:               133.50 MB
    1411 crate archives:          169.27 MB
    867 crate source checkouts:   571.68 MB
  Git db:                          35.56 MB
    4 bare git repos:              35.56 MB
    0 git repo checkouts:              0  B

Meta

  • cargo-cache 0.3.3 (813ad5b 2019-10-22)
@matthiaskrgr
Copy link
Owner

Can't look in detail right now but I'm wondering if the difference is related to symlinks.

@tesuji
Copy link
Author

tesuji commented Oct 28, 2019

Yes, rustup hard-links those binaries shim like cargo, rustc.

@slonik-az
Copy link

As of cargo-cache version 0.5.1 the ~/.cargo/bin disk usage reported on MacOS is still incorrect. The reason seams to be that many toolchain binaries are hard-links of the same executable while cargo-cache counts their sizes separately.

$ cargo cache
Cargo cache '/Users/foobar/.cargo':

Total:                          106.62 MB
  14 installed binaries:        106.61 MB
  Registry:                          0  B
    0 registry indices:              0  B
    0 crate archives:                0  B
    0 crate source checkouts:        0  B
  Git db:                         9.53 KB
    2 bare git repos:             3.24 KB
    1 git repo checkouts:         6.29 KB

while the actual disk usage is 5 times smaller

$ du -hS ~/.cargo/bin
22M	/Users/foobar/.cargo/bin

@matthiaskrgr
Copy link
Owner

I added a quick filter to ignore symlinks when counting sizes in the dont_count_symlinks branch.
https://github.com/matthiaskrgr/cargo-cache/tree/dont_count_symlinks
does this work better for you?

@heftig
Copy link

heftig commented Oct 7, 2021

Although ignoring symlinks isn't wrong, it wouldn't help in this case. The files aren't symlinks, they're hardlinked (see the 12 link count in the original listing).

You need maintain a set of the (dev, ino) of files you've already seen and ignore any file with the same metadata.

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

4 participants