Include _run_once duration in asyncio debug
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en Lib/asyncio/base_events.py, alrededor del registro existente de la duración de los callbacks lentos al que se hace referencia en el issue, y después revisa cómo se gestiona _run_once. El issue presenta tres diseños posibles, así que primero aclara qué comportamiento debe implementarse y qué umbral y salida de diagnóstico se esperan. Se considera terminado cuando se haya acordado un diagnóstico de la duración del bucle de eventos en modo de depuración con la cobertura correspondiente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100