Repository navigation
perf: traverse layout with an iterator stack - #46
Merged
Merged
Conversation
commit: |
cowboyd
marked this pull request as ready for review
October 27, 2026 19:11
jbolda
approved these changes
Oct 27, 2026
jbolda
left a comment
Member
There was a problem hiding this comment.
(There was previous discussion between us so just making that clear that I am not just glossing over the content.)
The perf is worth it and it is in a place we can continue to iterate for more perf or improved ergonomics. Seems worthwhile to move forward with it.
natemoo-re
approved these changes
Oct 29, 2026
cowboyd
force-pushed
the
layout-iterator-stack
branch
from
November 6, 2026 19:21
35d32f2 to
ba1baa4
Compare
Merging this PR will regress 1 benchmark
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
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.
What does this PR do?
Deep trees make layout's recursive generator delegation increasingly expensive due to the way JavaScript handles generator delegation. This change traverses child iterators with an explicit stack, so that externally the API remains exactly the same, but internally it is much more performant.
The performance issue is demonstrated by the rendering benchmarks added in #45, so no separate issue is needed. Tests cover a 20,000-level tree, adjacent text grouping, stable IDs, subtree layout, and early-return closing behavior.
Benchmark comparison
Ran the existing rendering benchmark suite before and after: 120 cases per version, sequentially on the same machine with identical dependencies and settings. Values below are end-to-end mean rendering times in milliseconds.
Initial render, 2,000 components:
Mutation workloads, 2,000-component bamboo trees:
Type of change
Checklist
pnpm test)pnpm format)AI-generated code disclosure