mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #456] [CLOSED] perf(core): cache measureFunc results in TextBufferRenderable #1331
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1331
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/456
Author: @remorses
Created: 12/29/2025
Status: ❌ Closed
Base:
main← Head:measure-cache-optimization📝 Commits (6)
fa398bbperf(core): cache measureFunc results in TextBufferRenderablece214c9fix: consistent height handling in measure cache hit/miss paths36179a4refactor: move measure cache to TextBufferViewa69497efix: use unlimited height for measure cache to avoid truncation35bc607Merge branch 'main' into measure-cache-optimization9d0e95echore: restore Math.floor in measureForDimensions📊 Changes
5 files changed (+213 additions, -2 deletions)
View changed files
📝
.gitignore(+1 -0)➕
packages/core/src/benchmark/measure-cache-benchmark.ts(+169 -0)📝
packages/core/src/renderables/TextBufferRenderable.ts(+0 -1)📝
packages/core/src/text-buffer-view.ts(+31 -1)📝
packages/core/src/text-buffer.ts(+12 -0)📄 Description
Summary
Adds a measure cache to
TextBufferRenderableto avoid redundantmeasureForDimensionscalls during Yoga layout passes.Why Yoga calls measureFunc multiple times:
During flexbox layout, Yoga probes nodes with different width constraints to determine optimal sizing:
Undefinedmode to get intrinsic sizeAtMostto constrain to available spaceExactlyafter resolving flex grow/shrinkThis means
measureForDimensions(which does text wrapping calculations) was being called 2-3x per layout pass per text node.Solution:
_versioncounter toTextBufferthat increments on content changesTextBufferRenderablekeyed by widthtextBuffer.versionchanges orwrapModechangesBenchmark results (144 text renderables in 8x6 grid):
References https://github.com/sst/opentui/pull/433#issuecomment-3697326260
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.