feat: add --cpu-prof-flamegraph to generate interactive SVG flamegraphs#32572
Open
bartlomieju wants to merge 18 commits intomainfrom
Open
feat: add --cpu-prof-flamegraph to generate interactive SVG flamegraphs#32572bartlomieju wants to merge 18 commits intomainfrom
bartlomieju wants to merge 18 commits intomainfrom
Conversation
Signed-off-by: Divy <dj.srivastava23@gmail.com>
…port - Add --cpu-prof, --cpu-prof-dir, --cpu-prof-name, --cpu-prof-interval, and --cpu-prof-md flags to `deno eval` - Fix call tree total time calculation: properly walk the tree to compute inclusive time (self + all descendants) instead of using self time only - Fix Hot Functions and Function Details sections to show accurate total time percentages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new `--cpu-prof-flamegraph` flag that generates a self-contained SVG flamegraph alongside the .cpuprofile file. No external dependencies required — the SVG is generated directly from the V8 CPU profile data. The flamegraph shows: - Call stacks as nested rectangles (root at bottom, leaves at top) - Width proportional to sample count (time spent) - Warm color palette with hover tooltips showing sample counts - Function names with source locations Supported on both `deno run` and `deno eval`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite flamegraph generation to match the inferno/cargo-flamegraph style with full interactivity: - Click any frame to zoom into that subtree - "Reset Zoom" button to restore full view - Ctrl+F / Search button for regex-based function search with magenta highlighting and matched percentage display - Hover any frame to see function details in the status bar - Fluid/responsive width that adapts to browser window - Percentage-based coordinates with fg:x/fg:w sample-count attributes for precise zoom calculations - Gradient background (grey to warm yellow) - Verdana font, matching inferno's visual style Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use min-height:100vh and dynamic JS resizing to ensure the flamegraph fills the entire browser window, with frames pushed to the bottom. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds an interactive "Invert" checkbox that flips the flamegraph into an icicle graph (root at top). Toggling back restores the original layout. Zoom works correctly in both orientations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
littledivy
approved these changes
Mar 8, 2026
runtime/cpu_profiler.rs
Outdated
Comment on lines
+935
to
+936
| // Interactive JavaScript for the flamegraph SVG, modeled after inferno/flamegraph. | ||
| // Supports: click-to-zoom, reset zoom, Ctrl+F search with highlight, hover details. |
Member
There was a problem hiding this comment.
Cool, should we move this to a file and include_str!?
Member
Author
|
@littledivy I update the description with example screenshot of SVG flamegraph. Let's land #31909 first then I'll rebase this one. |
Resolve conflicts between main's CPU profiling refactor (CpuProfFlags, centralized cpu_prof_parse, u32 interval, cpu_prof_filename) and our flamegraph additions. Adopts main's structural improvements while preserving flamegraph support and total_time tracking in markdown reports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract flamegraph JS to `cpu_profiler/flamegraph.js`, loaded via `include_str!` - Move cpuprofile/markdown generation to `cpu_profiler/cpuprof.rs` - Move flamegraph SVG generation to `cpu_profiler/flamegraph.rs` - Keep config, state, and profiler orchestration in `cpu_profiler/mod.rs` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on top of #31909 to add interactive SVG flamegraph generation for CPU profiles, plus improvements to the existing
--cpu-proffunctionality.New:
--cpu-prof-flamegraphflagGenerates a self-contained, interactive SVG flamegraph alongside the
.cpuprofilefile. No external dependencies required — the SVG is generated directly from V8 CPU profile data.Flamegraph features:
cargo-flamegraph/ inferno styleOther improvements
deno evalsupport: All--cpu-prof-*flags now work withdeno evalCo-Authored-By: Claude Opus 4.6 noreply@anthropic.com