Repository navigation
perf(ui): a ChoiceBar measures only when what it measures changes, compared by structure - #4325
Merged
Merged
Conversation
…hey change useFoldTogether measured its options after every draw: a layout effect with no dependency list read every option's box and getComputedStyle, each forcing a style and layout pass over the whole window. The agent tab's toolbar bar draws again with every transcript page, so a profile with a long transcript open put it at 1.06 s of every 15 s, the largest single cost left after #4296. It now measures as it first draws, whenever the options' names, glyphs, or counts or the bar's look change, and whenever the bar or an option resizes. The resize observer follows the options afresh as they change. 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.
|
…essages by structure ChoiceBar's thumb and fold decided whether to measure again by a string joined from the bar's look and its options, which AGENTS.md rules out. Each is now a typed value, kept from the draw before while every part of it is equal (useKept, over @luke/wire's keepIdentity), so its effects run only when it changes. applyMessagesPage compared a message heard again with a deep compare of its own. It now uses keepIdentity too, so a message that grew keeps every part that didn't change, and one heard again unchanged is the one held. Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
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. Charles asked for a profile with the long "Neon Realtime" transcript open, then for the keys to be cleaned up.
What the profile showed
The build was
bae007ad2, which includes #4296. The transcript had about 33k elements, and the window was in use. Over 15 s the main thread was busy 10.0 s, with 1,323 style recalcs.The largest single cost was
useFoldTogetherinchoice-bar.tsx, at 1.06 s of every 15 s:useLayoutEffect(measure)had no dependency list, so it read every option's box andgetComputedStyle(bar)after every draw. Each read forced a style and layout pass over the whole window.What changed
AGENTS.mdrules out.OptionsPlaced,OptionsNamed).useKeptkeeps the previous value while every part of it is equal, usingkeepIdentityfrom@luke/wire, so the effects run only when it changes.applyMessagesPage: my hand-written deep compare from perf(panel,ui): stop forcing a whole-window layout on every draw and DOM change #4296 is replaced bykeepIdentity. A message heard again unchanged is still the one held, and a message that grew now also keeps the parts that didn't change.Tests
namedis dropped from the measure effect's dependencies.placedis dropped from the thumb's dependencies.Made with Luke