Skip to content

Commit b9e0f5c

Browse files
authored
Merge branch 'main' into more-fail-fast
2 parents 5dd9abd + 4c02cbd commit b9e0f5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1682
-514
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build PGO wheel
2+
description: Builds a PGO-optimized wheel
3+
inputs:
4+
interpreter:
5+
description: 'Interpreter to build the wheel for'
6+
required: true
7+
rust-toolchain:
8+
description: 'Rust toolchain to use'
9+
required: true
10+
outputs:
11+
wheel:
12+
description: 'Path to the built wheel'
13+
value: ${{ steps.find_wheel.outputs.path }}
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: prepare self schema
18+
shell: bash
19+
# generate up front so that we don't have to do this inside the docker container
20+
run: uv run python generate_self_schema.py
21+
22+
- name: prepare profiling directory
23+
shell: bash
24+
# making this ahead of the compile ensures that the local user can write to this
25+
# directory; the maturin action (on linux) runs in docker so would create as root
26+
run: mkdir -p ${{ github.workspace }}/profdata
27+
28+
- name: build initial wheel
29+
uses: PyO3/maturin-action@v1
30+
with:
31+
manylinux: auto
32+
args: >
33+
--release
34+
--out pgo-wheel
35+
--interpreter ${{ inputs.interpreter }}
36+
rust-toolchain: ${{ inputs.rust-toolchain }}
37+
docker-options: -e CI
38+
env:
39+
RUSTFLAGS: '-Cprofile-generate=${{ github.workspace }}/profdata'
40+
41+
- name: detect rust host
42+
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
43+
shell: bash
44+
45+
- name: generate pgo data
46+
run: |
47+
uv sync --group testing
48+
uv pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
49+
uv run pytest tests/benchmarks
50+
RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2)
51+
rustup run ${{ inputs.rust-toolchain }} bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/$RUST_HOST/bin/llvm-profdata >> "$GITHUB_ENV"'
52+
shell: bash
53+
54+
- name: merge pgo data
55+
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
56+
shell: pwsh # because it handles paths on windows better, and works well enough on unix for this step
57+
58+
- name: build pgo-optimized wheel
59+
uses: PyO3/maturin-action@v1
60+
with:
61+
manylinux: auto
62+
args: >
63+
--release
64+
--out dist
65+
--interpreter ${{ inputs.interpreter }}
66+
rust-toolchain: ${{inputs.rust-toolchain}}
67+
docker-options: -e CI
68+
env:
69+
RUSTFLAGS: '-Cprofile-use=${{ github.workspace }}/merged.profdata'
70+
71+
- name: find built wheel
72+
id: find_wheel
73+
run: echo "path=$(ls dist/*.whl)" | tee -a "$GITHUB_OUTPUT"
74+
shell: bash

0 commit comments

Comments
 (0)