by echelon · 1y ago · 0 comments
We're progressively banning macro usage from our Rust monorepo. Macro-heavy dependencies are also going to be pruned eventually.
As much as I love Serde, it makes compile times for projects like async-stripe absolutely productivity killing. It interferes heavily with work.
Crates.io would be fantastic if it had compile time metrics and macro metrics reported for projects and dependencies.
[profile.dev.build-override]
opt-level = 3
codegen-units = 1
[profile.dev.package."syn"]
opt-level = 3
codegen-units = 1
[profile.dev.package."synstructure"]
opt-level = 3
codegen-units = 1
[profile.dev.package."quote"]
opt-level = 3
codegen-units = 1
# CTRL+C when it reaches async-stripe, then repeat
> rm -r target/debug/build/async-stripe*; time cargo build
default, O1, O2, O3: Executed in 47.13 secs
Executed in 45.68 secs
Executed in 46.07 secs
Executed in 46.22 secs
sccache will provide a major benefit, especially in combination with `cargo-hakari`.This means rust analyzer and your IDE will have different target dirs (target/debug and target/rust-analyzer), this can prevent flagging resulting from cargo and rust-analyzer fighting over the features etc. I have this set at system/global level in my IDE config. The downside is that you'll use double the disk space.
I have a backend and frontend for my project, and the typescript frontend with its sub-second feedback cycle definitely helps for staying in a flow-state. With all of the improvements above, rust is still at 3 to 10 seconds.