Skip to content

Commit

Permalink
[Fiber] Log the Render/Commit phases and the gaps in between (#31016)
Browse files Browse the repository at this point in the history
A slight behavior change here too is that I now mark the start of the
commit phase before the BeforeMutationEffect phase. This affects
`<Profiler>` too.

The named sequences are as follows:

Render -> Suspended or Throttled -> Commit -> Waiting for Paint ->
Remaining Effects

The Suspended phase is only logged if we delay the Commit due to CSS /
images.

The Throttled phase is only logged if we delay the commit due to the
Suspense throttling timer.

<img width="1246" alt="Screenshot 2024-09-20 at 9 14 23 PM"
src="https://github.com/user-attachments/assets/8d01f444-bb85-472b-9b42-6157d92c81b4">

I don't yet log render phases that don't complete. I think I also need
to special case renders that or don't commit after being suspended.

DiffTrain build for [4e9540e](4e9540e)
  • Loading branch information
sebmarkbage committed Sep 23, 2024
1 parent 7e85a93 commit d21a761
Show file tree
Hide file tree
Showing 34 changed files with 1,908 additions and 1,350 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d4688dfaafe51a4cb6e3c51fc2330662cb4e2296
4e9540e3c2a8f9ae56318b967939c99b3a815190
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d4688dfaafe51a4cb6e3c51fc2330662cb4e2296
4e9540e3c2a8f9ae56318b967939c99b3a815190
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-www-classic-d4688dfa-20240920";
exports.version = "19.0.0-www-classic-4e9540e3-20240923";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-www-modern-d4688dfa-20240920";
exports.version = "19.0.0-www-modern-4e9540e3-20240923";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-d4688dfa-20240920";
exports.version = "19.0.0-www-classic-4e9540e3-20240923";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-d4688dfa-20240920";
exports.version = "19.0.0-www-modern-4e9540e3-20240923";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-d4688dfa-20240920";
exports.version = "19.0.0-www-classic-4e9540e3-20240923";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-d4688dfa-20240920";
exports.version = "19.0.0-www-modern-4e9540e3-20240923";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
87 changes: 60 additions & 27 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10047,7 +10047,12 @@ __DEV__ &&
}
else ref.current = null;
}
function commitProfiler(finishedWork, current, commitTime, effectDuration) {
function commitProfiler(
finishedWork,
current,
commitStartTime,
effectDuration
) {
var _finishedWork$memoize = finishedWork.memoizedProps,
id = _finishedWork$memoize.id,
onCommit = _finishedWork$memoize.onCommit;
Expand All @@ -10061,20 +10066,20 @@ __DEV__ &&
finishedWork.actualDuration,
finishedWork.treeBaseDuration,
finishedWork.actualStartTime,
commitTime
commitStartTime
);
"function" === typeof onCommit &&
onCommit(
finishedWork.memoizedProps.id,
current,
effectDuration,
commitTime
commitStartTime
);
}
function commitProfilerPostCommitImpl(
finishedWork,
current,
commitTime,
commitStartTime,
passiveEffectDuration
) {
var _finishedWork$memoize2 = finishedWork.memoizedProps;
Expand All @@ -10087,13 +10092,13 @@ __DEV__ &&
finishedWork,
current,
passiveEffectDuration,
commitTime
commitStartTime
);
}
function commitProfilerPostCommit(
finishedWork,
current,
commitTime,
commitStartTime,
passiveEffectDuration
) {
try {
Expand All @@ -10102,7 +10107,7 @@ __DEV__ &&
commitProfilerPostCommitImpl,
finishedWork,
current,
commitTime,
commitStartTime,
passiveEffectDuration
);
} catch (error$21) {
Expand Down Expand Up @@ -10451,7 +10456,7 @@ __DEV__ &&
commitProfiler,
finishedWork,
current,
commitTime,
commitStartTime,
finishedRoot.effectDuration
);
} catch (error$20) {
Expand Down Expand Up @@ -11455,7 +11460,7 @@ __DEV__ &&
commitProfiler,
finishedWork,
current,
commitTime,
commitStartTime,
includeWorkInProgressEffects.effectDuration
);
} catch (error$20) {
Expand Down Expand Up @@ -11709,7 +11714,7 @@ __DEV__ &&
commitProfilerPostCommit(
finishedWork,
finishedWork.alternate,
commitTime,
commitStartTime,
finishedRoot.passiveEffectDuration
))
: recursivelyTraversePassiveMountEffects(
Expand Down Expand Up @@ -12565,7 +12570,10 @@ __DEV__ &&
workInProgressRootDidIncludeRecursiveRenderUpdate,
workInProgressDeferredLane,
workInProgressRootInterleavedUpdatedLanes,
workInProgressSuspendedRetryLanes
workInProgressSuspendedRetryLanes,
IMMEDIATE_COMMIT,
renderStartTime,
0
);
else {
if (
Expand Down Expand Up @@ -12596,7 +12604,10 @@ __DEV__ &&
workInProgressDeferredLane,
workInProgressRootInterleavedUpdatedLanes,
workInProgressSuspendedRetryLanes,
workInProgressRootDidSkipSuspendedSiblings
workInProgressRootDidSkipSuspendedSiblings,
THROTTLED_COMMIT,
renderStartTime,
0
),
didTimeout
);
Expand All @@ -12612,7 +12623,10 @@ __DEV__ &&
workInProgressDeferredLane,
workInProgressRootInterleavedUpdatedLanes,
workInProgressSuspendedRetryLanes,
workInProgressRootDidSkipSuspendedSiblings
workInProgressRootDidSkipSuspendedSiblings,
IMMEDIATE_COMMIT,
renderStartTime,
0
);
}
}
Expand Down Expand Up @@ -12666,7 +12680,11 @@ __DEV__ &&
lanes,
spawnedLane,
updatedLanes,
suspendedRetryLanes
suspendedRetryLanes,
didSkipSuspendedSiblings,
suspendedCommitReason,
completedRenderStartTime,
completedRenderEndTime
) {
lanes = finishedWork.subtreeFlags;
(lanes & 8192 || 16785408 === (lanes & 16785408)) &&
Expand All @@ -12678,7 +12696,10 @@ __DEV__ &&
didIncludeRenderPhaseUpdate,
spawnedLane,
updatedLanes,
suspendedRetryLanes
suspendedRetryLanes,
suspendedCommitReason,
completedRenderStartTime,
completedRenderEndTime
);
}
function isRenderConsistentWithExternalStores(finishedWork) {
Expand Down Expand Up @@ -12797,7 +12818,10 @@ __DEV__ &&
workInProgressRootDidIncludeRecursiveRenderUpdate,
workInProgressDeferredLane,
workInProgressRootInterleavedUpdatedLanes,
workInProgressSuspendedRetryLanes
workInProgressSuspendedRetryLanes,
IMMEDIATE_COMMIT,
renderStartTime,
0
);
ensureRootIsScheduled(root);
return null;
Expand Down Expand Up @@ -13462,7 +13486,10 @@ __DEV__ &&
didIncludeRenderPhaseUpdate,
spawnedLane,
updatedLanes,
suspendedRetryLanes
suspendedRetryLanes,
suspendedCommitReason,
completedRenderStartTime,
completedRenderEndTime
) {
var prevTransition = ReactSharedInternals.T,
previousUpdateLanePriority = currentUpdatePriority;
Expand All @@ -13477,7 +13504,10 @@ __DEV__ &&
previousUpdateLanePriority,
spawnedLane,
updatedLanes,
suspendedRetryLanes
suspendedRetryLanes,
suspendedCommitReason,
completedRenderStartTime,
completedRenderEndTime
);
} finally {
(ReactSharedInternals.T = prevTransition),
Expand Down Expand Up @@ -13556,9 +13586,10 @@ __DEV__ &&
(pendingPassiveEffectsRemainingLanes = remainingLanes),
(pendingPassiveTransitions = transitions),
scheduleCallback(NormalPriority$1, function () {
flushPassiveEffects();
flushPassiveEffects(!0);
return null;
}));
commitStartTime = now();
transitions = 0 !== (finishedWork.flags & 15990);
0 !== (finishedWork.subtreeFlags & 15990) || transitions
? ((transitions = ReactSharedInternals.T),
Expand All @@ -13568,7 +13599,6 @@ __DEV__ &&
(updatedLanes = executionContext),
(executionContext |= CommitContext),
commitBeforeMutationEffects(root, finishedWork),
(commitTime = now()),
commitMutationEffects(root, finishedWork, lanes),
(root.current = finishedWork),
enableDebugTracing &&
Expand Down Expand Up @@ -13597,7 +13627,7 @@ __DEV__ &&
(executionContext = updatedLanes),
(currentUpdatePriority = spawnedLane),
(ReactSharedInternals.T = transitions))
: ((root.current = finishedWork), (commitTime = now()));
: (root.current = finishedWork);
(transitions = rootDoesHavePassiveEffects)
? ((rootDoesHavePassiveEffects = !1),
(rootWithPendingPassiveEffects = root),
Expand Down Expand Up @@ -13659,7 +13689,7 @@ __DEV__ &&
null != remainingLanes &&
((root.pooledCache = null), releaseCache(remainingLanes)));
}
function flushPassiveEffects() {
function flushPassiveEffects(wasDelayedCommit) {
if (null !== rootWithPendingPassiveEffects) {
var root = rootWithPendingPassiveEffects,
remainingLanes = pendingPassiveEffectsRemainingLanes;
Expand All @@ -13675,7 +13705,7 @@ __DEV__ &&
return (
(currentUpdatePriority = renderPriority),
(ReactSharedInternals.T = null),
flushPassiveEffectsImpl()
flushPassiveEffectsImpl(wasDelayedCommit)
);
} finally {
(currentUpdatePriority = previousPriority),
Expand Down Expand Up @@ -14993,7 +15023,8 @@ __DEV__ &&
currentEventTransitionLane = 0,
fakeActCallbackNode$1 = {},
now = Scheduler.unstable_now,
commitTime = -0,
renderStartTime = -0,
commitStartTime = -0,
profilerStartTime = -1.1,
profilerEffectDuration = -0,
currentUpdateIsNested = !1,
Expand Down Expand Up @@ -16815,6 +16846,8 @@ __DEV__ &&
nestedPassiveUpdateCount = 0,
rootWithPassiveNestedUpdates = null,
isRunningInsertionEffect = !1,
IMMEDIATE_COMMIT = 0,
THROTTLED_COMMIT = 2,
didWarnStateUpdateForNotYetMountedComponent = null,
didWarnAboutUpdateInRender = !1;
var didWarnAboutUpdateInRenderForAnotherComponent = new Set();
Expand Down Expand Up @@ -17039,11 +17072,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-www-classic-d4688dfa-20240920",
version: "19.0.0-www-classic-4e9540e3-20240923",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-www-classic-d4688dfa-20240920"
reconcilerVersion: "19.0.0-www-classic-4e9540e3-20240923"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -17077,7 +17110,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.0.0-www-classic-d4688dfa-20240920";
exports.version = "19.0.0-www-classic-4e9540e3-20240923";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit d21a761

Please sign in to comment.