Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Oct 27, 2025

Introduce a new --heatmap output format that provides line-by-line
execution visualization. The heatmap shows:

  • Color-coded execution intensity for each line (cold → warm → hot → very hot)
  • Inline sample counts and percentages per line
  • Per-file statistics (total samples, hottest line)
  • Interactive call graph navigation with caller/callee buttons
  • Module type badges (stdlib, site-packages, project code)

Unlike flamegraphs which show call stacks and time distribution, heatmaps
excel at identifying hot code paths within files, understanding line-level
execution patterns, and navigating through call relationships.

@pablogsal
Copy link
Member Author

CC @ambv

Introduce a new --heatmap output format that provides line-by-line
execution visualization. The heatmap shows:

- Color-coded execution intensity for each line (cold → warm → hot → very hot)
- Inline sample counts and percentages per line
- Per-file statistics (total samples, hottest line)
- Interactive call graph navigation with caller/callee buttons
- Module type badges (stdlib, site-packages, project code)

Unlike flamegraphs which show call stacks and time distribution, heatmaps
excel at identifying hot code paths within files, understanding line-level
execution patterns, and navigating through call relationships.
Copy link
Member

@savannahostrowski savannahostrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this is so cool! I left a couple of comments, but also wanted to mention that I really loved that you added a minimap to show hotspots and the permalinking on line click; so nice for jumping around and sharing results.

@pablogsal pablogsal changed the title gh-140677 :Add heatmap visualization to Tachyon sampling profiler gh-140677 Add heatmap visualization to Tachyon sampling profiler Nov 24, 2025
@pablogsal pablogsal marked this pull request as ready for review November 24, 2025 14:11
@pablogsal
Copy link
Member Author

CC @ivonastojanovic can you give this a pass when you have some time? Test it locally and play a bit with it before reviewing the code

@pablogsal
Copy link
Member Author

@ivonastojanovic I have updated the buttons to be toggles, pls take a look

Copy link
Contributor

@ivonastojanovic ivonastojanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I left a few comments, and I’ll experiment with the CSS a bit

tree = trees[module_type]

# Project starts expanded, others start collapsed
is_collapsed = module_type in ('stdlib', 'site-packages')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the other files be collapsed by default? Since this category typically includes special frames or uncategorized files, users are usually more interested in their own project code first. Collapsing these by default might make navigation clearer?

Small changes:
- Change navigation button colors for dark theme
- Update toggle button colors and active-state text
- Add missing "→" in the Intensity legend
@ivonastojanovic
Copy link
Contributor

@pablogsal I ran into a bug during testing, so with Total and Hot enabled, changing the theme makes the sidebar vanish 👀

Screen.Recording.2025-12-02.at.00.15.56.mov

@pablogsal
Copy link
Member Author

@pablogsal I ran into a bug during testing, so with Total and Hot enabled, changing the theme makes the sidebar vanish 👀

Screen.Recording.2025-12-02.at.00.15.56.mov

Good catch! Fixed :)

Copy link
Contributor

@ivonastojanovic ivonastojanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@pablogsal pablogsal merged commit 8801c6d into python:main Dec 2, 2025
46 checks passed
@pablogsal pablogsal deleted the heatmap branch December 2, 2025 20:33
@pablogsal
Copy link
Member Author

Thanks a lot @ivonastojanovic and @savannahostrowski for the reviews!

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants