You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/src/guide/build-performance.md
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ This will:
38
38
- Provide an opt-in for when debugging via [`--profile debugging`](../reference/profiles.md#custom-profiles)
39
39
40
40
Trade-offs:
41
-
- ✅ Faster build times
41
+
- ✅ Faster code generation (`cargo build`)
42
42
- ✅ Faster link times
43
43
- ✅ Smaller disk usage of the `target` directory
44
44
- ❌ Requires a full rebuild to have a high-quality debugger experience
@@ -83,9 +83,33 @@ rustflags = "-Zthreads=8"
83
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
84
85
85
Trade-offs:
86
-
- ✅ Faster build times
86
+
- ✅ Faster build times (both `cargo check` and `cargo build`)
87
87
- ❌ **Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**
Consider: installing and configuring an alternative linker, like [LLD](https://lld.llvm.org/), [mold](https://github.com/rui314/mold) or [wild](https://github.com/davidlattimore/wild). For example, to configure mold on Linux, you can add to your `.cargo/config.toml`:
While dependencies may be built in parallel, linking all of your dependencies happens at once at the end of your build, which can make linking dominate your build times, especially for incremental rebuilds. Often, the linker Rust uses is already fairly fast and the gains from switching may not be worth it, but it is not always the case. For example, Linux targets besides `x86_64-unknown-linux-gnu` still use the Linux system linker which is quite slow (see [rust#39915](https://github.com/rust-lang/rust/issues/39915) for more details).
108
+
109
+
Trade-offs:
110
+
- ✅ Faster link times
111
+
- ❌ Might not support all use-cases, in particular if you depend on C or C++ dependencies
112
+
89
113
## Reducing built code
90
114
91
115
### Removing unused dependencies
@@ -103,7 +127,3 @@ it can be easy to miss that a dependency is no longer used and can be removed.
103
127
Trade-offs:
104
128
- ✅ Faster full build and link times
105
129
- ❌ May incorrectly flag dependencies as unused or miss some
0 commit comments