ad-ops
Re:Cranelift code generation comes to Rust
on Monday March 18, 2024 @12:15PM (#39746413)
For completion here is the compilation time for a small project from the axum/examples[0] (125 LoC), also comparing nightly dev vs adding cranelift + mold:
$ time cargo build
Compiling example-todos v0.1.0 (/home/user/ws/rust/example-todos)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.65s
cargo build 1.49s user 0.58s system 123% cpu 1.685 total
Compiling example-todos v0.1.0 (/home/user/ws/rust/example-todos)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.55s
cargo build 0.47s user 0.13s system 102% cpu 0.590 total
[0] https://github.com/tokio-rs/axum/tree/main/examples/todos
Re:Cranelift code generation comes to Rust
on Monday March 18, 2024 @11:26AM (#39745829)
I see that there are many comments on full debug builds, but for me the most important difference are incremental build times when making minor changes. In my opinion this is what speeds up the development iterations.
Here are my build times when making a trivial change to a print-statment in a root function, comparing nightly dev vs adding cranelift + mold for rust-analyzer[0] (347_290 LoC) and gleam[1] (76_335 LoC):
$ time cargo build
Compiling rust-analyzer v0.0.0 (/home/user/repos/rust-analyzer/crates/rust-analyzer)
# nightly
Finished `dev` profile [unoptimized] target(s) in 6.60s
cargo build 4.18s user 2.51s system 100% cpu 6.650 total
# cranelift+mold
Finished `dev` profile [unoptimized] target(s) in 2.25s
cargo build 1.77s user 0.36s system 92% cpu 2.305 total
Compiling gleam v1.0.0 (/home/user/repos/gleam/compiler-cli)
# nightly
Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.69s
cargo build --bin gleam 3.02s user 1.74s system 100% cpu 4.743 total
# cranelift+mold
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.99s
cargo build --bin gleam 0.71s user 0.20s system 88% cpu 1.033 total
For me this is the most important metric and it shows a huge improvement. If I compare it to Go building Terraform[2] (371_594 LoC) it is looking promising. This is a bit unfair since it is the release build for Go and this is really nice in the CI/CD. Love Go compilation times and I thought it would be nice to compare with another language to show the huge improvements that Rust has made. $ time go build
go build 3.62s user 0.76s system 171% cpu 2.545 total
I was looking forward to parallel front-end[3], but I have not seen any improvement for these small changes.[0] https://github.com/rust-lang/rust-analyzer
[1] https://github.com/gleam-lang/gleam
[2] https://github.com/hashicorp/terraform
[3] https://blog.rust-lang.org/2023/11/09/parallel-rustc.html
*edit: code-comments & links + making it easier to see the differences
Re:What part of Rust compilation is the bottleneck?
on Saturday March 16, 2024 @08:48AM (#39725444)
With all the recent improvements to compilation speed (nightly, cranelift, mold-linker), Rust has become much more pleasant. Trivial and incremental changes to a medium sized crate like rust-analyzer (~200k loc) takes around 2.5s and a small Axum project takes around 0.5s.
These are my very subjective hobby benchmarks running archlinux on an AMD 9 7940HS.
Of course the initial build or the release build take much longer, but it makes me hopeful for the future.