Reduce tool build time!
JohnAZoidberg opened this issue · 7 comments
Something has gone wrong and the build time has drastically increased.
NEED to figure out why and reduce it again.
The module firmware build is still really fast. Less than 2 seconds.
But the tool build is pretty slow. About 20 seconds. And this gets really bad when using rust-analyzer in vs code because it does some extra checks and blocks the build on the commandline until it's done.
I can take a look. I've got a few ideas to try. Are you trying to reduce local build times, CI build times, or both?
Cool, thanks!
Both, but mainly local build.
Quite annoying to have to wait 20s for a build.
Hmm so the problem is that I'm setting in the workspace global Cargo.toml the following:
[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 3
overflow-checks = false
# do not optimize proc-macro crates = faster builds from scratch
[profile.dev.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
[profile.release.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
# cargo test
[profile.test]
codegen-units = 1
debug = 2
debug-assertions = true
incremental = false
opt-level = 3
overflow-checks = true
# cargo test --release
[profile.bench]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 3
which is really only meant for the firmware builds.
With this, the release build of the tool takes 14s but without, just 1.4 seconds.
Fat LTO is gonna be a huge contributor to build times.
Yeah. 😞 That was one of the factors in me recommending a split project in my PR. Enabling incremental builds can help the host app too. That way, you aren't rebuilding the entire project every time (only the parts that changed).
I found out how to apply the options only to the firmware, not tool.
Fat LTO is gonna be a huge contributor to build times.
Yeah, but I only applied it to release builds, that's ok.