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
+4-10Lines changed: 4 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Optimizing Build Performance
2
2
3
-
This guide will step you through Cargo configuration options and source code organization patterns that can help improve build performance, by prioritizing it over other aspects which may not be as important for your circumstances.
3
+
Cargo configuration options and source code organization patterns can help improve build performance, by prioritizing it over other aspects which may not be as important for your circumstances.
4
4
5
5
Same as when optimizing runtime performance, be sure to measure these changes against the workflows you actually care about, as we provide general guidelines and your circumstances may be different, it is possible that some of these approaches might actually make build performance worse for your use-case.
6
6
@@ -11,8 +11,6 @@ Example workflows to consider include:
11
11
12
12
## Cargo and Compiler Configuration
13
13
14
-
> Note that some approaches described in this section currently require using the nightly toolchain.
15
-
16
14
Cargo uses configuration defaults that try to balance several aspects, including debuggability, runtime performance, build performance, binary size and others. This section describes several approaches for changing these defaults that should be designed to maximize build performance.
17
15
18
16
You can set the described options either in the [`Cargo.toml` manifest](../reference/profiles.md), which will make them available for all developers who work on the given crate/project, or in the [`config.toml` configuration file](../reference/config.md), where you can apply them only for you or even globally for all your local projects.
@@ -47,8 +45,6 @@ Trade-offs:
47
45
48
46
### Use an alternative codegen backend
49
47
50
-
> **This requires nightly/unstable features**
51
-
52
48
Recommendation:
53
49
54
50
- Install the Cranelift codegen backend rustup component
@@ -66,11 +62,9 @@ Recommendation:
66
62
This will change the [`dev` profile](../reference/profiles.md#dev) to use the [Cranelift codegen backend](https://github.com/rust-lang/rustc_codegen_cranelift) for generating machine code, instead of the default LLVM backend. The Cranelift backend should generate code faster than LLVM, which should result in improved build performance.
67
63
68
64
Trade-offs:
69
-
- ✅ Faster build times
65
+
- ✅ Faster code generation (`cargo build`)
66
+
- ❌ **Requires using nightly Rust and an unstable Cargo feature**
70
67
- ❌ Worse runtime performance of the generated code
71
-
- ❌ Requires using nightly Rust and an unstable feature
68
+
- Speeds up build part of `cargo test`, but might increase its test execution part
72
69
- ❌ Only available for [certain targets](https://github.com/rust-lang/rustc_codegen_cranelift?tab=readme-ov-file#platform-support)
73
70
- ❌ Might not support all Rust features (e.g. unwinding)
0 commit comments