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,7 @@ 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
22
57
cp -r /tmp/rustc-perf ./
23
58
chown -R $( whoami) : ./rustc-perf
24
59
cd rustc-perf
@@ -29,23 +64,7 @@ RUSTC=/checkout/obj/build/$PGO_HOST/stage0/bin/rustc \
29
64
RUSTC_BOOTSTRAP=1 \
30
65
/checkout/obj/build/$PGO_HOST /stage0/bin/cargo build -p collector
31
66
32
- # Gather LLVM PGO profiles from real-world crates.
33
- # Benchmark using profile_local with eprintln, which essentially just means
34
- # don't actually benchmark -- just make sure we run rustc a bunch of times.
35
- RUST_LOG=collector=debug \
36
- RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
37
- RUSTC_BOOTSTRAP=1 \
38
- /checkout/obj/build/$PGO_HOST /stage0/bin/cargo run -p collector --bin collector -- \
39
- profile_local \
40
- eprintln \
41
- /checkout/obj/build/$PGO_HOST /stage2/bin/rustc \
42
- Test \
43
- --builds Debug,Opt \
44
- --cargo /checkout/obj/build/$PGO_HOST /stage0/bin/cargo \
45
- --runs All \
46
- --include syn,cargo,serde,ripgrep,regex,clap-rs,hyper-2
47
-
48
- cd /checkout/obj
67
+ gather_profiles " Debug,Opt" " Full" " syn,cargo,serde,ripgrep,regex,clap-rs,hyper-2"
49
68
50
69
# Merge the profile data we gathered for LLVM
51
70
# Note that this uses the profdata from the clang we used to build LLVM,
@@ -64,28 +83,8 @@ python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
64
83
--stage 2 library/std \
65
84
--rust-profile-generate=/tmp/rustc-pgo
66
85
67
- # Profile libcore compilation in opt-level=0 and opt-level=3
68
- RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
69
- --edition=2021 --crate-type=lib ../library/core/src/lib.rs
70
- RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST /stage2/bin/rustc \
71
- --edition=2021 --crate-type=lib -Copt-level=3 ../library/core/src/lib.rs
72
-
73
- cd rustc-perf
74
-
75
- RUST_LOG=collector=debug \
76
- RUSTC=/checkout/obj/build/$PGO_HOST /stage0/bin/rustc \
77
- RUSTC_BOOTSTRAP=1 \
78
- /checkout/obj/build/$PGO_HOST /stage0/bin/cargo run -p collector --bin collector -- \
79
- profile_local \
80
- eprintln \
81
- /checkout/obj/build/$PGO_HOST /stage2/bin/rustc \
82
- Test \
83
- --builds Check,Debug,Opt \
84
- --cargo /checkout/obj/build/$PGO_HOST /stage0/bin/cargo \
85
- --runs All \
86
- --include externs,ctfe-stress-4,inflate,cargo,token-stream-stress,match-stress-enum
87
-
88
- cd /checkout/obj
86
+ gather_profiles " Check,Debug,Opt" " All" \
87
+ " externs,ctfe-stress-4,inflate,cargo,token-stream-stress,match-stress-enum"
89
88
90
89
# Merge the profile data we gathered
91
90
./build/$PGO_HOST /llvm/bin/llvm-profdata \
0 commit comments