Skip to content

Commit f787039

Browse files
Julian WollersbergerJoshua Nelson
Julian Wollersberger
authored and
Joshua Nelson
committed
Did more measurements on what exactly affects llvm-lines:
optimize, codegen-units and mir-opt do, but debug-assertions doesn't.
1 parent 7adeb09 commit f787039

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/profiling.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Depending on what you're trying to measure, there are several different approach
2121
eg. `cargo -Ztimings build`.
2222
You can use this flag on the compiler itself with `CARGOFLAGS="-Ztimings" ./x.py build`
2323

24-
## Optimizing rustc's self-compile-times with cargo-llvm-lines
24+
## Optimizing rustc's bootstrap times with `cargo-llvm-lines`
2525

2626
Using [cargo-llvm-lines](https://github.com/dtolnay/cargo-llvm-lines) you can count the
2727
number of lines of LLVM IR across all instantiations of a generic function.
@@ -38,8 +38,8 @@ cargo install cargo-llvm-lines
3838
RUSTFLAGS="--emit=llvm-ir" ./x.py build --stage 0 compiler/rustc
3939
4040
# Single crate, eg. rustc_middle
41-
cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/rustc_middle* > llvm-lines-middle.txt
42-
# Whole compiler at once
41+
cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/rustc_middle-a539a639bdab6513.ll > llvm-lines-middle.txt
42+
# Specify all crates of the compiler. (Relies on the glob support of your shell.)
4343
cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/*.ll > llvm-lines.txt
4444
```
4545

@@ -72,7 +72,7 @@ you will be compiling rustc _a lot_.
7272
I recommend changing a few settings in `config.toml` to make it bearable:
7373
```
7474
[rust]
75-
# A debug build takes _a fourth_ as long on my machine,
75+
# A debug build takes _a third_ as long on my machine,
7676
# but compiling more than stage0 rustc becomes unbearably slow.
7777
optimize = false
7878
@@ -81,15 +81,14 @@ incremental = false
8181
# We won't be running it, so no point in compiling debug checks.
8282
debug = false
8383
84-
# Caution: This changes the output of llvm-lines.
85-
# Using a single codegen unit gives more accurate output, but is slower to compile.
86-
# Changing it to the number of cores on my machine increased the output
87-
# from 3.5GB to 4.1GB and decreased compile times from 5½ min to 4 min.
88-
codegen-units = 1
89-
#codegen-units = 0 # num_cpus
84+
# Using a single codegen unit gives less output, but is slower to compile.
85+
codegen-units = 0 # num_cpus
9086
```
9187

92-
What I'm still not sure about is if inlining in MIR optimizations affect llvm-lines.
93-
The output with `-Zmir-opt-level=0` and `-Zmir-opt-level=1` is the same,
94-
but it feels like that some functions that show up at the top should be to small
95-
to have such a high impact. Inlining should only happens in LLVM though.
88+
The llvm-lines output is affected by several options.
89+
`optimize = false` increases it from 2.1GB to 3.5GB and `codegen-units = 0` to 4.1GB.
90+
91+
MIR optimizations have little impact. Compared to the default `RUSTFLAGS="-Zmir-opt-level=1"`,
92+
level 0 adds 0.3GB and level 2 removes 0.2GB.
93+
Inlining currently only happens in LLVM, but this might change in the future.
94+

0 commit comments

Comments
 (0)