Repository navigation
perf(panel): an empty toast stack measures nothing on every draw - #4324
Merged
Merged
Conversation
The toast stack's glide ran a layout effect after every draw, with no dependency list. It read the motion tokens through getComputedStyle and every toast's box, which lays out the whole window, even though the stack is empty nearly always. A profile of the panel at rest put it at about a fifth of the main thread's busy time. An empty stack now returns before reading anything. Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #4296, found by the profile Charles asked for after it merged.
The problem:
useStackGlideintoast.tsxruns auseLayoutEffectwith no dependency list. After every draw of the toast stack it reads--duration-fastand--spring-fastthroughgetComputedStyle, plus every toast's box. Each read forces a style or layout pass over the whole window, and it happens even though the stack is nearly always empty.The evidence: a 15 s profile of the panel at rest on
bae007ad2, which includes #4296, put 203 ms ingetPropertyValuefromtoast.tsx:401. That is about a fifth of the main thread's busy time in that window, and the cost grows with the size of the DOM.The fix: an empty stack now returns before reading anything. A stack with toasts in it glides as before.
The behavior doesn't change. The existing toast tests pass, and I added none, since all that changes is the work done.
I swept
packages/panelandpackages/uifor otheruseLayoutEffectcalls with no dependency list that read layout. The rest already return early when they have nothing to do: plan comments with no threads, a reveal that isn't pending, a combobox with no active row.Made with Luke