Skip to content

Commit 6786461

Browse files
committed
Add testing of collector profile_local.
Also neaten up `ci/check-benchmarks.sh` by using `set -e`.
1 parent 0680323 commit 6786461

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

.github/workflows/ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
aws_access_key_id: "${{ env.AWS_ACCESS_KEY_ID }}"
3333
aws_secret_access_key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
3434
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/deploy'
35+
3536
test_benchmarks:
3637
name: Test benchmarks
3738
runs-on: ubuntu-latest
@@ -60,6 +61,7 @@ jobs:
6061
run: sh -x -c "ci/check-benchmarks.sh"
6162
env:
6263
BENCH_INCLUDE_EXCLUDE_OPTS: "--exclude script-servo"
64+
6365
test_script_servo:
6466
name: Test benchmark script-servo
6567
runs-on: ubuntu-latest
@@ -92,3 +94,31 @@ jobs:
9294
env:
9395
BENCH_INCLUDE_EXCLUDE_OPTS: "--include script-servo"
9496
SHELL: "/bin/bash"
97+
98+
test_profiling:
99+
name: Test profiling
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Checkout the source code
103+
uses: actions/checkout@v2
104+
with:
105+
fetch-depth: 1
106+
107+
- name: Install latest nightly
108+
uses: actions-rs/toolchain@v1
109+
with:
110+
toolchain: nightly
111+
override: true
112+
113+
- name: Configure environment
114+
run: |
115+
sudo apt-get update
116+
sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
117+
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
118+
119+
- name: Build collector
120+
run: cargo build -p collector
121+
122+
- name: Check benchmarks
123+
run: sh -x -c "ci/check-profiling.sh"
124+

ci/check-benchmarks.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/bin/bash
22

3-
set -x;
3+
set -e -x;
44

55
bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
66
PING_LOOP_PID=$!
7-
trap - ERR
7+
trap 'kill $PING_LOOP_PID' ERR
8+
9+
# Install a toolchain.
810
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
9-
bindir=`cargo run -p collector --bin collector install_next` \
10-
&& \
11+
bindir=`cargo run -p collector --bin collector install_next`
12+
13+
# Do some benchmarking.
1114
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
1215
cargo run -p collector --bin collector -- \
1316
bench_local $bindir/rustc Test \
@@ -16,6 +19,6 @@ RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot
1619
--runs All \
1720
--rustdoc $bindir/rustdoc \
1821
$BENCH_INCLUDE_EXCLUDE_OPTS
19-
code=$?
22+
2023
kill $PING_LOOP_PID
21-
exit $code
24+
exit 0

ci/check-profiling.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
#
3+
# This script is basically just a smoke test. It tests a couple of the
4+
# profiling tools (those that don't require installling additional things) on a
5+
# few benchmarks.
6+
7+
set -e -x;
8+
9+
bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
10+
PING_LOOP_PID=$!
11+
trap 'kill $PING_LOOP_PID' ERR
12+
13+
# Install a toolchain.
14+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
15+
bindir=`cargo run -p collector --bin collector install_next`
16+
17+
# Profile with eprintln.
18+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
19+
cargo run -p collector --bin collector -- \
20+
profile_local eprintln $bindir/rustc Test \
21+
--cargo $bindir/cargo \
22+
--include helloworld \
23+
--runs Full
24+
25+
# Check that Check/Debug/Opt files are present, and that Doc files aren't
26+
# present, becuase they're not done by default.
27+
test -f results/eprintln-Test-helloworld-Check-Full
28+
test -f results/eprintln-Test-helloworld-Debug-Full
29+
test -f results/eprintln-Test-helloworld-Opt-Full
30+
test ! -e results/eprintln-Test-helloworld-Doc-Full
31+
32+
# Profile with perf.
33+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
34+
cargo run -p collector --bin collector -- \
35+
profile_local perf-record $bindir/rustc Test \
36+
--builds Debug \
37+
--cargo $bindir/cargo \
38+
--include futures \
39+
--runs IncrUnchanged
40+
41+
# Check the expected output is present.
42+
test -f results/perf-Test-futures-Debug-IncrUnchanged
43+
44+
kill $PING_LOOP_PID
45+
exit 0

0 commit comments

Comments
 (0)