python / python/cpython

Add runtime control for `profiling.sampling`

Aperta
#145,411 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib topic-profiling type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Feature or enhancement

Proposal:

The idea is to add an optional control channel (socket? named pipe?), so another process can start, stop etc. profiling without killing/restarting the profiler completely. Right now, the only option is to interact with it via TUI mode or just stop it via Ctrl-C.

While working on https://github.com/psf/pyperf/pull/230 I ran into the following problem: some parts (eg: warming up) of benchmarking should not be profiled, as they do not add any value. My only option was sending SIGINT signal.

Generally, the current flow is nice for headful sessions but it could be improved for (especially long-running) headless sessions.

perf record --control does it in a similar way:

       --control=fifo:ctl-fifo[,ack-fifo], --control=fd:ctl-fd[,ack-fd]
           ctl-fifo / ack-fifo are opened and used as ctl-fd / ack-fd as
           follows. Listen on ctl-fd descriptor for command to control
           measurement.

       Available commands:

       •   enable : enable events
       •   disable : disable events
       •   enable name : enable event name
       •   disable name : disable event name
       •   snapshot : AUX area tracing snapshot).
       •   stop : stop perf record
       •   ping : ping
       •   'evlist [-v|-g|-F] : display all events
               -F  Show just the sample frequency used for each event.
               -v  Show all fields.
               -g  Show event group information.

Specifically:

  • We could start with just enable and disable initially. snapshot next but it'd be lovely to dump without loosing accumulated data. Or maybe even set_rate.
  • Possible transport layers could be Unix sockets (works great on Linux) or named pipe. One option might be portable, another not?
  • Possble new arguments like --control unix:/tmp/tachyon-ctl.sock or --control fifo:/tmp/tachyon-ctl, similar to what perf record --control does.

It could be also ommited from the documentation initially, so we don't limit ourselves too early.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-149958

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

Inizia tracciando il flusso esistente di profiling.sampling e il modo in cui la modalità TUI e SIGINT controllano attualmente il profiling. Confronta il flusso di controllo proposto per l'abilitazione/disabilitazione con perf record --control, incluse le opzioni per Unix socket o named pipe e l'argomento --control proposto. Il lavoro è completato quando è definita un'interfaccia di controllo a runtime che supporta il profiling headless senza riavviare il profiler.

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

Valutazione

Stack tecnologico
python
Ambito
performance, tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
20/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.