Skip to content

Commit b2f6365

Browse files
authored
Minor Tweak to Performance Track (facebook#32808)
Rename "Suspended" commit to "Suspended on CSS" since that's the only reason for this particular branch. This will not hold true because with suspended images and with view transitions those can also be the reason. So in the future we need to add those. Only log "Blocked" in the components track if we yield for 3ms or longer. It's common to have like 1-2ms yield times for various reasons going on which is not worth the noise to consider "blocking". Rename "Blocked" to "Update" in the Blocking/Transition tracks. This is when a setState happens and with stack traces it's where you should look for the stack trace of the setState. So we want to indicate that this is the "Update". I only added the "Blocked" part if we're blocked for more than 5ms before we can start rendering - indicating that some other track was working at the same time and preventing us from rendering.
1 parent b81c92b commit b2f6365

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

packages/react-reconciler/src/ReactFiberPerformanceTrack.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export function logComponentEffect(
284284
export function logYieldTime(startTime: number, endTime: number): void {
285285
if (supportsUserTiming) {
286286
const yieldDuration = endTime - startTime;
287-
if (yieldDuration < 1) {
287+
if (yieldDuration < 3) {
288288
// Skip sub-millisecond yields. This happens all the time and is not interesting.
289289
return;
290290
}
@@ -299,6 +299,10 @@ export function logYieldTime(startTime: number, endTime: number): void {
299299
: 'error';
300300
reusableComponentOptions.start = startTime;
301301
reusableComponentOptions.end = endTime;
302+
// This get logged in the components track if we don't commit which leaves them
303+
// hanging by themselves without context. It's a useful indicator for why something
304+
// might be starving this render though.
305+
// TODO: Considering adding these to a queue and only logging them if we commit.
302306
performance.measure('Blocked', reusableComponentOptions);
303307
}
304308
}
@@ -365,7 +369,11 @@ export function logBlockingStart(
365369
reusableLaneOptions.start = updateTime;
366370
reusableLaneOptions.end = renderStartTime;
367371
performance.measure(
368-
isSpawnedUpdate ? 'Cascade' : 'Blocked',
372+
isSpawnedUpdate
373+
? 'Cascading Update'
374+
: renderStartTime - updateTime > 5
375+
? 'Update Blocked'
376+
: 'Update',
369377
reusableLaneOptions,
370378
);
371379
}
@@ -411,7 +419,10 @@ export function logTransitionStart(
411419
reusableLaneDevToolDetails.color = 'primary-light';
412420
reusableLaneOptions.start = updateTime;
413421
reusableLaneOptions.end = renderStartTime;
414-
performance.measure('Blocked', reusableLaneOptions);
422+
performance.measure(
423+
renderStartTime - updateTime > 5 ? 'Update Blocked' : 'Update',
424+
reusableLaneOptions,
425+
);
415426
}
416427
}
417428
}
@@ -588,7 +599,9 @@ export function logSuspendedCommitPhase(
588599
reusableLaneDevToolDetails.color = 'secondary-light';
589600
reusableLaneOptions.start = startTime;
590601
reusableLaneOptions.end = endTime;
591-
performance.measure('Suspended', reusableLaneOptions);
602+
// TODO: Make this conditionally "Suspended on Images" or both when we add Suspensey Images.
603+
// TODO: This might also be Suspended while waiting on a View Transition.
604+
performance.measure('Suspended on CSS', reusableLaneOptions);
592605
}
593606
}
594607

0 commit comments

Comments
 (0)