Skip to content

fix: pick busiest CPU profile from multi-thread traces - #24

Merged
hurali97 merged 1 commit into
callstackincubator:mainfrom
TMisiukiewicz:fix/idle-profile-selection
Oct 8, 2026
Merged

hurali97 merged 1 commit into
callstackincubator:mainfrom
TMisiukiewicz:fix/idle-profile-selection

Conversation

@TMisiukiewicz

Copy link
Copy Markdown
Contributor

Explanation of Change

Chrome Performance traces can hold more than one CPU profile, one for each JS thread that was recording (main renderer, other tabs, service workers). Tracesift keeps only one of them, and it picked the profile with the most samples.

An idle thread can easily have the most samples. In the trace that exposed this, the service worker had 100k samples, but almost all of them were (idle), so it beat the main renderer profile (41k nodes of real app work, 60k samples). The analysis then ran on a profile with nothing in it.

This change ranks profiles by the number of samples that are not (idle), so the thread that actually did work gets analyzed.

Tests

  1. Record a Chrome Performance trace of a web app that has an active service worker (or another tab/renderer recording at the same time), so the trace contains several Profile/ProfileChunk groups.
  2. Upload the trace to tracesift.
  3. Verify that the hotspots and bottlenecks come from the app's main thread code, not a near-empty profile made of (idle)/(program).
  4. Upload a single-profile .cpuprofile and a Hermes trace and verify that both still analyze the same as before.
  • npm test, typecheck and lint pass

🤖 Generated with Claude Code

@TMisiukiewicz
TMisiukiewicz marked this pull request as ready for review October 8, 2026 11:25

@hurali97 hurali97 left a comment

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.

Thanks 🚀

@hurali97
hurali97 merged commit 624c272 into callstackincubator:main Oct 8, 2026
1 check 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