-
Notifications
You must be signed in to change notification settings - Fork 126
140 lines (124 loc) · 4.74 KB
/
bench.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Bench
on:
push:
pull_request:
workflow_call:
env:
CARGO_PROFILE_BENCH_BUILD_OVERRIDE_DEBUG: true
CARGO_PROFILE_RELEASE_DEBUG: true
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
TOOLCHAIN: nightly
jobs:
bench:
name: Benchmark
runs-on: self-hosted
defaults:
run:
shell: bash
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: $TOOLCHAIN
components: rustfmt
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.4
- name: Configure Rust
run: |
echo "RUSTFLAGS=-C link-arg=-fuse-ld=lld -C link-arg=-Wl,--no-rosegment" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
cargo install flamegraph
- name: Checkout
uses: actions/checkout@v4
- name: Fetch NSS and NSPR
run: |
hg clone https://hg.mozilla.org/projects/nspr "$NSPR_DIR"
hg clone https://hg.mozilla.org/projects/nss "$NSS_DIR"
echo "NSS_DIR=$NSS_DIR" >> "$GITHUB_ENV"
echo "NSPR_DIR=$NSPR_DIR" >> "$GITHUB_ENV"
env:
NSS_DIR: ${{ github.workspace }}/nss
NSPR_DIR: ${{ github.workspace }}/nspr
- name: Build
run: |
cargo +$TOOLCHAIN bench --features bench --no-run
cargo +$TOOLCHAIN build --release --bin neqo-client --bin neqo-server
echo "LD_LIBRARY_PATH=${{ github.workspace }}/dist/Debug/lib" >> "$GITHUB_ENV"
# Disable turboboost, hyperthreading and use performance governor.
- name: Prepare machine
run: |
sudo /root/bin/prep.sh
echo "PERF_CMD=record -o perf.data -F997 --call-graph dwarf,16384 -g" >> "$GITHUB_ENV"
# Pin the benchmark run to core 0 and run all benchmarks at elevated priority.
- name: Benchmark
run: |
nice -n -20 taskset -c 0 \
cargo +$TOOLCHAIN bench --features bench | tee output.txt
# Pin the transfer benchmark to core 0 and run it at elevated priority inside perf.
# Work around https://github.com/flamegraph-rs/flamegraph/issues/248 by passing explicit perf arguments.
- name: Perf transfer benchmark
run: |
nice -n -20 taskset -c 0 \
cargo +$TOOLCHAIN flamegraph -v -c "$PERF_CMD" --features bench --bench transfer -- \
--bench --exact "Run multiple transfers with varying seeds"
- name: Benchmark a client/server transfer
run: |
mkdir server && \
cd server && \
nice -n -20 taskset -c 0 \
cargo +$TOOLCHAIN flamegraph -v -c "$PERF_CMD" \
--bin neqo-server -- $HOST:4433 &
PID=$!
mkdir client && \
cd client && \
nice -n -20 taskset -c 1 \
cargo +$TOOLCHAIN flamegraph -v -c "$PERF_CMD" \
--bin neqo-client -- --output-dir . https://$HOST:4433/$SIZE
kill $PID
[ "$(wc -c < client/"$SIZE")" -eq "$SIZE" ] || exit 1
env:
HOST: localhost
SIZE: 7654321
# Re-enable turboboost, hyperthreading and use powersave governor.
- name: Restore machine
run: sudo /root/bin/unprep.sh
if: success() || failure()
- name: Download previous benchmark results
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
# TODO: Wait for this action to be allowlisted. And then figure out how to only upload
# benchmark data when the main branch is being updated (e.g., if: ${{ github.ref == "refs/heads/main" }})
# - name: Store current benchmark results
# uses: benchmark-action/github-action-benchmark@v1
# with:
# tool: 'cargo'
# output-file-path: output.txt
# external-data-json-path: ./cache/benchmark-data.json
# fail-on-alert: true
# github-token: ${{ secrets.GITHUB_TOKEN }}
# comment-on-alert: true
# summary-always: true
- name: Convert for profiler.firefox.com
run: |
perf script -i perf.data -F +pid > transfer.perf &
perf script -i client/perf.data -F +pid > client.perf &
perf script -i server/perf.data -F +pid > server.perf &
wait
mv flamegraph.svg transfer.svg
mv client/flamegraph.svg client.svg
mv server/flamegraph.svg server.svg
rm neqo.svg
- name: Archive perf data
uses: actions/upload-artifact@v4
with:
name: ${{ github.head_ref || github.ref_name }}-perf
path: |
*.svg
*.perf
output.txt
target/criterion
compression-level: 9