Skip to content

Add a new heatmap output to the tachyon profiler #140677

Description

@pablogsal

It would be helpful to have a --heatmap output format that shows line-by-line sample intensity, similar to coverage.py's HTML reports.

Flamegraphs show which functions are hot and how they're called, but they don't tell you which lines within a function are the bottlenecks. The heatmap would solve this by showing the actual source code with color-coded lines (blue to red) based on sample counts, making it easy to spot hot loops, expensive operations, or unexpected hotspots within a function.

Usage would be: python -m profiling.sampling --heatmap -o results script.py

Linked PRs

Activity

  1. added a commit that references this issue on Oct 27, 2025
  2. pablogsal commented on Oct 27, 2025

    @pablogsal
    MemberAuthor

    Some examples of what I have in mind (from my prototype):

    Image Image Image Image
  3. added
    type-featureA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 27, 2025
  4. gaogaotiantian commented on Oct 28, 2025

    @gaogaotiantian
    Member

    This is pretty cool. If I understand correctly, the heatmap output does not include the call stack info right? So if both A and B called C, we know how much time (samples) that each line of C takes, but we can't differentiate if they are consumed in A or B.

    I'm not against this visualization I think it's very helpful, but as a future project, maybe we can combine the visualization.

    So we can have a flamegraph be in half of the screen, then when we click a slice in that flamegraph, we show the corresponding function and how much time each line takes in that specific call stack.

  5. pablogsal commented on Oct 29, 2025

    @pablogsal
    MemberAuthor

    This is pretty cool. If I understand correctly, the heatmap output does not include the call stack info right? So if both A and B called C, we know how much time (samples) that each line of C takes, but we can't differentiate if they are consumed in A or B.

    It kind of does because the little arrow on the lines allow you to move between caller and caller. If there are many possible candidates a contextual menu is displayed so you can choose. We can also add how many samples every callee is associated with if we want to the menu or some other contextual info.

    So we can have a flamegraph be in half of the screen, then when we click a slice in that flamegraph, we show the corresponding function and how much time each line takes in that specific call stack.

    For all the research I have done I think is better to just separate these two (there is --flamegraph already) and this will be a separate output differently. It is possible to merge both but it makes things more complicated because the data needs to be processed in different ways.

  6. added a commit that references this issue on Dec 2, 2025
  7. added a commit that references this issue on Dec 6, 2025
  8. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions