Skip to content

gh-142927: Fix heatmap caller navigation for interior lines - #143180

Merged
pablogsal merged 2 commits into
python:mainfrom
pablogsal:heatmap-fix
Jan 1, 2026
Merged

gh-142927: Fix heatmap caller navigation for interior lines#143180
pablogsal merged 2 commits into
python:mainfrom
pablogsal:heatmap-fix

Conversation

@pablogsal

@pablogsalpablogsal commented Dec 25, 2025

Copy link
Copy Markdown
Member

The heatmap was only showing caller buttons on function definition
lines, not on interior lines within a function. This happened because
callers were recorded against the function definition line but looked
up by the current line number when building navigation buttons.

Added a line_to_function mapping to track which function each sampled
line belongs to. When building navigation buttons, callers are now
looked up via the function definition line so all lines in a function
show who calls that function. Callees remain line-specific since only
actual call sites should show what they call. Added tests covering
root, middle, and leaf frame behavior in call stacks.

@pablogsal

Copy link
Copy Markdown
MemberAuthor

CC: @ivonastojanovic@lkollar

The heatmap was only showing caller buttons on function definition
lines, not on interior lines within a function. This happened because
callers were recorded against the function definition line but looked
up by the current line number when building navigation buttons.
Added a line_to_function mapping to track which function each sampled
line belongs to. When building navigation buttons, callers are now
looked up via the function definition line so all lines in a function
show who calls that function. Callees remain line-specific since only
actual call sites should show what they call. Added tests covering
root, middle, and leaf frame behavior in call stacks.
Comment threadLib/profiling/sampling/heatmap_collector.py Outdated
@pablogsal
pablogsal merged commit 513ae17 into python:mainJan 1, 2026
44 checks passed
@pablogsal
pablogsal deleted the heatmap-fix branch January 1, 2026 19:06
@pablogsalpablogsal added the type-bug An unexpected behavior, bug, or error label Jan 1, 2026
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstype-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@pablogsal