-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72fc9ef
commit 82df231
Showing
2 changed files
with
78 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Build PGO wheel | ||
description: Builds a PGO-optimized wheel | ||
inputs: | ||
interpreter: | ||
description: 'Interpreter to build the wheel for' | ||
required: true | ||
rust-toolchain: | ||
description: 'Rust toolchain to use' | ||
required: true | ||
outputs: | ||
wheel: | ||
description: 'Path to the built wheel' | ||
value: ${{ steps.find_wheel.outputs.path }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: prepare profiling directory | ||
shell: bash | ||
# making this ahead of the compile ensures that the local user can write to this | ||
# directory; the maturin action (on linux) runs in docker so would create as root | ||
run: mkdir -p ${{ github.workspace }}/profdata | ||
|
||
- name: build initial wheel | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
manylinux: auto | ||
args: > | ||
--release | ||
--out pgo-wheel | ||
--interpreter ${{ inputs.interpreter }} | ||
rust-toolchain: ${{ inputs.rust-toolchain }} | ||
docker-options: -e CI | ||
working-directory: crates/jiter-python | ||
env: | ||
RUSTFLAGS: '-Cprofile-generate=${{ github.workspace }}/profdata' | ||
|
||
- name: detect rust host | ||
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV" | ||
shell: bash | ||
|
||
- name: generate pgo data | ||
run: | | ||
pip install -U pip | ||
pip install -r tests/requirements.txt | ||
pip install jiter --no-index --no-deps --find-links pgo-wheel --force-reinstall | ||
python bench.py jiter jiter-cache | ||
RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) | ||
rustup run ${{ inputs.rust-toolchain }} bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/$RUST_HOST/bin/llvm-profdata >> "$GITHUB_ENV"' | ||
shell: bash | ||
working-directory: crates/jiter-python | ||
|
||
- name: merge pgo data | ||
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata | ||
shell: pwsh # because it handles paths on windows better, and works well enough on unix for this step | ||
|
||
- name: build pgo-optimized wheel | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
manylinux: auto | ||
args: > | ||
--release | ||
--out dist | ||
--interpreter ${{ inputs.interpreter }} | ||
rust-toolchain: ${{inputs.rust-toolchain}} | ||
docker-options: -e CI | ||
working-directory: crates/jiter-python | ||
env: | ||
RUSTFLAGS: '-Cprofile-use=${{ github.workspace }}/merged.profdata' | ||
|
||
- name: find built wheel | ||
id: find_wheel | ||
run: echo "path=$(ls dist/*.whl)" | tee -a "$GITHUB_OUTPUT" | ||
shell: bash | ||
working-directory: crates/jiter-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters