Skip to content

[ty] Benchmark NumPy and its tests in CI - #30262

Open
AlexWaygood wants to merge 4 commits into
charlie/ty-unyt-set-inferencefrom
alex/ty-numpy-benchmark
Open

AlexWaygood wants to merge 4 commits into
charlie/ty-unyt-set-inferencefrom
alex/ty-numpy-benchmark

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Stacked on #30241.

Add NumPy to the ty walltime benchmarks alongside pandas and colour-science. The benchmark checks the entire numpy package at the revision from astral-sh/ty#4990. This includes the parametrized test whose list of NumPy functions exposed the slowdown. The issue reduces that list to a single entry, [np.inner].

This benchmark would have caught the severe performance regression fixed by #30241. On CodSpeed, the median time for a multithreaded NumPy check was 5m05s on main without #30241 (9d2a566, one run). On this branch with #30241 (1477022), the median of six per-run medians was 17.07s. Each run took two samples on the same type of runner. That makes #30241 about 18× faster than main in this comparison1.

CI cost

The separate CI runs below compare the existing suite on main with the suite including NumPy on this PR.

Elapsed time main This PR (0b1e552) Difference
All benchmark jobs, from the first job starting to the last finishing (including builds) 11m34s 11m40s +6s
Run benchmarks step for the ty walltime suite 2m31s 3m07s +36s

The ty walltime step took 36 seconds longer in the PR run, but the instrumented ty shard simulation: micro-2 finished last in both runs.

Run-to-run variability

Across six CodSpeed runs of the same benchmark binary, NumPy's per-run medians ranged from 15.17s to 19.02s, a 25% increase from fastest to slowest. By relative standard deviation, it was about 14× more variable than pandas, the next most variable benchmark in the ty walltime suite. Fastest NumPy run · Slowest NumPy run

Benchmark Samples per run Relative standard deviation of run medians
NumPy 2 8.43%
pandas 2 0.59%
SymPy 2 0.53%
Altair (multithreaded) 8 0.48%
colour-science 2 0.42%

The other five benchmarks each had a relative standard deviation below 0.46%. Even on the same physical runner, NumPy's median was 19.02s, 17.43s, and 16.71s in three separate runs. Run 1 · Run 2 · Run 6

With this much variation, a single 10% change is hard to interpret. We'll probably want a relatively high threshold for CodSpeed to comment on NumPy regressions or improvements. The benchmark is still worth running in CI to catch pathological regressions like the one fixed in #30241.

Footnotes

  1. The [ty] Keep callable-local type variables out of enclosing constraints #30241 numbers also include two subsequent ty inference changes on main ([ty] Share predicate evaluations within an inference region #30235 and [ty] Record exception checkpoints for nested unpacking targets #30206) ↩

@AlexWaygood AlexWaygood added ci Related to internal CI tooling ty The ty type checker labels Nov 10, 2026
@AlexWaygood
AlexWaygood changed the base branch from main to charlie/ty-unyt-set-inference November 10, 2026 12:14
@AlexWaygood
AlexWaygood force-pushed the alex/ty-numpy-benchmark branch from 3bd3d9e to e55b52c Compare November 10, 2026 12:19
@codspeed

codspeed Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 5.86%

⚡ 1 improved benchmark
✅ 335 untouched benchmarks
🆕 1 new benchmark
⏩ 16 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Walltime lint_cached[typeshed] 19.8 ms 18.7 ms +5.86%
🆕 Walltime numpy N/A 14 s N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing alex/ty-numpy-benchmark (a3a124b) with charlie/ty-unyt-set-inference (1d30c42)

Open in CodSpeed

Footnotes

  1. 16 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@MichaReiser

Copy link
Copy Markdown
Member

Uff, 400s 😆

@AlexWaygood

Copy link
Copy Markdown
Member Author

Uff, 400s 😆

it just went down to 83s after rebasing on #30241 ;)

@MichaReiser

Copy link
Copy Markdown
Member

It's still 6x as long as any other benchmark. Does it reduce walltime if we run it multithreaded?

@AlexWaygood

Copy link
Copy Markdown
Member Author

Does it reduce walltime if we run it multithreaded?

looking

@AlexWaygood

Copy link
Copy Markdown
Member Author

It should be a 4.56x speedup to run it multithreaded, per codex. Running it in CI now.

@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.

Thank you

@AlexWaygood
AlexWaygood added this pull request to stack #30271 November 10, 2026 15:57
@dcreager

Copy link
Copy Markdown
Member

I've made some changes to #30241 and have taken care of the rebase to keep this up to date

@dcreager
dcreager force-pushed the alex/ty-numpy-benchmark branch from 1477022 to a3a124b Compare November 10, 2026 18:28
@dcreager
dcreager deployed to automations November 10, 2026 18:29 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
automations — a3a124bc Deployed Nov 10, 2026 by dcreager via security-review / security review #98043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Related to internal CI tooling ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants