oll3 / nbd-async

Block device driver in userspace!
https://crates.io/crates/nbd-async
MIT License
8 stars 7 forks source link

Don't spend build time optimizing build-time-only crates #2

Closed joshtriplett closed 4 years ago

joshtriplett commented 4 years ago

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 1m 22s

After: Finished release [optimized] target(s) in 27.16s

oll3 commented 4 years ago

The time savings will mainly be at clean builds? Is this commonly used among lib crates? Haven't seen it before.

joshtriplett commented 4 years ago

Yes, this will speed up any build that needs to build syn, proc_macro2, and other proc macro crates.

A binary crate using nbd-async would need to do the same thing to get the build performance benefit. This change helps when rebuilding nbd-async itself, which I was doing repeatedly when testing other changes.