python / python/cpython

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

Offen
#154,062 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib topic-profiling type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit dem Einstiegspunkt profiling.sampling und reproduzieren Sie die Befehle mit flamegraph_demo.py, wobei Sie baseline.bin mit diff.html vergleichen. Verfolgen Sie, wie --diff-flamegraph die baseline-Zeiten skaliert, und überprüfen Sie, dass f_2 ohne Änderungen gleiche baseline- und aktuelle Self-Zeiten von 1 s aufweist, ohne unnötige Farbänderungen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
performance
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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