python / python/cpython

Add runtime control for `profiling.sampling`

Ouverte
#145,411 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stdlib topic-profiling type-feature
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

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

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 retracer le flux existant de profiling.sampling et la manière dont le mode TUI et SIGINT contrôlent actuellement le profiling. Comparez le flux de contrôle d’activation/désactivation proposé avec perf record --control, y compris les options de socket Unix ou de named pipe et l’argument --control proposé. Le travail est considéré comme terminé lorsqu’une interface de contrôle à l’exécution définie prend en charge le profiling headless sans redémarrer le profiler.

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

Évaluation

Stack technique
python
Domaine
performance, tooling
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

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