Include _run_once duration in asyncio debug

Offen
#101,946 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
backend

Rechercherichtung

Beginne in Lib/asyncio/base_events.py bei der im Issue referenzierten bestehenden Protokollierung der Dauer langsamer Callbacks und prüfe anschließend, wie _run_once behandelt wird. Das Issue stellt drei mögliche Designs vor. Kläre daher zuerst, welches Verhalten implementiert werden soll und welcher Schwellenwert sowie welche diagnostische Ausgabe erwartet werden. Als abgeschlossen gilt die Vereinbarung über eine Laufzeitdauerdiagnose für Ereignisschleifen im Debug-Modus mit entsprechender Testabdeckung.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

stdlib topic-asyncio type-feature

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:

  1. like slow coroutines, log only a single time for _run_once if it exceeds a threshold. This doesn't contain actionable info on its own other than 'things are slow'
  2. 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)
  3. 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 where setitimer is also available, of course.

Previous discussion

Brought up originally on async-sig.

Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
558

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/cpython

Alle Issues in python/cpython

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.