python / python/cpython

Tachyon’s `--diff-flamegraph` scales times in baseline run to duration of current run

Aperta
#154,062 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Bug report

Bug description:

As discussed with @pablogsal during EuroPython sprints:

Using this simple example script (flamegraph_demo.py):

import time

def main():
    f_1()
    f_2()

def f_1():
    time.sleep(0.5)  # change this to 1.5 in the second run

def f_2():
    time.sleep(1)

main()
python -m profiling.sampling run --binary -o baseline.bin flamegraph_demo.py
vim flamegraph_demo.py  # edit f_1 to sleep for 1.5 s
python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html flamegraph_demo.py

generates this diff flamegraph:

Image

f_2 is unchanged between both runs, so the “Baseline Self” time should be equal to the “Current Self” and equal to 1 s (that it displays “1 ms” is covered in #154059); however, the baseline for all functions gets scaled with the ratio of total time in this run over total time of the previous run (in this case: 2.5 s / 1.5 s = 1.667).

I can imagine scenarios where this scaling is useful (e.g. when the baseline is generated on a different machine). However, in the common case of running baseline and diff on the same machine, this scaling means that a lot of unchanged functions get colour-coded, which distracts from the few functions that experienced a meaningful change.

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Linked PRs
  • gh-154082

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 dal punto di ingresso profiling.sampling e riproduci i comandi usando flamegraph_demo.py, confrontando baseline.bin con diff.html. Traccia come --diff-flamegraph ridimensiona i tempi baseline e verifica che f_2, che non è cambiato, mostri tempi self baseline e correnti uguali a 1 s senza cambiamenti di colore non necessari.

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

Valutazione

Stack tecnologico
python
Ambito
performance
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.