Repository navigation
perf: reuse styles for unchanged elements - #151
Merged
Merged
Conversation
commit: |
3 of 12 tasks
Merging this PR will degrade performance by 10.72%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
natemoo-re
force-pushed
the
natemoo-re/perf/layout-style-reuse
branch
from
December 3, 2026 22:11
9941830 to
1249093
Compare
natemoo-re
marked this pull request as ready for review
December 3, 2026 22:11
cowboyd
approved these changes
Dec 4, 2026
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?
Stacked on #143. Cuts the per-node allocations behind the
grassmemory regressions CodSpeed flagged on that PR.In
grass, every component is a direct child of the root. A single edit marks the root as changed, soLayoutreplays each of the other N−1 siblings one by one. Before replaying a sibling, it callscomputeStyle(child), andcomputeDefaultStylesbuilds 14 new objects every time. A heap profile that also counts collected objects puts about 72% of grass's per-frame churn in style computation. Most of the rest isinfo.get(), which bombshell-dev/tty#179 addresses.Layoutreuses the style it saved at an element's last#openwhen that element isn't inchanges. This is safe because every inline-style and attribute change already notifies its element, which puts it inchanges.CodSpeed
Compared with #143, using tty#179's build: 122 improvements, 3 regressions (2–3 KB each), 175 unchanged. Comparison
Without tty#179, CodSpeed shows little change for this PR: its memory instrument counts native allocations, not the JS heap. Fewer JS allocations also meant fewer collections freeing tty's per-string
encode()buffers, soinitial render (1500)peaks went up about 28%. tty#179 removes those buffers.Still open:
initial render::grass (100)(663 KB) andsingle value update::grass (500)(492 KB). Their allocation counts dropped 85–90%, but a few large untraced blocks remain. ui doesn't affect them, and they don't appear in other shapes or sizes.lays out a deeply nested tree without recursive traversaltimes out locally on a loaded machine both with and without this change. It's not related.Type of change
Checklist
pnpm test)pnpm format)AI-generated code disclosure