Skip to content

Make it easier to create upside-down flame graphs#6128

Merged
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-tzmnxpxrpyln
Jul 3, 2026
Merged

Make it easier to create upside-down flame graphs#6128
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-tzmnxpxrpyln

Conversation

@mstange

@mstange mstange commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This PR extracts some ideas from #6090. But it doesn't add UI to show an inverted flame graph.

I'm planning to have an upside-down flame graph in the function list (for the callers of the selected function), so the function list PR depends on this one.

@mstange mstange requested a review from fatadel June 26, 2026 14:02
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.08333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.46%. Comparing base (cc7309c) to head (c765a85).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/components/flame-graph/Canvas.tsx 75.00% 6 Missing ⚠️
src/components/flame-graph/FlameGraph.tsx 79.16% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6128      +/-   ##
==========================================
- Coverage   83.47%   83.46%   -0.02%     
==========================================
  Files         342      342              
  Lines       36338    36346       +8     
  Branches    10177    10208      +31     
==========================================
+ Hits        30334    30335       +1     
- Misses       5576     5583       +7     
  Partials      428      428              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mstange mstange force-pushed the push-tzmnxpxrpyln branch from 1d18f2a to 161003a Compare July 2, 2026 17:28
@fatadel

fatadel commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

I was in the middle of reviewing this 😃 Is it safe to review now?

@mstange

mstange commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I was in the middle of reviewing this 😃 Is it safe to review now?

Oops sorry! Yes it is safe to review, I haven't made any changes, this was just a rebase.

Comment thread src/components/flame-graph/Canvas.tsx Outdated
: Math.ceil(viewportBottom / stackFrameHeight);

// Only draw the stack frames that are vertically within view.
// The graph is drawn from bottom to top, in order of increasing depth.

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.

The comment is misleading now, need to reword "drawn from bottom to top". Drawn from either bottom to top or top to bottom?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to:

    // Rows are iterated in order of increasing depth; in startsAtBottom
    // mode that means visually bottom to top, otherwise top to bottom.

Comment thread src/components/flame-graph/Canvas.tsx Outdated
const cssRowTop: CssPixels = startsAtBottom
? (maxStackDepthPlusOne - depth - 1) * ROW_HEIGHT - viewportTop
: depth * ROW_HEIGHT - viewportTop;
const cssRowBottom: CssPixels = startsAtBottom

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.

Can be replaced by simply cssRowTop + ROW_HEIGHT.

Comment thread src/components/flame-graph/Canvas.tsx Outdated
// is maintained.
if (prevProps.maxStackDepthPlusOne !== this.props.maxStackDepthPlusOne) {
// is maintained. In top-down layout the base is at the top, so no
// adjustment is needed when depth grows or shrinks.

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 does not seem to be true regarding shrink: if the user had scrolled down so viewportBottom > newMaxViewportHeight, nothing clamps it, so blank space is shown below the now-shorter graph until the next scroll/resize event fires a moveViewport.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, good find! Should be fixed now.

mstange added 2 commits July 3, 2026 11:57
… flame graph code.

For the non-inverted call node info, the two are equivalent.

But if we want to use the flame graph on an inverted call node info,
such as for the "called by" view in the function list, the old code
would not work because the callNodeTable is always the non-inverted
call node table. So this change removes one barrier for inverted
flame graphs.
startsAtBottom={true} is the regular flame graph layout.
startsAtBottom={false} can be used for icicle-style flame graphs.
@mstange mstange force-pushed the push-tzmnxpxrpyln branch from 161003a to c765a85 Compare July 3, 2026 16:08
@mstange mstange merged commit 1875baf into firefox-devtools:main Jul 3, 2026
21 of 23 checks passed
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.

2 participants