2
2
3
3
set -euxo pipefail
4
4
5
+ # Compile several crates to gather execution PGO profiles.
6
+ # Arg0 => builds (Debug, Opt)
7
+ # Arg1 => runs (Full, IncrFull, All)
8
+ # Arg2 => crates (syn, cargo, ...)
9
+ gather_profiles () {
10
+ cd /checkout/obj
11
+
12
+ # Compile libcore, both in opt-level=0 and opt-level=3
13
+ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
14
+ --edition=2021 --crate-type=lib ../library/core/src/lib.rs
15
+ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
16
+ --edition=2021 --crate-type=lib -Copt-level=3 ../library/core/src/lib.rs
17
+
18
+ cd rustc-perf
19
+
20
+ # Run rustc-perf benchmarks
21
+ # Benchmark using profile_local with eprintln, which essentially just means
22
+ # don't actually benchmark -- just make sure we run rustc a bunch of times.
23
+ RUST_LOG=collector=debug \
24
+ RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
25
+ RUSTC_BOOTSTRAP=1 \
26
+ /checkout/obj/build/$PGO_HOST /stage0/bin/cargo run -p collector --bin collector -- \
27
+ profile_local \
28
+ eprintln \
29
+ /checkout/obj/build/$PGO_HOST /stage2/bin/rustc \
30
+ Test \
31
+ --builds $1 \
32
+ --cargo /checkout/obj/build/$PGO_HOST /stage0/bin/cargo \
33
+ --runs $2 \
34
+ --include $3
35
+
36
+ cd /checkout/obj
37
+ }
38
+
5
39
rm -rf /tmp/rustc-pgo
6
40
7
41
# We collect LLVM profiling information and rustc profiling information in
@@ -19,6 +53,19 @@ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST/stage2/bin/rustc \
19
53
RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
20
54
--edition=2021 --crate-type=lib -Copt-level=3 ../library/core/src/lib.rs
21
55
56
+ # Compile rustc perf
57
+ cp -r /tmp/rustc-perf ./
58
+ chown -R $( whoami) : ./rustc-perf
59
+ cd rustc-perf
60
+
61
+ # Build the collector ahead of time, which is needed to make sure the rustc-fake
62
+ # binary used by the collector is present.
63
+ RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
64
+ RUSTC_BOOTSTRAP=1 \
65
+ /checkout/obj/build/$PGO_HOST /stage0/bin/cargo build -p collector
66
+
67
+ gather_profiles " Debug,Opt" " Full" " syn,cargo,serde,ripgrep,regex,clap-rs,hyper-2"
68
+
22
69
# Merge the profile data we gathered for LLVM
23
70
# Note that this uses the profdata from the clang we used to build LLVM,
24
71
# which likely has a different version than our in-tree clang.
@@ -36,38 +83,8 @@ python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
36
83
--stage 2 library/std \
37
84
--rust-profile-generate=/tmp/rustc-pgo
38
85
39
- # Profile libcore compilation in opt-level=0 and opt-level=3
40
- RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
41
- --edition=2021 --crate-type=lib ../library/core/src/lib.rs
42
- RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
43
- --edition=2021 --crate-type=lib -Copt-level=3 ../library/core/src/lib.rs
44
-
45
- cp -r /tmp/rustc-perf ./
46
- chown -R $( whoami) : ./rustc-perf
47
- cd rustc-perf
48
-
49
- # Build the collector ahead of time, which is needed to make sure the rustc-fake
50
- # binary used by the collector is present.
51
- RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
52
- RUSTC_BOOTSTRAP=1 \
53
- /checkout/obj/build/$PGO_HOST /stage0/bin/cargo build -p collector
54
-
55
- # benchmark using profile_local with eprintln, which essentially just means
56
- # don't actually benchmark -- just make sure we run rustc a bunch of times.
57
- RUST_LOG=collector=debug \
58
- RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
59
- RUSTC_BOOTSTRAP=1 \
60
- /checkout/obj/build/$PGO_HOST /stage0/bin/cargo run -p collector --bin collector -- \
61
- profile_local \
62
- eprintln \
63
- /checkout/obj/build/$PGO_HOST /stage2/bin/rustc \
64
- Test \
65
- --builds Check,Debug,Opt \
66
- --cargo /checkout/obj/build/$PGO_HOST /stage0/bin/cargo \
67
- --runs All \
68
- --include externs,ctfe-stress-4,inflate,cargo,token-stream-stress,match-stress-enum
69
-
70
- cd /checkout/obj
86
+ gather_profiles " Check,Debug,Opt" " All" \
87
+ " externs,ctfe-stress-4,inflate,cargo,token-stream-stress,match-stress-enum"
71
88
72
89
# Merge the profile data we gathered
73
90
./build/$PGO_HOST /llvm/bin/llvm-profdata \
0 commit comments