From ddafef12d07da2b99a5da596d369b9eae0112cec Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 7 Aug 2026 17:01:01 -0400 Subject: [PATCH 1/7] Enable PGO for Windows x86-64 ty releases --- .github/workflows/build-binaries.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index eb2d95833f..c6cb646113 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -209,6 +209,26 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform.arch }} + - name: "Install LLVM profiling tools" + id: pgo-toolchain + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + working-directory: ruff + shell: bash + run: | + rustup component add llvm-tools-preview + echo "toolchain=$(rustc --version | cut -d ' ' -f2)" >> "$GITHUB_OUTPUT" + - name: "Train PGO ty" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + shell: bash + run: | + export RUSTFLAGS="${RUSTFLAGS:+${RUSTFLAGS} }-C target-feature=+crt-static" + + python scripts/build_ty_pgo.py \ + --target "${{ matrix.platform.target }}" \ + --target-dir "${{ github.workspace }}/ruff/target/ty-pgo" \ + --train-only + + echo "RUSTFLAGS=${RUSTFLAGS:+${RUSTFLAGS} }-Cprofile-use=${{ github.workspace }}/ruff/target/ty-pgo/ty.profdata" >> "$GITHUB_ENV" - name: "Prep README.md" run: python scripts/transform_readme.py - name: "Build wheels" @@ -216,10 +236,24 @@ jobs: with: maturin-version: v1.14.1 target: ${{ matrix.platform.target }} + rust-toolchain: ${{ steps.pgo-toolchain.outputs.toolchain }} args: --release --locked --out dist --compatibility pypi env: # aarch64 build fails, see https://github.com/PyO3/maturin/issues/2110 XWIN_VERSION: 16 + - name: "Verify static Windows runtime" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + working-directory: ruff + shell: bash + run: | + LLVM_READOBJ="$(rustc --print sysroot)/lib/rustlib/${{ matrix.platform.target }}/bin/llvm-readobj.exe" + IMPORTS_FILE="$RUNNER_TEMP/ty-coff-imports.txt" + "$LLVM_READOBJ" --coff-imports "target/${{ matrix.platform.target }}/release/ty.exe" > "$IMPORTS_FILE" + + if grep -Eiq 'vcruntime[[:digit:]_]*\.dll|api-ms-win-crt-' "$IMPORTS_FILE"; then + echo "ty must not dynamically link the Visual C++ runtime" >&2 + exit 1 + fi - name: "Test wheel" if: ${{ !startsWith(matrix.platform.target, 'aarch64') }} shell: bash From bb96a9f31cd9c7837f95ee1bfc688476c1c7f714 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 10 Aug 2026 18:57:48 -0400 Subject: [PATCH 2/7] Apply profile-guided hotness tuning to Windows x86-64 ty releases --- .github/workflows/build-binaries.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index c6cb646113..e2d9e98a5b 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -228,7 +228,8 @@ jobs: --target-dir "${{ github.workspace }}/ruff/target/ty-pgo" \ --train-only - echo "RUSTFLAGS=${RUSTFLAGS:+${RUSTFLAGS} }-Cprofile-use=${{ github.workspace }}/ruff/target/ty-pgo/ty.profdata" >> "$GITHUB_ENV" + PROFILE_HOT_COUNT="$(cat "${{ github.workspace }}/ruff/target/ty-pgo/ty.profile-hot-count")" + echo "RUSTFLAGS=${RUSTFLAGS:+${RUSTFLAGS} }-Cprofile-use=${{ github.workspace }}/ruff/target/ty-pgo/ty.profdata -Cllvm-args=--profile-summary-hot-count=$PROFILE_HOT_COUNT" >> "$GITHUB_ENV" - name: "Prep README.md" run: python scripts/transform_readme.py - name: "Build wheels" From 1e8d1825d274865d03535ceb06374ffb39c34c16 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 11 Aug 2026 09:40:51 -0400 Subject: [PATCH 3/7] Install uv for Windows PGO training --- .github/workflows/build-binaries.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index e2d9e98a5b..9dc10d4255 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -209,6 +209,9 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform.arch }} + - name: "Install uv for PGO training" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 - name: "Install LLVM profiling tools" id: pgo-toolchain if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} From 0fd9fc40ed0a283246c136e2f0479043b588731e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 11 Aug 2026 11:27:45 -0400 Subject: [PATCH 4/7] Use a larger runner for Windows x86-64 PGO builds --- .github/workflows/build-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 9dc10d4255..a28a61b6b3 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -190,7 +190,7 @@ jobs: windows: if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: windows-latest + runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'github-windows-2025-x86_64-16' || 'windows-latest' }} strategy: matrix: platform: From 4ad7c205b4c155ba750dba059dd3c6a3aa132c78 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 11 Aug 2026 11:54:48 -0400 Subject: [PATCH 5/7] Benchmark eight-core Windows PGO builds --- .github/workflows/build-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index a28a61b6b3..278b930e46 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -190,7 +190,7 @@ jobs: windows: if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'github-windows-2025-x86_64-16' || 'windows-latest' }} + runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'github-windows-2025-x86_64-8' || 'windows-latest' }} strategy: matrix: platform: From 6cd4d239b48cdb3586450c30ef15707d94d448ec Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 11 Aug 2026 12:18:39 -0400 Subject: [PATCH 6/7] Benchmark 32-core Windows PGO builds --- .github/actionlint.yaml | 1 + .github/workflows/build-binaries.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index ed6dc0ebad..501431d329 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -7,5 +7,6 @@ self-hosted-runner: - depot-ubuntu-24.04-4 - depot-ubuntu-24.04-8 - namespace-profile-macos-15 + - depot-windows-2025-32 - github-windows-2025-x86_64-8 - github-windows-2025-x86_64-16 diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 278b930e46..e03da4226c 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -190,7 +190,7 @@ jobs: windows: if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'github-windows-2025-x86_64-8' || 'windows-latest' }} + runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'depot-windows-2025-32' || 'windows-latest' }} strategy: matrix: platform: From 98203f81824ed2563d6f54642063fea5f77b880a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 11 Aug 2026 13:56:04 -0400 Subject: [PATCH 7/7] Use Namespace for Windows x86-64 PGO builds --- .github/actionlint.yaml | 2 +- .github/workflows/build-binaries.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 501431d329..13c7160aaa 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -7,6 +7,6 @@ self-hosted-runner: - depot-ubuntu-24.04-4 - depot-ubuntu-24.04-8 - namespace-profile-macos-15 - - depot-windows-2025-32 + - namespace-profile-windows-2022-x86-64-16x32 - github-windows-2025-x86_64-8 - github-windows-2025-x86_64-16 diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index e03da4226c..d616ada180 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -190,7 +190,7 @@ jobs: windows: if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'depot-windows-2025-32' || 'windows-latest' }} + runs-on: ${{ github.repository == 'astral-sh/ty' && matrix.platform.target == 'x86_64-pc-windows-msvc' && 'namespace-profile-windows-2022-x86-64-16x32' || 'windows-latest' }} strategy: matrix: platform: