Skip to content

Commit 054eb75

Browse files
Kobzoltshepang
authored andcommitted
Review changes
1 parent 083cbb4 commit 054eb75

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/building/optimized-build.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lto = "thin"
2222

2323
> Note that LTO for `rustc` is currently supported and tested only for
2424
> the `x86_64-unknown-linux-gnu` target. Other targets *may* work, but no guarantees are provided.
25-
> Notably, LTO optimized `rustc` currently produces [miscompilations] on Windows.
25+
> Notably, LTO-optimized `rustc` currently produces [miscompilations] on Windows.
2626
2727
[miscompilations]: https://github.com/rust-lang/rust/issues/109114
2828

@@ -63,7 +63,7 @@ compile `rustc` for a specific instruction set architecture, you can set the `ta
6363
option in `RUSTFLAGS`:
6464

6565
```bash
66-
$ RUSTFLAGS="-C target_cpu=x86-64-v3" x.py build ...
66+
RUSTFLAGS="-C target_cpu=x86-64-v3" ./x build ...
6767
```
6868

6969
If you also want to compile LLVM for a specific instruction set, you can set `llvm` flags
@@ -78,9 +78,9 @@ cflags = "-march=x86-64-v3"
7878
## Profile-guided optimization
7979

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

8585
There is a tool called `opt-dist` that is used to optimize `rustc` with [PGO] (profile-guided
8686
optimizations) and [BOLT] (a post-link binary optimizer) for builds distributed to end users. You
@@ -89,6 +89,9 @@ workflow based on it, or try to use it directly. Note that the tool is currently
8989
the way we use it in Rust's continuous integration workflows, and it might require some custom
9090
changes to make it work in a different environment.
9191

92+
[1]: https://blog.rust-lang.org/inside-rust/2020/11/11/exploring-pgo-for-the-rust-compiler.html#final-numbers-and-a-benchmarking-plot-twist
93+
[2]: https://github.com/rust-lang/rust/pull/96978
94+
9295
[PGO]: https://doc.rust-lang.org/rustc/profile-guided-optimization.html
9396

9497
[BOLT]: https://github.com/llvm/llvm-project/blob/main/bolt/README.md
@@ -112,11 +115,11 @@ you execute the following commands on a Linux system):
112115

113116
1. Build the tool with the following command:
114117
```bash
115-
$ python3 x.py build tools/opt-dist
118+
./x build tools/opt-dist
116119
```
117120
2. Run the tool with the `PGO_HOST` environment variable set to the 64-bit Linux target:
118121
```bash
119-
$ PGO_HOST=x86_64-unknown-linux-gnu ./build/host/stage0-tools-bin/opt-dist
122+
PGO_HOST=x86_64-unknown-linux-gnu ./build/host/stage0-tools-bin/opt-dist
120123
```
121124
Note that the default Linux environment expects several hardcoded paths to exist:
122125
- `/checkout` should contain a checkout of the Rust compiler repository that will be compiled.
@@ -126,6 +129,6 @@ you execute the following commands on a Linux system):
126129

127130
You can modify `LinuxEnvironment` (or implement your own) to override these paths.
128131

129-
[`Environment`]: https://github.com/rust-lang/rust/blob/65e468f9c259749c210b1ae8972bfe14781f72f1/src/tools/opt-dist/src/environment/mod.rs#L8-L7
132+
[`Environment`]: https://github.com/rust-lang/rust/blob/65e468f9c259749c210b1ae8972bfe14781f72f1/src/tools/opt-dist/src/environment/mod.rs#L8-L70
130133

131134
[Rust benchmark suite]: https://github.com/rust-lang/rustc-perf

0 commit comments

Comments
 (0)