-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Log yielded time in the Component Track #31563
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,54 @@ export function logComponentEffect( | |
} | ||
} | ||
|
||
export function logYieldTime(startTime: number, endTime: number): void { | ||
if (supportsUserTiming) { | ||
const yieldDuration = endTime - startTime; | ||
if (yieldDuration < 1) { | ||
// Skip sub-millisecond yields. This happens all the time and is not interesting. | ||
return; | ||
} | ||
// Being blocked on CPU is potentially bad so we color it by how long it took. | ||
reusableComponentDevToolDetails.color = | ||
yieldDuration < 5 | ||
? 'primary-light' | ||
: yieldDuration < 10 | ||
? 'primary' | ||
: yieldDuration < 100 | ||
Comment on lines
+126
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we decide the numeric value of these thresholds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally the render time ones are This comes from that a typical component should really be less then 1ms. If it's less than 10 you can still comfortably fit the rendering within a frame with some additional overhead but that's still very high for a single component. You can do a lot in 10ms. That still lets you do JS based animations. Above that you're starting to be unable to do JS animations without dropping frames. Approaching error territory but ideally an event should respond in about 50ms. If on average your click hits in the middle of 100ms, and we yield 50ms after that. Assuming the response renders fast after that, you're still within the range of feeling responsive so it's ok. But that's the very top end. Above 100ms you're really in error territory. You can no longer be responsive to new input. The effect ones are more permissive because they are expected to kind of happen in the seams like when you commit a brand new page rather than in the background or continuously. E.g. the animation probably just finished and is about to restart. However, we probably should maybe lower this for Blocking lane because a long commit in blocking lane is also not good because it's likely to maybe happen more repeatedly. For yields I'm trying to mirror the time coloring of component render. In that case it's something else blocking us so whatever that is has the same constraints as we do. However, it's more likely to have small little 1-5ms yields due to some little timer or something yielding that I increased the minimum number a little bit. |
||
? 'primary-dark' | ||
: 'error'; | ||
reusableComponentOptions.start = startTime; | ||
reusableComponentOptions.end = endTime; | ||
performance.measure('Blocked', reusableComponentOptions); | ||
} | ||
} | ||
|
||
export function logSuspendedYieldTime( | ||
startTime: number, | ||
endTime: number, | ||
suspendedFiber: Fiber, | ||
): void { | ||
if (supportsUserTiming) { | ||
reusableComponentDevToolDetails.color = 'primary-light'; | ||
reusableComponentOptions.start = startTime; | ||
reusableComponentOptions.end = endTime; | ||
performance.measure('Suspended', reusableComponentOptions); | ||
} | ||
} | ||
|
||
export function logActionYieldTime( | ||
startTime: number, | ||
endTime: number, | ||
suspendedFiber: Fiber, | ||
): void { | ||
if (supportsUserTiming) { | ||
reusableComponentDevToolDetails.color = 'primary-light'; | ||
reusableComponentOptions.start = startTime; | ||
reusableComponentOptions.end = endTime; | ||
performance.measure('Action', reusableComponentOptions); | ||
} | ||
} | ||
|
||
export function logBlockingStart( | ||
updateTime: number, | ||
eventTime: number, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these become >=1ms when CPU throttling is turned on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for the really slow ones. Depends on the overhead of yielding on the platform I guess.