FrameworkComputer / inputmodule-rs

Framework Laptop 16 Input Module SW/FW
MIT License
223 stars 24 forks source link

Reduce tool build time! #19

Closed JohnAZoidberg closed 1 year ago

JohnAZoidberg commented 1 year ago

Something has gone wrong and the build time has drastically increased. NEED to figure out why and reduce it again.

JohnAZoidberg commented 1 year ago

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.

jdswensen commented 1 year ago

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?

JohnAZoidberg commented 1 year ago

Cool, thanks! Both, but mainly local build. Quite annoying to have to wait 20s for a build.

JohnAZoidberg commented 1 year ago

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.

sajattack commented 1 year ago

Fat LTO is gonna be a huge contributor to build times.

jdswensen commented 1 year ago

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).

JohnAZoidberg commented 1 year ago

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.