Repository navigation
perf(core): measure text autofit for a whole slide at once - #150
Merged
Merged
Conversation
|
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.
Text autofit wrote styles and then read
clientWidthandscrollHeightfor one text box at a time, so every autofit box forced its own layout of the slide, both duringrenderSlideand again in its own deferred pass two frames later. That was the largest single cost of rendering a deck: 1,041 ms of self time on the 300-slide bench deck.renderer/autofit.tssplits a box's measurement into phases (prepare, measure, unwrapped measure, apply).runAutofitJobsruns each phase for every box before the next phase starts, so a slide costs two layouts instead of two per box.renderSlidecollects its boxes' jobs and runs them once every node is mounted. The deferred passes for boxes scheduled in the same frame run together in the frame their own doublerequestAnimationFramewould have used. A job scheduled twice in a batch runs once.pnpm bench --runs 9 --against <main build>: the two builds alternate run by run, median of 9, Chromium headless shell 156 on Linux. Times in milliseconds:An A/A run moves these by up to ±10%, so time to first slide is unchanged. The gain is in rendering every slide.
pnpm bench --shotsbefore and after, compared withpnpm bench:diff: 448 of 448 slides identical pixel for pixel.Not shown: