python / python/mypy

`dmypy` - poor performance when a lot of possibly unrelated errors

オープン
#14,474 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug topic-daemon
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Bug Report

The dmypy daemon will experience poor performance if there are a lot of files with errors, even if only a single file is updated.

To Reproduce

Create a ball of mud with errors. This script requires some tweaking to really bring out the issue but its a good starting point:

https://github.com/JamesHutchison/mypy/blob/dmypy-update-perf/ball_of_mud/generate_ball_of_mud.py

The performance deficit is proportionate to the number of failing files.

Expected Behavior

dmypy is always fast for small changes

Actual Behavior

dmypy is slow.

Your Environment

  • Mypy version used: 0.991

Why is this important?

When converting a large repo to mypy you will have a lot of failing files at first and you cannot use --follow-imports=silent

Notes

The cause appears to be this code:

https://github.com/python/mypy/blob/master/mypy/server/update.py#L847

From what I can tell, it looks like dmypy relies on files failing their imports to know to revisit them later. This appears to also be the reason that you cannot use --follow-imports=silent with dmypy.

For example, when --follow-imports=error:

  • File A is built, and File A imports file B. File A gets errors about B not existing.
  • File B is built
  • File A gets built again, but this time B is cached (or loaded, or whatever) and no longer fails import

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

mypy/server/update.py の 847 行目付近から始め、issue にリンクされている ball_of_mud/generate_ball_of_mud.py スクリプトを使って低速化を再現します。1 ファイルだけが変更された場合に、多数の失敗したファイルが再度処理される理由を調査します。無関係なエラーがあっても小さな変更に対して dmypy が高速なままであり、関連する import の動作が維持されていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。