python / python/mypy

mypy daemon consumes an increasing amount of memory every time `run` or `recheck` is invoked

Aperta
#19,644 2 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 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

  1. Repeat this line 2000 times in a file project/test/__init__.py,

    aaaaaaaaaaaaaaaaaaaaaaaa
    

    and create the following mypy configuration file at project/mypy.ini

    [mypy]
    files = test/
    
  2. Navigate to project/, then run dmypy run > errors.txt multiple times without editing project/test/__init__.py; watch the memory consumption grow for the dmypy process.

  3. Delete all code in project/test/__init__.py, then run dmypy run again 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

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

Riproduci il problema da project/test/init.py usando project/mypy.ini, quindi invoca dmypy run e ripeti recheck osservando la memoria del daemon. Confronta il comportamento dopo aver rimosso gli errori ripetuti; il lavoro è completo quando la memoria non cresce più a causa delle segnalazioni ripetute e diminuisce quando vengono rimossi gli errori e i nodi AST, con copertura di regressione per lo scenario.

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

Valutazione

Stack tecnologico
python
Ambito
tooling
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.