Skip to content
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

check_overlapping_overloads is slow and often not needed #9691

Closed
hauntsaninja opened this issue Nov 3, 2020 · 2 comments · Fixed by #10922
Closed

check_overlapping_overloads is slow and often not needed #9691

hauntsaninja opened this issue Nov 3, 2020 · 2 comments · Fixed by #10922
Labels

Comments

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Nov 3, 2020

To Reproduce

With pure Python mypy:

~/dev/mypy master λ cat test.py   
import subprocess

~/dev/mypy master λ hyperfine -w 1 -M 5 'python -m mypy -m test --no-incremental'
Benchmark #1: python -m mypy -m test --no-incremental
  Time (mean ± σ):     10.316 s ±  0.955 s    [User: 9.301 s, System: 0.287 s]
  Range (min … max):    9.425 s … 11.452 s    5 runs

~/dev/mypy master λ vim mypy/checker.py
# change check_overlapping_overloads to early return

~/dev/mypy master λ hyperfine -w 1 -M 5 'python -m mypy -m test --no-incremental'
Benchmark #1: python -m mypy -m test --no-incremental
  Time (mean ± σ):      4.409 s ±  0.047 s    [User: 4.163 s, System: 0.191 s]
  Range (min … max):    4.346 s …  4.457 s    5 runs

The difference is substantial even for empty files. This would roughly halve the time it takes to run command line tests.

Proposal

As far as I can tell, check_overlapping_overloads does a lot of work to find problems which often don't get reported (and has no other side effects). Maybe we can just skip the call if self.msg.disable_count <= 0? But maybe this is a dangerous precedent to set.

@hauntsaninja hauntsaninja added bug mypy got something wrong performance labels Nov 3, 2020
@JukkaL
Copy link
Collaborator

JukkaL commented Mar 10, 2021

Maybe disable the checks when checking stubs? We don't report errors in stubs, I think. Overloads aren't very common outside stubs.

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 10, 2021

I think that something needs to be done to improve the situation, so I'm making this high priority.

hauntsaninja pushed a commit to hauntsaninja/mypy that referenced this issue Aug 4, 2021
Resolves python#9691

As mentioned in that issue, this is a huge performance win. On the
codebase I'm currently working on, it halves a cacheless mypy runtime.
The linked issue contains another measurement.
hauntsaninja pushed a commit to hauntsaninja/mypy that referenced this issue Aug 4, 2021
Resolves python#9691

As mentioned in that issue, this is a huge performance win. On the
codebase I'm currently working on, it halves a cacheless interpreted
mypy runtime. The linked issue contains some more measurement.
msullivan pushed a commit that referenced this issue Aug 4, 2021
Resolves #9691

As mentioned in that issue, this is a huge performance win. On the
codebase I'm currently working on, it halves a cacheless interpreted
mypy runtime. The linked issue contains some more measurement.

Co-authored-by: hauntsaninja <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants