-
Notifications
You must be signed in to change notification settings - Fork 247
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
83ff1cf
commit 49bcd51
Showing
5 changed files
with
226 additions
and
64 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 self schema | ||
shell: bash | ||
# generate up front so that we don't have to do this inside the docker container | ||
run: uv run python generate_self_schema.py | ||
|
||
- 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 | ||
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: | | ||
uv sync --group testing | ||
uv pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall | ||
uv run pytest tests/benchmarks | ||
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 | ||
|
||
- name: merge pgo data | ||
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata | ||
shell: bash | ||
|
||
- 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 | ||
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 |
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
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
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
Oops, something went wrong.