python / python/mypy

slow dmypy recheck times

Open
#6,722 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance priority-1-normal topic-daemon topic-fine-grained-incremental
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Hi, I'm creating an issue for a problem discussed with @ilevkivskyi over at https://github.com/dropbox/mypy-PyCharm-plugin/issues/26

Ivan indicated that he's getting 300-500ms response time from dmypy on rechecks of a large code base, but on my moderately large code base, dmypy is taking over 15s to rerun if I edit any files.

I'm using 0.701.

First I start the daemon:

$ dmypy run -v -- python/packages
err                     : 
out                     : python/packages/filesize.py:51: error: I ...
platform                :     darwin
python_version          :        2_7
roundtrip_time          :     20.145
stats                   : {
'validate_meta_time': 0.005048990249633789,
'files_parsed': 819, 
'modules_parsed': 520, 
'stubs_parsed': 299, 
'parse_time': 4.495372295379639, 
'find_module_time': 0.3217315673828125, 
'find_module_calls': 5739, 
'graph_size': 819, 
'stubs_found': 299, 
'graph_load_time': 5.5668110847473145, 
'fm_cache_size': 1936, 
'sccs_left': 0, 
'nodes_left': 0, 
'cache_commit_time': 4.0531158447265625e-06, 
'load_fg_deps_time': 9.5367431640625e-07
}
status                  :          1

Then I edit a file and recheck:

$ dmypy recheck -v --update python/packages/foo.py
err                     : 
out                     : python/packages/foo.py:1 ...
platform                :     darwin
python_version          :        2_7
roundtrip_time          :     17.837
stats                   : {
'load_fg_deps_time': 2.5272369384765625e-05, 
'validate_meta_time': 1.3113021850585938e-05, 
'files_parsed': 1, 
'modules_parsed': 1, 
'stubs_parsed': 0, 
'parse_time': 0.002131938934326172, 
'find_module_time': 0.005670785903930664, 
'find_module_calls': 4, 
'semanal_time': 0.0036809444427490234,
'typecheck_time': 0.0034759044647216797, 
'deps_time': 0.001669168472290039, 
'finish_passes_time': 0.0005908012390136719, 
'update_isolated_time': 0.021294116973876953, 
'propagate_time': 0.003412961959838867, 
'find_changes_time': 0.0008490085601806641, 
'fg_update_time': 17.824305057525635,
'files_changed': 1
}
status                  :          1

Clearly the problem lies in fg_update_time!

It may be important to note that this code produces hundreds of errors. I'm using a custom mypy runner to filter out errors I'm not concerned with until my message filtering PR gets some traction.

Here's my mypy.ini:

[mypy]
python_version = 2.7
ignore_missing_imports = true
follow_imports = skip
warn_no_return = false
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true

Any guidance is greatly appreciated!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported timings with dmypy run and dmypy recheck -v --update, using the supplied mypy.ini settings and a comparable codebase. Start by tracing the fg_update_time statistic, then compare it with the other recheck timings and confirm that the change reduces the reported delay without changing type-checking results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.