Skip to content

Commit 2fc4b4b

Browse files
authored
Merge pull request #1333 from hodgesds/pgo-builds
build: Add script for pgo/lto builds
2 parents 8cbd073 + d55df9e commit 2fc4b4b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pgo-lto.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -eou pipefail
3+
4+
PGO_TMPDIR=${1:-/tmp/pgo-data}
5+
SCHED=${2:-scx_rustland}
6+
PGO_DUR=${3:-30}
7+
8+
rm -rf "$PGO_TMPDIR"
9+
mkdir -p "$PGO_TMPDIR"
10+
11+
RUSTFLAGS="-C profile-generate=$PGO_TMPDIR -C link-arg=-lgcov" \
12+
cargo build --release --bin "$SCHED"
13+
14+
echo "Running sched to generate PGO"
15+
for i in {0..3}; do
16+
sudo "./target/release/$SCHED" &
17+
sleep "$PGO_DUR"
18+
sudo kill -9 $! || echo "$SCHED already dead"
19+
sleep 1
20+
done
21+
22+
# Merge the `.profraw` files into a `.profdata` file
23+
llvm-profdata merge --failure-mode=warn \
24+
-o "$PGO_TMPDIR/merged.profdata" \
25+
"$PGO_TMPDIR"
26+
27+
# Use the `.profdata` file for guiding optimizations
28+
RUSTFLAGS="-Cprofile-use=$PGO_TMPDIR/merged.profdata" \
29+
cargo build --release --bin "$SCHED"
30+

0 commit comments

Comments
 (0)