mypy daemon consumes an increasing amount of memory every time `run` or `recheck` is invoked
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
Bug Report
The amount of memory that the daemon process consumes doesn't drop when typing errors are fixed; the memory consumption appears to stay the same if there are no errors, and when more errors appear, the memory consumption just continues increasing.
This is problematic when running the daemon on initially untyped code bases with large amounts of typing errors (as usually done in code editors integrating with a type-checker), as dmypy becomes sluggish very quickly (because the same existing errors are repeatedly reported).
To Reproduce & Actual Behaviour
-
Repeat this line 2000 times in a file
project/test/__init__.py,aaaaaaaaaaaaaaaaaaaaaaaaand create the following mypy configuration file at
project/mypy.ini[mypy] files = test/ -
Navigate to
project/, then rundmypy run > errors.txtmultiple times without editingproject/test/__init__.py; watch the memory consumption grow for thedmypyprocess. -
Delete all code in
project/test/__init__.py, then rundmypy runagain multiple times. The memory consumption does not decrease.
Expected Behavior
I expect the memory consumption to be proportional to the number of errors, AST nodes, and size of a cache diff since the last time the checked code files have changed. If there's no code changes, it's surprising to me that memory consumption would grow for just repeated reports of the same errors.
Your Environment
- Mypy version used: 1.17.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): See# project/mypy.ini - Operating system: Ubuntu (Pop!_OS) 22.04 LTS
- Python version used: 3.11
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
project/mypy.ini を使用して project/test/init.py の問題を再現し、その後 dmypy run を呼び出して、デーモンのメモリを監視しながら recheck を繰り返します。繰り返し発生するエラーを削除した場合の動作と比較します。繰り返しの報告によってメモリが増加しなくなり、エラーと AST ノードを削除するとメモリが減少することを確認し、このシナリオの回帰テストを用意できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100