Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fiber] Log the Render/Commit phases and the gaps in between #31016

Merged
merged 8 commits into from
Sep 23, 2024
Prev Previous commit
Next Next commit
Log the render phase when it completes
  • Loading branch information
sebmarkbage committed Sep 20, 2024
commit 177c67b0910dcb72f1e85df509e4c10f1f46dfce
9 changes: 9 additions & 0 deletions packages/react-reconciler/src/ReactFiberPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ export function logTransitionStart(
}
}
}

export function logRenderPhase(startTime: number, endTime: number): void {
if (supportsUserTiming) {
reusableComponentDevToolDetails.color = 'primary-light';
reusableComponentOptions.start = startTime;
reusableComponentOptions.end = endTime;
performance.measure('Render', reusableComponentOptions);
}
}
6 changes: 6 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
import {
logBlockingStart,
logTransitionStart,
logRenderPhase,
} from './ReactFiberPerformanceTrack';

import {
Expand Down Expand Up @@ -239,6 +240,7 @@ import {
clampTransitionTimers,
markNestedUpdateScheduled,
renderStartTime,
renderEndTime,
recordRenderTime,
recordCompleteTime,
recordCommitTime,
Expand Down Expand Up @@ -1124,6 +1126,8 @@ function finishConcurrentRender(
// Track when we finished the last unit of work, before we actually commit it.
// The commit can be suspended/blocked until we commit it.
recordCompleteTime();
setCurrentTrackFromLanes(lanes);
logRenderPhase(renderStartTime, renderEndTime);
}

// TODO: The fact that most of these branches are identical suggests that some
Expand Down Expand Up @@ -1509,6 +1513,8 @@ export function performSyncWorkOnRoot(root: FiberRoot, lanes: Lanes): null {

if (enableProfilerTimer && enableComponentPerformanceTrack) {
recordCompleteTime();
setCurrentTrackFromLanes(lanes);
logRenderPhase(renderStartTime, renderEndTime);
}

// We now have a consistent tree. Because this is a sync render, we
Expand Down