Repository navigation
fix(browser): Preserve empty stacks in continuous profiles - #25764
Merged
Merged
Conversation
Co-Authored-By: GPT-6 <codex@openai.com>
Contributor
size-limit report 📦Compared: 8f9412e (PR test merge using develop at f75f15b) Against: f75f15b (develop) · base run #63873 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 7 not successful, 58 successful. See the run.
Successful checks
|
msonnb
marked this pull request as ready for review
October 27, 2026 15:12
msonnb
requested review from
Lms24 and
logaretm
and removed request for
a team
October 27, 2026 15:13
logaretm
approved these changes
Oct 27, 2026
Comment on lines
+150
to
+164
| let emptyStackId: number | undefined; | ||
| const samples: ContinuousThreadCpuProfile['samples'] = []; | ||
| for (let i = 0; i < input.samples.length; i++) { | ||
| const sample = input.samples[i]; | ||
| if (!sample) { | ||
| continue; | ||
| } | ||
| let stackId = sample.stackId; | ||
| if (stackId === undefined) { | ||
| if (emptyStackId === undefined) { | ||
| emptyStackId = input.stacks.length; | ||
| stacks[emptyStackId] = []; | ||
| } | ||
| stackId = emptyStackId; | ||
| } |
Member
There was a problem hiding this comment.
l: The empty stack's id is always input.stacks.length, so I think we can drop the lazy tracking:
Suggested change
| let emptyStackId: number | undefined; | |
| const samples: ContinuousThreadCpuProfile['samples'] = []; | |
| for (let i = 0; i < input.samples.length; i++) { | |
| const sample = input.samples[i]; | |
| if (!sample) { | |
| continue; | |
| } | |
| let stackId = sample.stackId; | |
| if (stackId === undefined) { | |
| if (emptyStackId === undefined) { | |
| emptyStackId = input.stacks.length; | |
| stacks[emptyStackId] = []; | |
| } | |
| stackId = emptyStackId; | |
| } | |
| const emptyStackId = input.stacks.length; | |
| const samples: ContinuousThreadCpuProfile['samples'] = []; | |
| for (let i = 0; i < input.samples.length; i++) { | |
| const sample = input.samples[i]; | |
| if (!sample) { | |
| continue; | |
| } | |
| const stackId = sample.stackId ?? emptyStackId; | |
| if (stackId === emptyStackId) { | |
| stacks[emptyStackId] ??= []; | |
| } |
Co-Authored-By: GPT-6 <codex@openai.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 fixes a bug where we fell back to stack ID 0 for profiling samples that don't have an associated stack (i.e. are idle). Stack ID 0 is a real stack though (usually the first one from the callback that started profiling), leading to the profiler recording the sample as being active in the frames of stack 0 instead of idle.
This PR creates an empty stack if the sample has no stack attached, assign its ID to the sample, and reuses it across the profile, matching the behavior of the legacy profiler.
Fixes #25757