Skip to content

Commit 79e630e

Browse files
authored
Merge pull request #727 from nnethercote/more-profiler-testing
Add more profiler testing.
2 parents a44874b + 0bc9e88 commit 79e630e

File tree

2 files changed

+151
-12
lines changed

2 files changed

+151
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797

9898
- name: Install profilers
9999
run: |
100+
sudo apt install -y valgrind
100101
cargo install cargo-llvm-lines
101102
102103
- name: Configure environment

ci/check-profiling.sh

Lines changed: 150 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,171 @@ trap 'kill $PING_LOOP_PID' ERR 1 2 3 6
1313
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
1414
bindir=`cargo run -p collector --bin collector install_next`
1515

16-
# Profile with eprintln.
16+
#----------------------------------------------------------------------------
17+
# Test the profilers
18+
#----------------------------------------------------------------------------
19+
20+
# time-passes.
1721
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
1822
cargo run -p collector --bin collector -- \
19-
profile_local eprintln $bindir/rustc Test \
23+
profile_local time-passes $bindir/rustc Test \
24+
--builds Check \
25+
--cargo $bindir/cargo \
26+
--include helloworld \
27+
--runs Full
28+
test -f results/Ztp-Test-helloworld-Check-Full
29+
grep -q "time:.*total" results/Ztp-Test-helloworld-Check-Full
30+
31+
# perf-record: TODO
32+
33+
# oprofile: TODO
34+
35+
# Cachegrind.
36+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
37+
cargo run -p collector --bin collector -- \
38+
profile_local cachegrind $bindir/rustc Test \
39+
--builds Check \
40+
--cargo $bindir/cargo \
41+
--include helloworld \
42+
--runs Full
43+
test -f results/cgout-Test-helloworld-Check-Full
44+
grep -q "events: Ir" results/cgout-Test-helloworld-Check-Full
45+
test -f results/cgann-Test-helloworld-Check-Full
46+
# The Valgrind available on on GitHub is 3.13, which doesn't support the
47+
# `--show-percs=yes` option that we use. So the `cgann` file ends up empty,
48+
# because `cg_annotate` errors out and produces no stdout, but `collector` does
49+
# not check its exit code for failure and so does not fail itself.
50+
#grep -q "PROGRAM TOTALS" results/cgann-Test-helloworld-Check-Full
51+
52+
# Callgrind.
53+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
54+
cargo run -p collector --bin collector -- \
55+
profile_local callgrind $bindir/rustc Test \
56+
--builds Check \
57+
--cargo $bindir/cargo \
58+
--include helloworld \
59+
--runs Full
60+
test -f results/clgout-Test-helloworld-Check-Full
61+
grep -q "creator: callgrind" results/clgout-Test-helloworld-Check-Full
62+
test -f results/clgann-Test-helloworld-Check-Full
63+
# See the explanation on the `cgann` file for Cachegrind; it holds here too.
64+
#grep -q "Profile data file" results/clgann-Test-helloworld-Check-Full
65+
66+
# DHAT: needs Valgrind 3.15, but only Valgrind 3.13 is available on GitHub.
67+
68+
# Massif.
69+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
70+
cargo run -p collector --bin collector -- \
71+
profile_local massif $bindir/rustc Test \
72+
--builds Check \
2073
--cargo $bindir/cargo \
2174
--include helloworld \
2275
--runs Full
76+
test -f results/msout-Test-helloworld-Check-Full
77+
grep -q "snapshot=0" results/msout-Test-helloworld-Check-Full
2378

24-
# Check that Check/Debug/Opt files are present, and that Doc files aren't
25-
# present, becuase they're not done by default.
79+
# eprintln.
80+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
81+
cargo run -p collector --bin collector -- \
82+
profile_local eprintln $bindir/rustc Test \
83+
--builds Check \
84+
--cargo $bindir/cargo \
85+
--include helloworld \
86+
--runs Full
2687
test -f results/eprintln-Test-helloworld-Check-Full
27-
test -f results/eprintln-Test-helloworld-Debug-Full
28-
test -f results/eprintln-Test-helloworld-Opt-Full
29-
test ! -e results/eprintln-Test-helloworld-Doc-Full
88+
grep -q "Checking helloworld" results/eprintln-Test-helloworld-Check-Full
3089

31-
# Profile with llvm-lines.
90+
# llvm-lines. `Debug` not `Check` because it doesn't support `Check` builds.
3291
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
3392
cargo run -p collector --bin collector -- \
3493
profile_local llvm-lines $bindir/rustc Test \
3594
--builds Debug \
3695
--cargo $bindir/cargo \
37-
--include futures \
96+
--include helloworld \
3897
--runs Full
98+
test -f results/ll-Test-helloworld-Debug-Full
99+
grep -q "Lines.*Copies.*Function name" results/ll-Test-helloworld-Debug-Full
100+
101+
#----------------------------------------------------------------------------
102+
# Test option handling
103+
#----------------------------------------------------------------------------
104+
105+
# With `--builds` unspecified, `Check`/`Debug`/`Opt` files must be present, and
106+
# `Doc` files must not be present.
107+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
108+
cargo run -p collector --bin collector -- \
109+
profile_local eprintln $bindir/rustc Builds1 \
110+
--cargo $bindir/cargo \
111+
--include helloworld
112+
test -f results/eprintln-Builds1-helloworld-Check-Full
113+
test -f results/eprintln-Builds1-helloworld-Check-IncrFull
114+
test -f results/eprintln-Builds1-helloworld-Check-IncrPatched0
115+
test -f results/eprintln-Builds1-helloworld-Check-IncrUnchanged
116+
test -f results/eprintln-Builds1-helloworld-Debug-Full
117+
test -f results/eprintln-Builds1-helloworld-Debug-IncrFull
118+
test -f results/eprintln-Builds1-helloworld-Debug-IncrPatched0
119+
test -f results/eprintln-Builds1-helloworld-Debug-IncrUnchanged
120+
test -f results/eprintln-Builds1-helloworld-Opt-Full
121+
test -f results/eprintln-Builds1-helloworld-Opt-IncrFull
122+
test -f results/eprintln-Builds1-helloworld-Opt-IncrPatched0
123+
test -f results/eprintln-Builds1-helloworld-Opt-IncrUnchanged
124+
test ! -e results/eprintln-Builds1-helloworld-Doc-Full
125+
test ! -e results/eprintln-Builds1-helloworld-Doc-IncrFull
126+
test ! -e results/eprintln-Builds1-helloworld-Doc-IncrPatched0
127+
test ! -e results/eprintln-Builds1-helloworld-Doc-IncrUnchanged
128+
129+
# With `--builds Doc` specified, `Check`/`Debug`/`Opt` files must not be
130+
# present, and `Doc` files must be present (but not for incremental runs).
131+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
132+
cargo run -p collector --bin collector -- \
133+
profile_local eprintln $bindir/rustc Builds2 \
134+
--builds Doc \
135+
--cargo $bindir/cargo \
136+
--include helloworld
137+
test ! -e results/eprintln-Builds2-helloworld-Check-Full
138+
test ! -e results/eprintln-Builds2-helloworld-Check-IncrFull
139+
test ! -e results/eprintln-Builds2-helloworld-Check-IncrUnchanged
140+
test ! -e results/eprintln-Builds2-helloworld-Check-IncrPatched0
141+
test ! -e results/eprintln-Builds2-helloworld-Debug-Full
142+
test ! -e results/eprintln-Builds2-helloworld-Debug-IncrFull
143+
test ! -e results/eprintln-Builds2-helloworld-Debug-IncrUnchanged
144+
test ! -e results/eprintln-Builds2-helloworld-Debug-IncrPatched0
145+
test ! -e results/eprintln-Builds2-helloworld-Opt-Full
146+
test ! -e results/eprintln-Builds2-helloworld-Opt-IncrFull
147+
test ! -e results/eprintln-Builds2-helloworld-Opt-IncrUnchanged
148+
test ! -e results/eprintln-Builds2-helloworld-Opt-IncrPatched0
149+
test -f results/eprintln-Builds2-helloworld-Doc-Full
150+
test ! -f results/eprintln-Builds2-helloworld-Doc-IncrFull
151+
test ! -f results/eprintln-Builds2-helloworld-Doc-IncrPatched0
152+
test ! -f results/eprintln-Builds2-helloworld-Doc-IncrUnchanged
153+
154+
# With `--runs IncrUnchanged` specified, `IncrFull` and `IncrUnchanged` files
155+
# must be present.
156+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
157+
cargo run -p collector --bin collector -- \
158+
profile_local eprintln $bindir/rustc Runs1 \
159+
--builds Check \
160+
--cargo $bindir/cargo \
161+
--include helloworld \
162+
--runs IncrUnchanged
163+
test ! -e results/eprintln-Runs1-helloworld-Check-Full
164+
test -f results/eprintln-Runs1-helloworld-Check-IncrFull
165+
test -f results/eprintln-Runs1-helloworld-Check-IncrUnchanged
166+
test ! -e results/eprintln-Runs1-helloworld-Check-IncrPatched0
39167

40-
# Check the output is present and looks something like it should.
41-
test -f results/ll-Test-futures-Debug-Full
42-
grep -q "Lines.*Copies.*Function name" results/ll-Test-futures-Debug-Full
168+
# With `--runs IncrPatched` specified, `IncrFull` and `IncrPatched0` files must
169+
# be present.
170+
RUST_BACKTRACE=1 RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \
171+
cargo run -p collector --bin collector -- \
172+
profile_local eprintln $bindir/rustc Runs2 \
173+
--builds Check \
174+
--cargo $bindir/cargo \
175+
--include helloworld \
176+
--runs IncrPatched
177+
test ! -e results/eprintln-Runs2-helloworld-Check-Full
178+
test -f results/eprintln-Runs2-helloworld-Check-IncrFull
179+
test ! -e results/eprintln-Runs2-helloworld-Check-IncrUnchanged
180+
test -f results/eprintln-Runs2-helloworld-Check-IncrPatched0
43181

44182
kill $PING_LOOP_PID
45183
exit 0

0 commit comments

Comments
 (0)