-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Don't spend build time optimizing build-time-only crates #8406
Don't spend build time optimizing build-time-only crates #8406
Conversation
Crates used exclusively at build time, such as proc-macro crates and their dependencies, don't benefit substantially from optimization; they take far longer to optimize than time saved when running them during the build. No machine code from these crates will appear in the final compiled binary. Use the new profile-overrides mechanism in Rust 1.41 (https://doc.rust-lang.org/cargo/reference/profiles.html#overrides) to build such crates with opt-level 0. Before: Finished release [optimized] target(s) in 4m 20s After: Finished release [optimized] target(s) in 4m 07s
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 78e7c01 has been approved by |
⌛ Testing commit 78e7c01 with merge a8723de370999bafcaaa8cca43ee0dd3e75dd793... |
☀️ Try build successful - checks-azure |
Ah, I see. I do find this useful for local testing, but I wouldn't want to have rust-lang/rust warn about it. So until Cargo gets a mechanism for ignoring the profile warning (as suggested in the linked issue), feel free to ignore. |
It may be worth exploring whether this makes sense as a heuristic for Cargo in general (rather than just applying it to this repository). I don't know how we'd evaluate such a change beyond checking a few well known projects, though. I'm also not sure how much the 13s win here is meaningful - presumably incremental builds get slowed down by this change? Have you checked the effects there? |
In #6577 I explored changing the defaults for build dependencies. That PR was a little more ambitious, in that it uses the same settings across dev and release. It was sometimes slower and sometimes faster. The big problem is that shared dependencies have to be built multiple times (which in some cases is a huge number of extra crates). Although if you use |
Crates used exclusively at build time, such as proc-macro crates and
their dependencies, don't benefit substantially from optimization; they
take far longer to optimize than time saved when running them during the
build. No machine code from these crates will appear in the final
compiled binary.
Use the new profile-overrides mechanism in Rust 1.41
(https://doc.rust-lang.org/cargo/reference/profiles.html#overrides) to
build such crates with opt-level 0.
Before:
Finished release [optimized] target(s) in 4m 20s
After:
Finished release [optimized] target(s) in 4m 07s