Repository navigation
Conversation
🦋 Changeset detectedLatest commit: ab2035a The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@exoego is attempting to deploy a commit to the diegomura Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been 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.
Summary
resolveBookmarkswalks the whole document tree on every render to findbookmarkprops. It does this even when the document has no bookmarks.The walk takes items from a single queue with
listToExplore.shift(). The queue holds a whole level of the tree, so it gets large on big documents. Eachshift()on a large array moves every remaining item, so the walk is quadratic in the number of elements.This PR reads the queue by index instead. The visit order is the same breadth-first order as before. Bookmark refs and parent links do not change.
Measurements
Rendering rows of 9 cells with no bookmarks. Apple M4 Pro, Node 24.21.0, median of 3 runs.
resolveBookmarksbeforeresolveBookmarksafterAt 8,000 rows the whole render is 26% faster. Before this change, doubling the rows made
resolveBookmarksabout 4 times slower. After it, the time doubles.The step runs before pagination, so both pagination engines are affected. In our 270-page report with large tables, it took 4.5 s of a 26 s render.
How to reproduce
Render many rows with no bookmarks. Profile with
node --cpu-profand look at the self time ofresolveBookmarks.Tests
No new tests. The existing "should resolve bookmark hierarchy" test already checks the breadth-first ref order and parent links. A timing test would be flaky in CI. All layout tests pass.
Notes
fetchAssetsandbuildXLinksIndexuse the sameshift()pattern. Their queues stay small, so they are not slow in practice. I left them out to keep this PR focused.