feat: --cpu-prof flags for CPU profiles#31909
Merged
littledivy merged 9 commits intodenoland:mainfrom Mar 9, 2026
Merged
Conversation
Signed-off-by: Divy <dj.srivastava23@gmail.com>
kajukitli
approved these changes
Mar 7, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
lgtm — nice feature addition for CPU profiling
the implementation is clean:
- flags are well-structured with sensible defaults
CpuProfilerStateuses inspector session to control V8's profiler- markdown report generation is a nice touch for quick analysis
the test coverage looks good with specs for basic usage, custom names, and md output
one minor thing: the --cpu-prof-interval default of 1000µs (1ms) is reasonable, but might want to document that higher values = less overhead but coarser resolution
kajukitli
added a commit
to kajukitli/docs
that referenced
this pull request
Mar 8, 2026
Documents the new --cpu-prof flags added in denoland/deno#31909: - --cpu-prof: Enable CPU profiling - --cpu-prof-dir: Output directory - --cpu-prof-name: Custom filename - --cpu-prof-interval: Sampling interval - --cpu-prof-md: Generate Markdown report Includes example of the Markdown report output format.
… eval support Move the 5 cpu-prof fields from RunFlags to a single CpuProfFlags struct on the top-level Flags, making it easy to add cpu-prof to more subcommands. Add --cpu-prof support to `deno eval` with a spec test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove duplicate CpuProfConfig struct from cli/worker.rs, use CpuProfilerConfig from runtime everywhere - Change cpu_prof_interval type from i32 to u32 (sampling interval can't be negative) - Remove misleading Total columns from markdown report (they were identical to Self columns without proper descendant walking) - Extract shared cpu_prof_filename() helper, eliminating duplicated timestamp/PID generation and unwrap() on SystemTime - Always append worker ID to filename for web workers, even with custom --cpu-prof-name, preventing file overwrites - Keep last two path segments in format_location() for better context - Add --cpu-prof flags to deno serve subcommand - Document that --cpu-prof-dir implicitly enables profiling - Add explanatory comments for clippy allow and profile_msg_id race Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bartlomieju
added a commit
that referenced
this pull request
Mar 14, 2026
…hs (#32572) ## Summary Builds on top of #31909 to add interactive SVG flamegraph generation for CPU profiles, plus improvements to the existing `--cpu-prof` functionality. ### New: `--cpu-prof-flamegraph` flag Generates a self-contained, interactive SVG flamegraph alongside the `.cpuprofile` file. No external dependencies required — the SVG is generated directly from V8 CPU profile data. ```bash deno run --cpu-prof --cpu-prof-flamegraph script.ts # or deno eval --cpu-prof --cpu-prof-flamegraph "/* code */" ``` **Flamegraph features:** - 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 - "Invert" checkbox to flip into an icicle graph (root at top) - Hover any frame to see function name and sample count in the status bar - Responsive — fills the browser viewport, adapts on resize - Warm color gradient matching `cargo-flamegraph` / inferno style ### Other improvements - **`deno eval` support**: All `--cpu-prof-*` flags now work with `deno eval` - **Fixed total time calculation**: The markdown report now properly computes inclusive time (self + all descendants) using bottom-up tree aggregation, instead of showing only self time --------- 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.
This PR adds
--cpu-prof,--cpu-prof-dir,--cpu-prof-md,--cpu-prof-nameand--cpu-prof-intervalExample usage: