Skip to content

gh-138122: Add differential flame graph#145785

Open
ivonastojanovic wants to merge 2 commits intopython:mainfrom
ivonastojanovic:differential_flamegraph
Open

gh-138122: Add differential flame graph#145785
ivonastojanovic wants to merge 2 commits intopython:mainfrom
ivonastojanovic:differential_flamegraph

Conversation

@ivonastojanovic
Copy link
Contributor

@ivonastojanovic ivonastojanovic commented Mar 10, 2026

Differential flame graphs compare two profiling runs and highlight where performance has changed. This makes it easier to detect regressions introduced by code changes and to verify that optimizations have the intended effect.

The visualization renders the current profile with frame widths representing current time consumption. Color is then applied to show the difference relative to the baseline profile: red gradients indicate regressions, while blue gradients indicate improvements.

Some call paths may disappear entirely between profiles. These are referred to as elided stacks and occur when optimizations remove code paths or when certain branches stop executing. When elided stacks are present, an "Elided" toggle is displayed, allowing the user to switch between the main differential view and a view showing only the removed paths.

Differential view
image

Elided view
image

CC: @pablogsal @lkollar


📚 Documentation preview 📚: https://cpython-previews--145785.org.readthedocs.build/

Differential flame graphs compare two profiling runs and highlight where
performance has changed. This makes it easier to detect regressions
introduced by code changes and to verify that optimizations have the
intended effect.

The visualization renders the current profile with frame widths
representing current time consumption. Color is then applied to show the
difference relative to the baseline profile: red gradients indicate
regressions, while blue gradients indicate improvements.

Some call paths may disappear entirely between profiles. These are
referred to as elided stacks and occur when optimizations remove code
paths or when certain branches stop executing. When elided stacks are
present, an "Elided" toggle is displayed, allowing the user to switch
between the main differential view and a view showing only the removed
paths.
@ivonastojanovic ivonastojanovic changed the title Add differential flame graph gh-138122: Add differential flame graph Mar 10, 2026
@ivonastojanovic
Copy link
Contributor Author

I’m a bit stuck on what colors we should use for new vs deleted functions.

Right now:

  • New functions (not in baseline, present in current) are purple.
  • Deleted functions (shown in elided view, were in baseline, gone in current) are deep red, mostly so they stand out and because red = “removed”.

But I’m not sure if we should even treat them differently from other functions visually.

From a perf perspective it’s kind of confusing:

  • New functions are technically a regression (the code path now exists and adds cost).
  • Deleted ones are technically an improvement (code path removed).

So I’m not sure what the right visual semantics are here. Curious what you think 🙂

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant