Skip to content

Commit 8f242b7

Browse files
jensensclaude
andcommitted
Fix PGO profiling in release CI across all platforms
- Linux: robust Python finder with fallback (cp313 may not exist in manylinux2014) - macOS/Windows: create virtualenv for maturin develop (requires venv) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8e1f348 commit 8f242b7

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,19 @@ jobs:
4747
before-script-linux: |
4848
set -e
4949
echo "::group::PGO: Instrumented build + profiling"
50-
PYTHON=$(find /opt/python -maxdepth 1 -name 'cp313-cp313' -type d | head -1)/bin/python
50+
# Find best available Python (prefer 3.13, fallback to newest 3.x)
51+
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp313-cp313' -type d 2>/dev/null | head -1)
52+
if [ -z "$PYDIR" ]; then
53+
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp3*' -type d 2>/dev/null | sort -V | tail -1)
54+
fi
55+
if [ -z "$PYDIR" ] || [ ! -x "$PYDIR/bin/python" ]; then
56+
echo "PGO: No suitable Python found in container, skipping PGO"
57+
echo "::endgroup::"
58+
exit 0
59+
fi
60+
PYTHON="$PYDIR/bin/python"
61+
echo "PGO: Using $PYTHON"
62+
5163
# 1. Install ZODB+BTrees for FileStorage benchmarks
5264
$PYTHON -m pip install --quiet ZODB BTrees
5365
@@ -93,11 +105,12 @@ jobs:
93105
run: |
94106
set -e
95107
rustup component add llvm-tools
96-
pip install maturin ZODB BTrees
97-
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" maturin develop --release
108+
python -m venv .pgo-venv
109+
.pgo-venv/bin/pip install maturin ZODB BTrees
110+
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" .pgo-venv/bin/maturin develop --release
98111
gunzip -k benchmarks/bench_data/Data.fs.gz
99-
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
100-
python benchmarks/bench.py synthetic --iterations 2000
112+
.pgo-venv/bin/python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
113+
.pgo-venv/bin/python benchmarks/bench.py synthetic --iterations 2000
101114
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" -name llvm-profdata | head -1)
102115
if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then
103116
"$LLVM_PROFDATA" merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw
@@ -130,13 +143,14 @@ jobs:
130143
run: |
131144
set -e
132145
rustup component add llvm-tools
133-
pip install maturin ZODB BTrees
146+
python -m venv .pgo-venv
147+
.pgo-venv/Scripts/pip install maturin ZODB BTrees
134148
PGO_DIR="$(pwd)/pgo-data"
135149
mkdir -p "$PGO_DIR"
136-
RUSTFLAGS="-Cprofile-generate=$PGO_DIR" maturin develop --release
150+
RUSTFLAGS="-Cprofile-generate=$PGO_DIR" .pgo-venv/Scripts/maturin develop --release
137151
gunzip -k benchmarks/bench_data/Data.fs.gz
138-
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
139-
python benchmarks/bench.py synthetic --iterations 2000
152+
.pgo-venv/Scripts/python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
153+
.pgo-venv/Scripts/python benchmarks/bench.py synthetic --iterations 2000
140154
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" \( -name llvm-profdata -o -name llvm-profdata.exe \) | head -1)
141155
if [ -n "$LLVM_PROFDATA" ] && ls "$PGO_DIR"/*.profraw 1>/dev/null 2>&1; then
142156
"$LLVM_PROFDATA" merge -o "$PGO_DIR/merged.profdata" "$PGO_DIR"/*.profraw

0 commit comments

Comments
 (0)