python / python/mypy

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

Offen
#14,474 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug topic-daemon
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit mypy/server/update.py etwa bei Zeile 847 und reproduziere die Verlangsamung mithilfe des im Issue verlinkten Skripts ball_of_mud/generate_ball_of_mud.py. Untersuche, warum viele fehlschlagende Dateien erneut verarbeitet werden, wenn sich nur eine Datei ändert; die Aufgabe ist erledigt, wenn dmypy bei kleinen Änderungen trotz nicht zusammenhängender Fehler schnell bleibt und dabei das relevante Importverhalten erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.