python / python/mypy

Daemon performance seems slow

Ouverte
#16,745 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

performance topic-daemon
Langage dominant
Python
Étoiles
20.6k
Forks
3.3k
Métriques de merge des PR
Métriques de PR en attente

Description

I've written a simple little timing script:

import os
from timing import TicToc # our own timing context
with TicToc('stop daemon'):
    os.system('dmypy stop')
for _ in range(10):
    with TicToc('Run on scratch'):
        os.system('dmypy run scratch.py > boo.txt')
    with TicToc('Modify scratch'):
        with open('scratch.py', 'a') as f:
            f.write('\n\nx: int = 5\n')

scratch.py is a file in a repo with ~100k lines of code. It's a work in progress as far as typing goes; boo.txt ends with Found 2587 errors in 143 files (checked 1 source file)

The intention of the script is to simulate me working on code, e.g. scratch.py, and having type checking run frequently (e.g. every time I save the file).

With default mypy (1.8.0) settings, I get this:

Daemon stopped
[stop daemon] 0.161 seconds
[Run on scratch] 33.603 seconds
[Modify scratch] 0.002 seconds
[Run on scratch] 7.247 seconds
[Modify scratch] 0.002 seconds
[Run on scratch] 3.549 seconds
[Modify scratch] 0.001 seconds
[Run on scratch] 7.029 seconds
[Modify scratch] 0.002 seconds
[Run on scratch] 3.721 seconds
[Modify scratch] 0.001 seconds
[Run on scratch] 6.860 seconds
[Modify scratch] 0.002 seconds
[Run on scratch] 3.705 seconds
[Modify scratch] 0.001 seconds
[Run on scratch] 8.777 seconds
[Modify scratch] 0.002 seconds
[Run on scratch] 3.623 seconds
[Modify scratch] 0.001 seconds
[Run on scratch] 6.872 seconds
[Modify scratch] 0.002 seconds

In other words, the time it takes to check this one file (once the daemon has started) oscillates between ~4 seconds and ~7 seconds, just by adding a single line to scratch.py each time.

Without modifying scratch.py between runs, I get this:

Daemon stopped
[stop daemon] 0.161 seconds
[Run on scratch] 33.603 seconds
[Run on scratch] 4.002 seconds
[Run on scratch] 0.369 seconds
[Run on scratch] 0.364 seconds
[Run on scratch] 0.364 seconds
[Run on scratch] 0.371 seconds
[Run on scratch] 0.364 seconds
[Run on scratch] 0.366 seconds
[Run on scratch] 0.362 seconds
[Run on scratch] 0.362 seconds
  1. Is this oscillation in run time (seen on the first test) expected?
  2. Is it expected to see a second run be much slower than subsequent runs on the same file if nothing is modified?
  3. Is there anything I can do to speed this up, other than setting follow-imports to skip?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le script de mesure du temps fourni et comparez des exécutions répétées de dmypy run scratch.py avec et sans ajout à scratch.py. Étudiez les temps du daemon lors de la première exécution, d’une exécution sans modification et avec un fichier modifié ; le travail est terminé lorsque l’oscillation est expliquée et qu’un moyen pris en charge de réduire le temps de vérification au-delà de follow-imports=skip est identifié.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
devtools, performance
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.