Skip to content

[ty] Adapt many_enum_members benchmark#24203

Merged
sharkdp merged 4 commits intomainfrom
david/modify-many_enum_members-benchmark
Mar 26, 2026
Merged

[ty] Adapt many_enum_members benchmark#24203
sharkdp merged 4 commits intomainfrom
david/modify-many_enum_members-benchmark

Conversation

@sharkdp
Copy link
Copy Markdown
Contributor

@sharkdp sharkdp commented Mar 26, 2026

Summary

This changes the many_enum_members benchmark from this structure:

class E(Enum):
    m1 = 1
    m2 = 2
    ...

print(E.m1)
print(E.m2)
...

to this structure:

class E(Enum):
    m1 = 1
    m2 = 2
    ...

print((E.m1, E.m2, …))

The idea here is to make this benchmark less susceptible to changes in our reachability constraints (that we record for print calls). The idea of the print statements was only to have "uses" of these enum members. It was never the idea to be an example of 512 function calls in sequence.

I'm certainly not trying to hide the fact that this benchmark revealed a huge regression in #23245. But it did so for the wrong reasons. We would have already had that regression on main if those print calls would have been inside another function scope. And so it seems fair to change the benchmark before we proceed with #23245 (which shows no regressions elsewhere, and even leads to performance improvements in real world projects).

Adding Alex here as a reviewer since we discussed this in person.

@sharkdp sharkdp added internal An internal refactor or improvement ty Multi-file analysis & type inference labels Mar 26, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 26, 2026

Merging this PR will improve performance by 7.81%

⚡ 1 improved benchmark
✅ 57 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ty_micro[many_enum_members] 100.3 ms 93 ms +7.81%

Comparing david/modify-many_enum_members-benchmark (f8e98fe) with main (203a6b3)

Open in CodSpeed

@sharkdp sharkdp marked this pull request as ready for review March 26, 2026 12:54
@astral-sh-bot astral-sh-bot bot requested a review from AlexWaygood March 26, 2026 12:54
@sharkdp sharkdp enabled auto-merge (squash) March 26, 2026 13:00
@sharkdp sharkdp disabled auto-merge March 26, 2026 13:00
@sharkdp sharkdp enabled auto-merge (squash) March 26, 2026 13:00
@sharkdp sharkdp merged commit 207232c into main Mar 26, 2026
45 checks passed
@sharkdp sharkdp deleted the david/modify-many_enum_members-benchmark branch March 26, 2026 13:04
sharkdp added a commit that referenced this pull request Mar 26, 2026
## Summary

We previously avoided recording `IsNonTerminalCall` calls in global
scope (non-function scopes, to be precise) because we were worried about
the performance implications. However, it turns out that this does not
cause any slowdowns in our real world ty benchmarks (but see
#24203). There is also no dramatic
change in the ecosystem timings.

closes astral-sh/ty#2480

## Ecosystem

Two false positives removed.

## Test Plan

Adapted previously existing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants