Repository navigation
Conversation
There was a problem hiding this comment.
2 issues found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/react-native/src/react-devtools/react-profile-analysis.ts">
<violation number="1" location="packages/react-native/src/react-devtools/react-profile-analysis.ts:260">
P2: Each matched updater receives the full commit `workMs`, so a commit with multiple updaters charges the same sibling work to every component's finding. Attribute work to the relevant updater or avoid per-component cost attribution when the commit has multiple updaters.</violation>
<violation number="2" location="packages/react-native/src/react-devtools/react-profile-analysis.ts:399">
P2: `workMs` includes unnamed fibers, but `rendered` counts only fibers that `commitRenders` can resolve to profiled components. Qualify this count as profiled components or report a total fiber count so the evidence does not understate what rendered.</violation>
</file>
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
| costMs: commit.durationMs, | ||
| evidence: `commit #${commit.index} took ${ms(commit.durationMs)} rendering ${commit.rendered} components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`, | ||
| costMs: commit.workMs, | ||
| evidence: `commit #${commit.index} took ${ms(commit.workMs)} rendering ${commit.rendered} components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`, |
There was a problem hiding this comment.
P2: workMs includes unnamed fibers, but rendered counts only fibers that commitRenders can resolve to profiled components. Qualify this count as profiled components or report a total fiber count so the evidence does not understate what rendered.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/react-native/src/react-devtools/react-profile-analysis.ts, line 399:
<comment>`workMs` includes unnamed fibers, but `rendered` counts only fibers that `commitRenders` can resolve to profiled components. Qualify this count as profiled components or report a total fiber count so the evidence does not understate what rendered.</comment>
<file context>
@@ -396,8 +395,8 @@ function slowCommitFinding(commit: CommitProfile): Finding {
- costMs: commit.durationMs,
- evidence: `commit #${commit.index} took ${ms(commit.durationMs)} rendering ${commit.rendered} components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`,
+ costMs: commit.workMs,
+ evidence: `commit #${commit.index} took ${ms(commit.workMs)} rendering ${commit.rendered} components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`,
fix: `render less ${owner ? `under ${owner.name} ` : ''}per update (memoize, virtualize, or defer)`,
};
</file context>
| evidence: `commit #${commit.index} took ${ms(commit.workMs)} rendering ${commit.rendered} components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`, | |
| evidence: `commit #${commit.index} took ${ms(commit.workMs)} rendering ${commit.rendered} profiled components${mounted}${inside}${trigger}; most time in ${heaviest.join(', ')}`, |
| const chain = chains.get(key) ?? { component: updater, count: 0, costMs: 0 }; | ||
| chain.count += 1; | ||
| chain.costMs += commit.duration; | ||
| chain.costMs += commits[index]!.workMs; |
There was a problem hiding this comment.
P2: Each matched updater receives the full commit workMs, so a commit with multiple updaters charges the same sibling work to every component's finding. Attribute work to the relevant updater or avoid per-component cost attribution when the commit has multiple updaters.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/react-native/src/react-devtools/react-profile-analysis.ts, line 260:
<comment>Each matched updater receives the full commit `workMs`, so a commit with multiple updaters charges the same sibling work to every component's finding. Attribute work to the relevant updater or avoid per-component cost attribution when the commit has multiple updaters.</comment>
<file context>
@@ -257,7 +257,7 @@ function effectChainFindings(profile: RawReactProfile): Finding[] {
const chain = chains.get(key) ?? { component: updater, count: 0, costMs: 0 };
chain.count += 1;
- chain.costMs += commit.duration;
+ chain.costMs += commits[index]!.workMs;
chains.set(key, chain);
}
</file context>
|
Thanks for the fix. The code at 1496412 has no blocking findings. The regression test and the issue's invariant (render work counted across sibling subtrees) match what the diff does. The open inline thread on reason-row wording still stands: #5427 (comment). The reason row mixes total work (which includes unnamed fibers) with a count of named components only. It is a wording fix, and the PR waits for it to be addressed or resolved. The other thread, #5427 (comment), does not apply here. Each chained updater is charged the commit's whole cost, exactly as the base did, so the author can resolve it. Per-updater apportioning can be a separate issue. The only non-passing checks are two Body rules runs, both cancelled. That workflow grades only the title and body, and a newer edit or push cancels earlier runs, so the diff does not affect it. No conflicts are known. Not verified here: the React 18.3.1 and 19.2.0 before/after numbers (they are consistent with the test fixture), that fiberSelfDurations is never negative, DevTools commit timestamp semantics for f1, and the tests themselves. Before merge, a completed Body rules run and green hosted checks at 1496412 are needed. |
Summary
Fixes #5401. React DevTools reports the largest independently updated subtree as the commit duration. The profiler now sums each fiber’s self time into
workMs, including unnamed fibers. The summary, commit ranking, and slow-commit findings use total work. Commit JSON preserves the originaldurationMs. Saved recordings use the same calculation.Before / after
I recorded three sibling state updates in one synchronous React DOM commit and compared the same recording on base and head.
The second recording’s fiber self times were 9.423, 9.117, and 9.106 ms. The regression test exercises profile stop and saved commit readback with those timings.
Validation
Tested
14964123ac7ea1fd30c1717d46c7f7454d121429on Linux. The build, type check, lint, formatting, layering, Fallow, documentation checks, and 440 related tests passed. The built CLI returned both metrics for both recordings.The full unit run had 22,949 passes, 73 skips, and 11 failures. I reran the five affected test files on unchanged base
202d135063and confirmed the same 11 failures. The local affected-check receipt records failure at the unit stage. Hosted CI is pending.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.