python / python/mypy

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

Aperta
#14,474 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-daemon
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da mypy/server/update.py intorno alla riga 847 e riproduci il rallentamento usando lo script ball_of_mud/generate_ball_of_mud.py collegato nell’issue. Indaga sul motivo per cui molti file con errori vengono rielaborati quando cambia un solo file; il lavoro è completato quando dmypy rimane veloce per le modifiche di piccole dimensioni nonostante gli errori non correlati, preservando al contempo il comportamento di importazione rilevante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.