-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy is slow when type checking torch #17919
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
Comments
If this is accurate, maybe the fscache exception handling is really slowing us down in the mypyc build. mypyc: interpreted: |
Mypy detects an import cycle with 945 modules. Overall 1380 files were parsed, so 68% of processed files are in this one SCC. I've seen this pattern in other third-party packages as well -- the majority of the implementation is a single SCC. A potential way to make the SCC smaller would be to process imports lazily in third-party modules (where this is possible, since errors aren't reported). It may be tricky to implement though, but I'll think about it more. |
Yeah, lazy import resolution could be a massive perf win |
#17924 is the issue for tracking lazy resolution Jukka's times in #17920 (comment) are much better than mine. #17948 is the issue for tracking performance improvements in my work environment. |
Performance is now a lot better, but I bet there are still some good opportunities to make this faster. Fresh CPU profiles would be interesting to see. |
Here's a new profile for 5313497 ! Install torch, along with a few extra dependencies:
Then I get the following on Python 3.11:
Here's the output of:
(I realised py-spy also supports |
@hauntsaninja I've merged some additional optimizations. It would be interesting to see if the numbers have improved. |
They have indeed improved! With this env on Python 3.11:
Running the following:
I get:
So latest master is 1.27x faster on incremental and 1.07x faster on non-incremental compared to 1.13 |
We use a lot of torch at work, performance is probably the biggest reason folks at work switch to a different type checker.
The text was updated successfully, but these errors were encountered: