python / python/cpython

Differential flamegraphs are incorrectly scaled across sampling rates

Open
#154,032 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-profiling type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Differential flamegraphs compare raw sample counts after scaling the baseline by sampled wall time. This makes identical profiles look very different when the sampling rates differ.

For example, using a 1 kHz baseline and profiling the same workload at 100 Hz reports around -90% for unchanged leaf functions. Using the same rate for both profiles reports approximately 0%.

We should normalize the sample counts consistently and use the sampling interval only when converting samples to time for display.

Linked PRs
  • gh-154082

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the differential flamegraph comparison described in the issue with 1 kHz and 100 Hz profiles, then trace where sample counts are scaled and where sampling intervals convert samples to displayed time. Done means identical profiles at different sampling rates compare at approximately 0% while displayed time conversion remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.