Add build profile. by ehuss · Pull Request #6577 · rust-lang/cargo (original) (raw)

I have some concerns about this, so I wanted to open this for discussion.

dev/release switching

With this feature, if a dev build is made, and then a release build is made, all of the build artifacts are unnecessarily compiled again because they are in different directories. Some thoughts to work around this:

Extra artifacts

I'm very worried about this causing shared dependencies to now be built multiple times.

Some options:

I've been doing some analysis on crates.io to try to understand the impact.

3187 of 21098 crates have at least one overlapping dependency. gist. crossgen has a whopping 161 crates in common worst case.

I did some tests "without" build profile and "with" build profile with either 12 or 2 concurrency. All times in seconds. These is just a rough idea. I ran each attempt multiple times, but this is particular to my hardware, and running on MacOS.

Package j12 Without j12 With j2 Without j2 With Notes
rand 44.3 40.6 (⨉0.92) 43.0 43.7 (⨉1.01) +0 crates
cargo 81.4 76.6 (⨉0.94) 129.8 129.7 (⨉1.00) +3 crates
ripgrep 27.2 28.1 (⨉1.03) 58.6 62.3 (⨉1.06) +6 crates
gluon 66.5 61.9 (⨉0.93) 112.7 115.2 (⨉1.02) +35 crates
imag 81.4 100.4 (⨉1.23) 231.5 266.4 (⨉1.15) +79 crates

As you can see, sometimes it is a little faster, but usually it is slower (sometimes much slower).

Here's a few more pieces of data that seemed interesting (of 21098 crates):

Default settings

The current defaults may not be the best. Turning off debug improves speed and reduces disk space, but then you lose good backtraces. It's also questionable if it matters if debug-assertions or overflow-checks are off. Setting opt-level=1 had a noticeable increase in compile time on the few projects I tried, so I left it at 0.