Skip to content

gh-140677 Add heatmap visualization to Tachyon sampling profiler - #140680

Merged
pablogsal merged 23 commits into
python:mainfrom
pablogsal:heatmap
Dec 2, 2025
Merged

gh-140677 Add heatmap visualization to Tachyon sampling profiler#140680
pablogsal merged 23 commits into
python:mainfrom
pablogsal:heatmap

Conversation

@pablogsal

@pablogsalpablogsal commented Oct 27, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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.

@savannahostrowskisavannahostrowski left a comment

Copy link
Copy Markdown
Member

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.

Comment threadLib/profiling/sampling/heatmap_index_template.html Outdated
Comment threadLib/profiling/sampling/heatmap_index_template.html Outdated
Comment threadLib/profiling/sampling/stack_collector.py Outdated
Comment threadLib/profiling/sampling/sample.py Outdated
@pablogsalpablogsal changed the title gh-140677 :Add heatmap visualization to Tachyon sampling profilergh-140677 Add heatmap visualization to Tachyon sampling profilerNov 24, 2025
@pablogsal
pablogsal marked this pull request as ready for review November 24, 2025 14:11
@pablogsal

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

@ivonastojanovicivonastojanovic left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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?

Comment threadLib/profiling/sampling/heatmap_collector.py Outdated
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
Copy Markdown
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

pablogsaland others added 2 commits December 2, 2025 14:34
Co-authored-by: ivonastojanovic <80911834+ivonastojanovic@users.noreply.github.com>
@pablogsal

Copy link
Copy Markdown
MemberAuthor

@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 :)

@ivonastojanovicivonastojanovic left a comment

Copy link
Copy Markdown
Contributor

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:mainDec 2, 2025
46 checks passed
@pablogsal
pablogsal deleted the heatmap branch December 2, 2025 20:33
@pablogsal

Copy link
Copy Markdown
MemberAuthor

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

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
python#140680)
Co-authored-by: Ivona Stojanovic <stojanovic.i@hotmail.com>
Sign up for freeto 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.

4 participants

@pablogsal@ivonastojanovic@savannahostrowski@nazeerali4325-commits