Skip to content

Expose renderer threads and improve CPU call trees - #16

Merged
jackfranklin merged 4 commits into
ChromeDevTools:mainfrom
kurtextrem:codex/trace-cpu-analysis
Nov 19, 2026
Merged

jackfranklin merged 4 commits into
ChromeDevTools:mainfrom
kurtextrem:codex/trace-cpu-analysis

Conversation

@kurtextrem

@kurtextrem kurtextrem commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

View just this PR’s diff

Add threads and --thread PID:TID so CPU commands can inspect an out-of-process iframe. Use instrumented timeline events for the overview breakdown so optional CPU samples preserve category attribution.

Long tasks show a representative source frame when available. Top-down rows show call paths, aggregate rows show the first event timestamp, and tasks --url-only and find --url help locate source-backed activity. Validate result limits and profile bucket sizes, and require a function or URL for find.

Task listing and bottom-up ranking select candidates before formatting rows. The agent skill and command reference show how to select a renderer thread for an iframe.

Synthetic tests cover sample invariance, call paths, timestamps, thread selection, URL search, Markdown and JSON thread output, and invalid arguments.

Part 2 of 5 for #14. Papercuts 2, 4, 6, 7, 8, 9, and 10. Extends the warnings for papercut 3 to tasks and profile.

Fixes the invalid tasks --top -5 and profile --bucket 0 options reported in #9.

@kurtextrem
kurtextrem force-pushed the codex/trace-cpu-analysis branch 4 times, most recently from 6404427 to 09fcbbc Compare November 19, 2026 13:13
@kurtextrem
kurtextrem marked this pull request as ready for review November 19, 2026 13:14

@jackfranklin jackfranklin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The core changes here look great — nice fixes for sample-invariant category attribution, on-demand top-down expansion, and --thread support. A few things before merging:

  1. Rebase onto main: Now that #15 has been squash-merged, this branch has conflicts and needs a rebase onto main.
  2. Route threads through formatResult(): In src/cli.ts, the threads handler branches on args.format === 'md' and calls formatThreadsMarkdown() directly. Adding ThreadsResult to src/engine/types.ts and a 'threads' case in formatMarkdown() (src/formatters/markdown.ts) would keep formatting dispatch consistent with the other commands.
  3. Add CLI tests for option validation: This fixes --top -5, --bucket 0, and find without --function/--url, so it would be good to add test cases in test/cli.test.ts asserting those rejections.
  4. (Minor) In extractOverview() (src/engine/extractors/overview.ts), the category filter checks !isProfileCall(event) && !isPhaseAsync(event.ph) without entryToNode?.has(event) (unlike rendererCpuFilter() in src/engine/helpers.ts). Just confirming whether omitting entryToNode?.has(event) there is intentional.

@kurtextrem
kurtextrem force-pushed the codex/trace-cpu-analysis branch from 09fcbbc to bc43d82 Compare November 19, 2026 15:17
@jackfranklin
jackfranklin merged commit 8e9feb6 into ChromeDevTools:main Nov 19, 2026
6 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