Skip to content

Heatmap replay shows zero duration and sample rate #161008

Open

Description

@deadlovelll

Bug report

Replaying a binary profile with --heatmap shows zero duration and sample rate even though both values are stored in the file

Repro:

import time
time.sleep(2)

Run:

sudo ./python.exe -m profiling.sampling run --binary -o repro.bin repro.py
sudo ./python.exe -m profiling.sampling replay --heatmap -o repro-report repro.bin

We will get:

Captured 2,024 samples in 2.02 seconds
Sample rate: 999.94 samples/sec
Error rate: 0.00
  Binary Encoding:
    Records:          8
      RLE repeat:     3 (37.5%) [2,019 samples]
      Full stack:     5 (62.5%)
      Suffix match:   0 (0.0%)
      Pop-push:       0 (0.0%)
  Frame Efficiency:
    Frames written:   8
    Frames saved:     12,039 (99.9%)
    Bytes (pre-zstd): 6.0 KB
Binary profile written to repro.bin (2024 samples)

Replaying 2024 samples from repro.bin
  Sample interval: 1000 us
  Compression: zstd
  [████████████████████████████████████████] 100.0% (2,024/2,024)
Heatmap output written to repro-report/
  - Index: repro-report/index.html
  - 1 source file analyzed
Replayed 2024 samples

if we will try to open the html report "missed samples" and "error rate" will always be N/A, "duration" will always be 0.0 (and without a unit of measurement)

Actual:

Image

Expected:

Image

Proposed fix: add set_replay_stats method for HeatmapCollector

I will work on the fix for that

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions