r/rust • • 5d ago

A cargo fork that attempts to solve disk usage

I bumped into this interesting cargo fork -- has anyone used it? https://huacnlee.github.io/cargo/why/

It's apparently by the guy who built https://gpui-kit.com/

I wonder why this issue is not more upfront and center nowadays as I see many complaining about it.

0 Upvotes

11 comments sorted by

12

u/avsaase 5d ago edited 5d ago

It's not clear to me what this does differently than kache which wraps rustc.

2

u/Knochenhauer-Puuh 4d ago

handling it at the cargo level probably lets it clean up intermediate build artifacts that a simple rustc wrapper cant see

2

u/cheese_karate 5d ago

Kache works great for me! Upvote! 

7

u/Proximyst 5d ago

We had a post just yesterday by the very same guy who forked cargo, complaining about the cargo cache sizes. The same posts have been happening and inspiring discussions for years. It does feel like it is pretty front-and-center of an issue in this community/sub, at least. What else would you expect?

5

u/xd009642 cargo-tarpaulin 5d ago

> why this issue is not more upfront and center nowadays

The Rust project has a lot of people working in a lot of areas often on a volunteer basis (so based on their own interests). But there is a project goal looking for funding on this so there should be progress coming https://goals.rust-lang.org/2026/target-dir-size.html

1

u/bitemyapp 5d ago

41.7 GiB? That's it?

Anyway, anyone interested in this issue might want to look at this fork of buck2 I've been experimenting with for my Linux distribution and desktop environment built in Rust: http://github.com/bitemyapp/shikka

1

u/tanmaynargas2901 4d ago

Read through their page. A decent chunk of the first-build win is just deps not carrying debug info, and you can get that on stock cargo today:

[profile.dev.package."*"]
debug = false

The shared deps across worktrees part is the more interesting bit. A shared CARGO_TARGET_DIR kind of does it already, but then worktrees block on each other's build lock and nothing ever gets evicted.

The size cap with day-old eviction is what I'd actually want upstream.

What would stop me installing it: it replaces ~/.cargo/bin/cargo and silently self-updates once a day by default. For the thing that runs every build.rs on my machine I'd want that off (CARGO_FORK_AUTO_UPDATE=0) or pinned.

2

u/Zhuk-Max 3d ago

Same lever matters on CI, where "buy more disk" isn't an option. A hosted GitHub runner starts with about 14 GB free, and my workspace has 140-odd integration test files, each one its own binary, each statically linking sqlx, actix and two crypto libraries. The first time it ran out it didn't even say "disk full": `ld` died with a bus error, which is what a truncated mmap on a full disk looks like.

What got it back under the limit:

- `CARGO_PROFILE_TEST_DEBUG=line-tables-only` in the job env. Panic backtraces still have file and line, the rest of the debug info is gone.

- `cargo test -j 2`. Linking is the peak for both disk and memory, and one job per core is what tipped it over.

- deleting the toolchains the runner image ships with and I never use (.NET, Android SDK, GHC, CodeQL), about 20 GB, with plain `rm` before the build.

-14

u/_filmil_ 5d ago

Disk is dirt cheap. Buy more disk, and done.

4

u/SkiFire13 5d ago

Disk is no longer that cheap. And even if it was cheap, more efficient disk usage also means faster compile times due to less time wasted reading/writing to disk and more efficient OS page caching.

1

u/cheese_karate 5d ago

Disk was dirt cheap, but yes, it's a good choice.