Skip to content

Recent performance regressions #18991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JukkaL opened this issue Apr 28, 2025 · 4 comments
Open

Recent performance regressions #18991

JukkaL opened this issue Apr 28, 2025 · 4 comments
Labels
bug mypy got something wrong performance

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 28, 2025

I was looking at self check benchmark results, and I noticed that there were some potential recent performance regressions. Here is a summary:

#18845 looks like noise and probably isn't a regression.

It would be good to see if we can reduce the impact of these.

I'm wondering if we could only perform the additional passes introduced in #18433 only when the first pass actually generates an error that we want to fix. If that's the case, we'd discard the errors and apply the new logic.

(Note that the December regression is due to switching from Python 3.8 to 3.13, which is less efficient for our workload.)

cc @tyralla and @ilevkivskyi

@JukkaL JukkaL added bug mypy got something wrong performance labels Apr 28, 2025
@JelleZijlstra
Copy link
Member

Python 3.8 to 3.13, which is less efficient for our workload

That's pretty surprising since 3.11 is generally much faster. It might be worth looking into why mypy is slower on a newer version and if that's something we can fix in CPython.

@tyralla
Copy link
Collaborator

tyralla commented Apr 28, 2025

I'm wondering if we could only perform the additional passes introduced in #18433 only when the first pass actually generates an error that we want to fix. If that's the case, we'd discard the errors and apply the new logic.

8.7 % is much more than I would have expected. Thanks for pointing it out. I should be able to experiment with your idea at the weekend. (I would want to revisit this code anyhow because of #18606.)

@JukkaL
Copy link
Collaborator Author

JukkaL commented Apr 28, 2025

I think much of the performance regression was from the new reference counting approach introduced in 3.12. #18459 reduced the impact a little.

3.11 is generally faster when running mypy without compilation, but compiled mypy mostly relies on the C API, which hasn't been getting much faster. This is a reasonable tradeoff for Python in general -- most workloads spend a larger fraction of time in the interpreter compared to the C API.

@ilevkivskyi
Copy link
Member

OK, I will try to mitigate the performance regression from my PR. I have two ideas:

  • Skip overlap check in bind_self() if we know the argument was already handled by check_self_arg(), this should remove some duplicate work.
  • Skip both checks completely if the original method has unannotated self. This may require some extra memory for a boolean flag on FuncDef, but it will likely be very minor.

I initially wanted to include those in #18943, but it looks like a separate PR may be OK as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong performance
Projects
None yet
Development

No branches or pull requests

4 participants