Skip to content

Slow incremental run when single module has errors #4135

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

Closed
JukkaL opened this issue Oct 19, 2017 · 5 comments
Closed

Slow incremental run when single module has errors #4135

JukkaL opened this issue Oct 19, 2017 · 5 comments
Assignees

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 19, 2017

mypy -i is slower than expected in the following scenario:

  • Check out fresh mypy repository
  • Create tiny module mypy.x that generates an error: echo '1 + ""' > mypy/x.py
  • Run mypy -i mypy
    • This takes a while, generates an error for mypy/x.py as expected
  • Run mypy -i mypy
    • This is as slow as the previous run, but caching should make this much faster
@JukkaL
Copy link
Collaborator Author

JukkaL commented Oct 19, 2017

@gvanrossum in #4130 (comment):

The performance problem is apparently not new -- I can reproduce this with standard -i mode as well. No cache entries for the mypy package are written somehow -- perhaps because mypy.x precedes all other submodules of mypy. This could be due to an edge case in the topsort.

@gvanrossum gvanrossum added the topic-daemon dmypy label Nov 7, 2017
@gvanrossum
Copy link
Member

Adding topic-daemon label because this impedes one of the important use cases for the daemon (quickly rechecking code with errors).

@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 17, 2017

This is blocking progress in fine-grained incremental mode. ASTs can't be reused when there is an error. In fine-grained incremental mode we want to cache every module that has no blocking errors. I'll try to fix or work around this.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 20, 2017

I've worked around this in my local branch (but have not fixed the underlying issue).

@gvanrossum gvanrossum self-assigned this Dec 1, 2017
@gvanrossum
Copy link
Member

gvanrossum commented Dec 6, 2017

I've got a clue about why this is happening: in build.py, in State.write_cache(), on line 1943, there's a check for self.manager.errors.is_errors(). But this returns True when there was an error in any previous file! And then two lines down we actually call delete_cache(). (This was added recently in PR #4045.)

What we actually need is a little different -- we want to check if the current SCC or any of its dependents has errors.

gvanrossum pushed a commit to gvanrossum/mypy that referenced this issue Dec 6, 2017
gvanrossum pushed a commit to gvanrossum/mypy that referenced this issue Dec 6, 2017
gvanrossum pushed a commit to gvanrossum/mypy that referenced this issue Dec 8, 2017
gvanrossum added a commit that referenced this issue Dec 8, 2017
Fixes #4135. We now decide more carefully whether a module has an error -- only if there's an error for that specific file or for any of its (transitive) dependencies (including the SCC it's a member of). Previously, once an error was detected, *all* modules processed later were considered to be at risk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants