Skip to content

Merge pull request #8 from bluedynamics/optimize/lazy-memo-sync #58

Merge pull request #8 from bluedynamics/optimize/lazy-memo-sync

Merge pull request #8 from bluedynamics/optimize/lazy-memo-sync #58

Workflow file for this run

name: Release
on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
# Python versions to build wheels for (must match pyproject.toml requires-python
# and be supported by the PyO3 version in Cargo.toml)
PYTHON_TARGETS: "-i 3.10 -i 3.11 -i 3.12 -i 3.13 -i 3.14"
jobs:
ci:
uses: ./.github/workflows/ci.yml
linux:
needs: ci
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-24.04-arm
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist ${{ env.PYTHON_TARGETS }}
manylinux: auto
rustup-components: llvm-tools
# PGO: Profile-guided optimization. Both targets build natively
# on their respective runners, so PGO works for all Linux wheels.
before-script-linux: |
set -e
echo "::group::PGO: Instrumented build + profiling"
# Find best available Python (prefer 3.13, fallback to newest 3.x)
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp313-cp313' -type d 2>/dev/null | head -1)
if [ -z "$PYDIR" ]; then
PYDIR=$(find /opt/python -maxdepth 1 -name 'cp3*' -type d 2>/dev/null | sort -V | tail -1)
fi
if [ -z "$PYDIR" ] || [ ! -x "$PYDIR/bin/python" ]; then
echo "PGO: No suitable Python found in container, skipping PGO"
echo "::endgroup::"
exit 0
fi
PYTHON="$PYDIR/bin/python"
echo "PGO: Using $PYTHON"
# 1. Install ZODB+BTrees for FileStorage benchmarks
$PYTHON -m pip install --quiet ZODB BTrees
# 2. Instrumented build
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" maturin develop --release -i $PYTHON
# 3. Generate profile data with real + synthetic workloads
gunzip -k benchmarks/bench_data/Data.fs.gz
$PYTHON benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
$PYTHON benchmarks/bench.py synthetic --iterations 2000
# 4. Merge profiles and set RUSTFLAGS for the final build
LLVM_PROFDATA=$(find /root/.rustup -name llvm-profdata 2>/dev/null | head -1 || true)
if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then
$LLVM_PROFDATA merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw
export RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
echo "::endgroup::"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist
macos:
needs: ci
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: macos-15-intel
target: x86_64
- runner: macos-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: PGO profiling
run: |
set -e
rustup component add llvm-tools
python -m venv .pgo-venv
source .pgo-venv/bin/activate
pip install maturin ZODB BTrees
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" maturin develop --release
gunzip -k benchmarks/bench_data/Data.fs.gz
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
python benchmarks/bench.py synthetic --iterations 2000
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" -name llvm-profdata | head -1)
if [ -n "$LLVM_PROFDATA" ] && ls /tmp/pgo-data/*.profraw 1>/dev/null 2>&1; then
"$LLVM_PROFDATA" merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data/*.profraw
echo "RUSTFLAGS=-Cprofile-use=/tmp/pgo-data/merged.profdata" >> "$GITHUB_ENV"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist ${{ env.PYTHON_TARGETS }}
- uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist
windows:
needs: ci
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
architecture: x64
- name: PGO profiling
shell: bash
run: |
set -e
rustup component add llvm-tools
python -m venv .pgo-venv
source .pgo-venv/Scripts/activate
pip install maturin ZODB BTrees
PGO_DIR="$(cygpath -m "$(pwd)")/pgo-data"
mkdir -p "$PGO_DIR"
RUSTFLAGS="-Cprofile-generate=$PGO_DIR" maturin develop --release
gunzip -k benchmarks/bench_data/Data.fs.gz
python benchmarks/bench.py filestorage benchmarks/bench_data/Data.fs
python benchmarks/bench.py synthetic --iterations 2000
LLVM_PROFDATA=$(find "$(rustc --print sysroot)" \( -name llvm-profdata -o -name llvm-profdata.exe \) | head -1)
if [ -n "$LLVM_PROFDATA" ] && ls "$PGO_DIR"/*.profraw 1>/dev/null 2>&1; then
"$LLVM_PROFDATA" merge -o "$PGO_DIR/merged.profdata" "$PGO_DIR"/*.profraw
echo "RUSTFLAGS=-Cprofile-use=$PGO_DIR/merged.profdata" >> "$GITHUB_ENV"
echo "PGO: Building with merged profile data"
else
echo "PGO: No profile data found, building without PGO"
fi
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x64
args: --release --out dist ${{ env.PYTHON_TARGETS }}
- uses: actions/upload-artifact@v4
with:
name: wheels-windows-x64
path: dist
sdist:
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
# Upload to Test PyPI on every push to main
release-test-pypi:
name: Publish to test.pypi.org
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [linux, macos, windows, sdist]
runs-on: ubuntu-latest
environment: release-test-pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
# Upload to real PyPI on GitHub Release
release-pypi:
name: Publish to pypi.org
if: github.event.action == 'published'
needs: [linux, macos, windows, sdist]
runs-on: ubuntu-latest
environment: release-pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1