Skip to content

Commit 9a63dd7

Browse files
committed
Add parallel frontend to the build performance guide
1 parent fbe6193 commit 9a63dd7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/doc/src/guide/build-performance.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,21 @@ Trade-offs:
6868
- Speeds up build part of `cargo test`, but might increase its test execution part
6969
- ❌ Only available for [certain targets](https://github.com/rust-lang/rustc_codegen_cranelift?tab=readme-ov-file#platform-support)
7070
- ❌ Might not support all Rust features (e.g. unwinding)
71+
72+
### Enable the experimental parallel frontend
73+
74+
Recommendation: Add `-Zthreads=n` to the `RUSTFLAGS` environment variable[^rustflags], for example:
75+
76+
```console
77+
$ RUSTFLAGS="-Zthreads=8" cargo build
78+
```
79+
80+
This will enable the [parallel frontend][parallel-frontend] of the Rust compiler, and tell it to use `n` threads. The value of `n` should be chosen according to the number of cores available on your system, although there are diminishing returns. We recommend to set at most `8` threads.
81+
82+
Trade-offs:
83+
- ✅ Faster build times
84+
-**Requires using nightly Rust and an unstable Cargo feature**
85+
86+
[^rustflags]: You can configure `RUSTFLAGS` either as an environment variable when running Cargo, or through the [Cargo config](../reference/config.md#targettriplerustflags).
87+
88+
[parallel-frontend]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/

0 commit comments

Comments
 (0)