Skip to content

Enable PGO for Linux ARM64 ty releases - #4218

Merged
charliermarsh merged 4 commits into
charlie/ty-pgo-windows-x64from
charlie/ty-pgo-linux-arm64
Aug 11, 2026
Merged

charliermarsh merged 4 commits into
charlie/ty-pgo-windows-x64from
charlie/ty-pgo-linux-arm64

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR enables PGO for ty's Linux ARM64 releases, following the approach outlined in #4213. (To enable PGO, we also move to a native ARM64 runner.) The existing jemalloc page-size configuration is preserved.

Across four held-out Linux ARM64 projects, ty check uses 15.0% less CPU and finishes 11.9% faster. The release binary gets 4.9% smaller, the wheel gets 1.2% smaller, and the release archive gets 1.4% smaller.

The Linux ARM64 PGO build uses an eight-core Depot runner, reducing its runtime from 14m 51s on a four-core GitHub runner to 11m 37s (22%). In the matched full-stack run, eight-core Linux x86-64 finished in 11m 28s and Namespace Windows finished in 12m 24s, making Windows the release bottleneck.

@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 8be52f8 to 9c79de3 Compare August 10, 2026 14:12
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 9c79de3 to 307e582 Compare August 10, 2026 14:53
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 307e582 to 47c34be Compare August 10, 2026 14:56
@charliermarsh charliermarsh added the release Related to the release process label Aug 10, 2026
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 47c34be to a078288 Compare August 10, 2026 20:21
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from a078288 to 9d97ab5 Compare August 10, 2026 22:58
@charliermarsh
charliermarsh marked this pull request as ready for review August 10, 2026 23:16

@MichaReiser MichaReiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand your summary correctly, that this does not improve performance?

@charliermarsh

Copy link
Copy Markdown
Member Author

No, that's not implied. I just didn't run the results since I need an ARM machine (much like the Windows build) and I'll have to do a dedicated pass to generate them.

@charliermarsh

Copy link
Copy Markdown
Member Author

Added (via GitHub Actions so YMMV!).

@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 9d97ab5 to 2f7f355 Compare August 11, 2026 13:41
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 2f7f355 to aad7848 Compare August 11, 2026 15:28
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch 3 times, most recently from 9c52fa3 to c7c06f9 Compare August 11, 2026 16:19
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from c7c06f9 to 0508ad8 Compare August 11, 2026 17:56
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 91ecfe6 to 466c856 Compare August 11, 2026 19:49
@charliermarsh
charliermarsh force-pushed the charlie/ty-pgo-linux-arm64 branch from 466c856 to 241c75f Compare August 11, 2026 20:05
@charliermarsh
charliermarsh merged commit df9bad1 into main Aug 11, 2026
34 checks passed
@charliermarsh
charliermarsh deleted the charlie/ty-pgo-linux-arm64 branch August 11, 2026 22:23
charliermarsh added a commit that referenced this pull request Aug 11, 2026
## Summary

This PR enables PGO for ty releases, starting with Linux x86-64. The
approach follows that outlined in
astral-sh/ruff#27570.

### Design

The release pipeline is modified as follows:

- We build an instrumented release binary using the Rust toolchain
pinned by the Ruff submodule.
- We run `ty check` on the same ten pinned ecosystem projects used by
Ruff. In total, the corpus contains 618 Python and stub files.
- We also exercise `ty server` against a temporary project, covering
diagnostics, hover, go-to-definition, completion, and incremental
cross-file edits.
- We merge the profiles via `llvm-profdata`.
- We derive LLVM's hot-code threshold from the profile's 95th
percentile, matching its size-optimization threshold and avoiding
unnecessary expansion of moderately hot functions. (Without this,
performance was marginally better, but wheel size _increased_ by 5-10%!)
- We feed the result back into the existing `maturin` build.

### Results

Here's the initial, untuned PGO performance on seven held-out projects
(and language-server performance on three held-out projects):

| Held-out project | `ty check` | Incremental edits |
| --- | ---: | ---: |
| Black | 7.1% faster | 17.1% faster |
| isort | 13.3% faster | 18.1% faster |
| Jinja | 5.5% faster | 13.7% faster |
| Django | 25.5% faster | — |
| pandas | 15.9% faster | — |
| scikit-learn | 19.6% faster | — |
| SymPy | 21.5% faster | — |
| Geometric mean | **15.8% faster** | **16.3% faster** |

As an aside, profiling the language server explicitly (i.e., including
the language server commands in the PGO training) improved
incremental-edit latency by another 7.6% over CLI-only PGO; without that
training, incremental edit performance was _still_ up (but not quite as
much).

Beyond raw performance, with the tuned PGO settings, we see the
following results:

- **Binary size decreased by 7.98%** (28.10 MB to 25.86 MB compared with
non-PGO).
- **Wheel size decreased by 1.32%** (12.71 MB to 12.54 MB compared with
non-PGO), and by 14.11% compared with untuned PGO.
- **Release archive size decreased by 1.53%** (12.35 MB to 12.16 MB
compared with non-PGO), and by 14.25% compared with untuned PGO.
- **Incremental language-server edits are 3.30% faster than untuned
PGO**.
- **Linux x86-64 release build finishes in 11m28s on eight-core Depot**,
compared with 12m59s on four-core Depot and 15m45s on the previous
GitHub runner. The full-stack bottleneck shifts to Windows at 12m24s;
other Linux targets retain their four-core runners.

### Stack

Additional platforms are covered in subsequent PRs:

- macOS ARM64: #4216
- Windows x86-64: #4217
- Linux ARM64: #4218

Ruff and uv follow the same approach; see
astral-sh/ruff#27570 and
astral-sh/uv#21001.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Related to the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants