Skip to content

Commit 9396555

Browse files
committed
sembr src/building/optimized-build.md
1 parent 20b3a4a commit 9396555

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/building/optimized-build.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
There are multiple additional build configuration options and techniques that can be used to compile a
44
build of `rustc` that is as optimized as possible (for example when building `rustc` for a Linux
5-
distribution). The status of these configuration options for various Rust targets is tracked [here].
5+
distribution).
6+
The status of these configuration options for various Rust targets is tracked [here].
67
This page describes how you can use these approaches when building `rustc` yourself.
78

89
[here]: https://github.com/rust-lang/rust/issues/103595
910

1011
## Link-time optimization
1112

12-
Link-time optimization is a powerful compiler technique that can increase program performance. To
13-
enable (Thin-)LTO when building `rustc`, set the `rust.lto` config option to `"thin"`
13+
Link-time optimization is a powerful compiler technique that can increase program performance.
14+
To enable (Thin-)LTO when building `rustc`, set the `rust.lto` config option to `"thin"`
1415
in `bootstrap.toml`:
1516

1617
```toml
@@ -29,8 +30,8 @@ Enabling LTO on Linux has [produced] speed-ups by up to 10%.
2930

3031
## Memory allocator
3132

32-
Using a different memory allocator for `rustc` can provide significant performance benefits. If you
33-
want to enable the `jemalloc` allocator, you can set the `rust.jemalloc` option to `true`
33+
Using a different memory allocator for `rustc` can provide significant performance benefits.
34+
If you want to enable the `jemalloc` allocator, you can set the `rust.jemalloc` option to `true`
3435
in `bootstrap.toml`:
3536

3637
```toml
@@ -53,7 +54,8 @@ rust.codegen-units-std = 1
5354
## Instruction set
5455

5556
By default, `rustc` is compiled for a generic (and conservative) instruction set architecture
56-
(depending on the selected target), to make it support as many CPUs as possible. If you want to
57+
(depending on the selected target), to make it support as many CPUs as possible.
58+
If you want to
5759
compile `rustc` for a specific instruction set architecture, you can set the `target_cpu` compiler
5860
option in `RUSTFLAGS`:
5961

@@ -72,14 +74,16 @@ llvm.cflags = "-march=x86-64-v3"
7274
## Profile-guided optimization
7375

7476
Applying profile-guided optimizations (or more generally, feedback-directed optimizations) can
75-
produce a large increase to `rustc` performance, by up to 15% ([1], [2]). However, these techniques
77+
produce a large increase to `rustc` performance, by up to 15% ([1], [2]).
78+
However, these techniques
7679
are not simply enabled by a configuration option, but rather they require a complex build workflow
7780
that compiles `rustc` multiple times and profiles it on selected benchmarks.
7881

7982
There is a tool called `opt-dist` that is used to optimize `rustc` with [PGO] (profile-guided
80-
optimizations) and [BOLT] (a post-link binary optimizer) for builds distributed to end users. You
81-
can examine the tool, which is located in `src/tools/opt-dist`, and build a custom PGO build
82-
workflow based on it, or try to use it directly. Note that the tool is currently quite hardcoded to
83+
optimizations) and [BOLT] (a post-link binary optimizer) for builds distributed to end users.
84+
You can examine the tool, which is located in `src/tools/opt-dist`, and build a custom PGO build
85+
workflow based on it, or try to use it directly.
86+
Note that the tool is currently quite hardcoded to
8387
the way we use it in Rust's continuous integration workflows, and it might require some custom
8488
changes to make it work in a different environment.
8589

@@ -93,9 +97,9 @@ changes to make it work in a different environment.
9397
To use the tool, you will need to provide some external dependencies:
9498

9599
- A Python3 interpreter (for executing `x.py`).
96-
- Compiled LLVM toolchain, with the `llvm-profdata` binary. Optionally, if you want to use BOLT,
97-
the `llvm-bolt` and
98-
`merge-fdata` binaries have to be available in the toolchain.
100+
- Compiled LLVM toolchain, with the `llvm-profdata` binary.
101+
Optionally, if you want to use BOLT,
102+
the `llvm-bolt` and `merge-fdata` binaries have to be available in the toolchain.
99103

100104
These dependencies are provided to `opt-dist` by an implementation of the [`Environment`] struct.
101105
It specifies directories where will the PGO/BOLT pipeline take place, and also external dependencies

0 commit comments

Comments
 (0)