The actual binary sizes are fine - even with embedded devices that have <1MB of program space, there doesn't seem to be much bloat. But I need to remember to clean every project when I finish working on it, because otherwise the build folders will eat 100s-1000s of megabytes each on a 16-32GB partition.
I really appreciate Rust's inclusive approach to learning and teaching, but I can't justify using it for education on ultra-affordable machines for that reason. People often scatter one-off projects all over the place as they learn, and when they run out of space it takes a long time to clean everything up.
So I would also be very in favor of some sort of simple shared package cache.
cargo build --target-dir ~/build-artifacts/$(basename $(pwd))
Then you can have something like this in your ~/.config/user-tmpfiles.d/clean_build.conf d /home/user/build-artifacts - - - 1d -
You can then do cleanup by calling systemd-tmpfiles --user
Or you can use the tmpfiles timer systemctl enable --user --now systemd-tmpfiles-clean.timer [build]
target-dir = "/home/user/build-artifacts"
But I don't know if the different projects will trample each other that way. If that's the case you could just go with a .cargo/config per-project targeting a subdirectory of the build-artifacts directory.I agree though. I don't mind binary sizes in the single megabytes for a release build, and I don't mind clean/rebuild build times that are a few dozen seconds. I do mind the 500MB of build artifacts in a single target directory, multiplied by all the projects I have that share the same version of serde/winapi/syn/quote/insert-common-dependency-here.
In the context of resource-constrained machines, one can always host it remotely on S3. (or mount an NFS share as the CARGO_TARGET_DIR, if you’re feeling adventurous or want fast CI)
NB: it works a bit better on not-Mac because staticlibs are deterministic.
I see a lot of difference between my i5 laptop and i9 desktop.
On upgrading from an OC i5-4670k to a r9-3900x, my compile times for a clean release build went from 20 minutes to 2.
It seems nalgebra is the culprit here: because Rust doesn’t yet support const generics, it has to use some hacky type-level metaprogramming to represent numbers, and that will definitely destroy build times.
The original code, after being migrated to an up to date version of Gtkmm, takes a couple of seconds with GCC 7, not more than one minute if at all.
The big difference? I don't need to compile from scratch all the 3rd party dependencies.
With every release from Rust I do a clean build to assert how much it has improved.
It was much worse, so congrats on the work achieved thus far, but it is still a pain to set up a project from scratch.
Cargo needs to do better with shared caches (so you compile each dep at most once per machine) or ability to get precompiled crates (so you don't even compile it).
Incremental improvements of compiler speed or trimming of individual dependencies won't bring the 10x improvement it needs.