|
47 | 47 | before-script-linux: | |
48 | 48 | set -e |
49 | 49 | 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 | +
|
51 | 63 | # 1. Install ZODB+BTrees for FileStorage benchmarks |
52 | 64 | $PYTHON -m pip install --quiet ZODB BTrees |
53 | 65 |
|
@@ -93,11 +105,12 @@ jobs: |
93 | 105 | run: | |
94 | 106 | set -e |
95 | 107 | 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 |
98 | 111 | 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 |
101 | 114 | LLVM_PROFDATA=$(find "$(rustc --print sysroot)" -name llvm-profdata | head -1) |
102 | 115 | if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then |
103 | 116 | "$LLVM_PROFDATA" merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw |
@@ -130,13 +143,14 @@ jobs: |
130 | 143 | run: | |
131 | 144 | set -e |
132 | 145 | 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 |
134 | 148 | PGO_DIR="$(pwd)/pgo-data" |
135 | 149 | 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 |
137 | 151 | 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 |
140 | 154 | LLVM_PROFDATA=$(find "$(rustc --print sysroot)" \( -name llvm-profdata -o -name llvm-profdata.exe \) | head -1) |
141 | 155 | if [ -n "$LLVM_PROFDATA" ] && ls "$PGO_DIR"/*.profraw 1>/dev/null 2>&1; then |
142 | 156 | "$LLVM_PROFDATA" merge -o "$PGO_DIR/merged.profdata" "$PGO_DIR"/*.profraw |
|
0 commit comments