Skip to content

Commit a887a25

Browse files
committed
Add parallel frontend to the build performance guide
1 parent 5f0328f commit a887a25

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,23 @@ Trade-offs:
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)
7171

72-
[codegen-backend-feature]: ../reference/unstable.md#codegen-backend
72+
[codegen-backend-feature]: ../reference/unstable.md#codegen-backend
73+
74+
### Enable the experimental parallel frontend
75+
76+
Recommendation: Add to your `.cargo/config.toml`:
77+
78+
```toml
79+
[build]
80+
rustflags = "-Zthreads=8"
81+
```
82+
83+
This [`rustflags`][build.rustflags] will enable the [parallel frontend][parallel-frontend-blog] 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 using at most `8` threads.
84+
85+
Trade-offs:
86+
- ✅ Faster build times
87+
-**Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**
88+
89+
[parallel-frontend-blog]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
90+
[parallel-frontend-issue]: https://github.com/rust-lang/rust/issues/113349
91+
[build.rustflags]: ../reference/config.md#buildrustflags

0 commit comments

Comments
 (0)