I wonder if there's any write-up about what current incremental compilation can and can't do? I want to understand it better, so that I know which changes are "fast" and which changes are "slow", and to optimize the structure of my project for fast incremental compiles.
For example, at the moment I can't explain the following: changing a (non-doc) comment in rust-analayzer's middle-end crate and rebuilding the analyzer in "debug" mode takes 10s. I would expect this no-op change to be effectively no-op tbh.
Here's what I am doing.
At this line I added // ...
and I add or remove the .
(so the line numbers are intact). I then build the leaf crate using
λ export RUSTC_BOOTSTRAP=1
λ rustc --version
rustc 1.49.0-beta.2 (bd26e4e54 2020-11-24)
λ cargo build -p rust-analyzer --bin rust-analyzer -Ztimings=info
There's debug=0
in Cargo.toml profile.
With all that, this is what I am seeing:
Compiling hir v0.0.0 (/home/matklad/projects/rust-analyzer/crates/hir)
Compiling ide_db v0.0.0 (/home/matklad/projects/rust-analyzer/crates/ide_db)
Completed hir v0.0.0 in 0.7s
Compiling assists v0.0.0 (/home/matklad/projects/rust-analyzer/crates/assists)
Compiling completion v0.0.0 (/home/matklad/projects/rust-analyzer/crates/completion)
Compiling ssr v0.0.0 (/home/matklad/projects/rust-analyzer/crates/ssr)
Completed ide_db v0.0.0 in 0.9s
Completed ssr v0.0.0 in 0.5s
Completed completion v0.0.0 in 0.6s
Compiling ide v0.0.0 (/home/matklad/projects/rust-analyzer/crates/ide)
Completed assists v0.0.0 in 0.9s
Compiling rust-analyzer v0.0.0 (/home/matklad/projects/rust-analyzer/crates/rust-analyzer)
Completed ide v0.0.0 in 0.8s
Completed rust-analyzer v0.0.0 in 1.6s
Completed rust-analyzer v0.0.0 bin "rust-analyzer" in 5.8s
Finished dev [unoptimized] target(s) in 10.06s
THe hir
is the middle crate being edited, the rust-analyzer
is the final leaf binary, and other crates are some front-end IDE bits.
I am surprised that middle crates take up to a second to compile, as those should be no-ops...