Include _run_once duration in asyncio debug
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Feature or enhancement
In asyncio debug mode, log the duration of the asyncio iteration if it exceeds the slow_callback_duration (or a separate duration), as is done now for individual coroutine durations.
Pitch
This will capture when one eventloop iteration is slow, not just because one coroutine is blocking for a while, but because there might be several smaller tasks to process (e.g. 10 10ms operations in one tick blocks incoming operations just as much as one 100ms task, but nothing is logged, currently). It might be less actionable info if it doesn’t log the tasks, but it’s proved useful to us in the past as a more general diagnostic with other event loops (pre-asyncio tornado.IOLoop.set_blocking_log_threshold). This may be an indicator that a web worker is overloaded and more replicas are needed, for example, even if each individual task is handled quickly.
I see three possible versions of this:
- like slow coroutines, log only a single time for
_run_onceif it exceeds a threshold. This doesn't contain actionable info on its own other than 'things are slow' - add to 1. some summary information about the tasks (e.g. log total number and top N coroutines and durations if the sum of durations exceeds some threshold)
- replicate tornado's pre-asyncio set_blocking_log_threshold, which logs the stack when the time is crossed via
signal.setitimer. The nice thing about this is it can diagnose hangs, not just slowness, unlike after-complete timer logs. Only available wheresetitimeris also available, of course.
Previous discussion
Brought up originally on async-sig.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in Lib/asyncio/base_events.py, intorno alla registrazione esistente della durata dei callback lenti a cui si fa riferimento nell’issue, quindi esamina come viene gestito _run_once. L’issue presenta tre possibili design, quindi chiarisci innanzitutto quale comportamento debba essere implementato e quali soglia e output diagnostico siano previsti. Il lavoro è considerato completato quando è stato concordato un diagnostico della durata del ciclo di eventi in modalità debug con la relativa copertura.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100