[PR #475] [MERGED] perf(text-buffer-view): cache measureForDimensions results #563

Closed
opened 2026-03-02 23:47:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/475
Author: @simonklee
Created: 1/5/2026
Status: Merged
Merged: 1/5/2026
Merged by: @kommander

Base: mainHead: perf-measure-dimensions


📝 Commits (3)

  • e7dc7c4 perf(text-buffer-view): add cache and arena reuse in measureForDimensions
  • ace275b Merge branch 'main' into perf-measure-dimensions
  • e5908af some more test coverage

📊 Changes

7 files changed (+564 additions, -13 deletions)

View changed files

📝 packages/core/src/text-buffer-view.test.ts (+64 -0)
📝 packages/core/src/zig/tests/text-buffer-view_test.zig (+102 -0)
📝 packages/core/src/zig/tests/wrap-cache-perf_test.zig (+5 -3)
📝 packages/core/src/zig/text-buffer-view.zig (+68 -8)
📝 packages/core/src/zig/text-buffer.zig (+21 -2)
📝 packages/solid/tests/__snapshots__/textarea.test.tsx.snap (+170 -0)
📝 packages/solid/tests/textarea.test.tsx (+134 -0)

📄 Description

Yoga calls measureForDimensions repeatedly during layout. This adds caching
keyed by (buffer, epoch, width, wrap_mode) to avoid repeated rope walks.

  • Use epoch instead of dirty flag since other code paths clear dirty
  • Reuse measure arena with retain_capacity to reduce mmap churn during streaming
  • Add fast path for width=0 or wrap_mode=.none that skips virtual line calculation

I can split up the arena-reuse if you prefer that in another PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/475 **Author:** [@simonklee](https://github.com/simonklee) **Created:** 1/5/2026 **Status:** ✅ Merged **Merged:** 1/5/2026 **Merged by:** [@kommander](https://github.com/kommander) **Base:** `main` ← **Head:** `perf-measure-dimensions` --- ### 📝 Commits (3) - [`e7dc7c4`](https://github.com/anomalyco/opentui/commit/e7dc7c4b7e6a368070f391337ab9c3be7e190e33) perf(text-buffer-view): add cache and arena reuse in measureForDimensions - [`ace275b`](https://github.com/anomalyco/opentui/commit/ace275b1329150e8418aeb0c75900dd9a62d11f1) Merge branch 'main' into perf-measure-dimensions - [`e5908af`](https://github.com/anomalyco/opentui/commit/e5908af134d22cd1b274a8f0d85703dcd5bae2fb) some more test coverage ### 📊 Changes **7 files changed** (+564 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/text-buffer-view.test.ts` (+64 -0) 📝 `packages/core/src/zig/tests/text-buffer-view_test.zig` (+102 -0) 📝 `packages/core/src/zig/tests/wrap-cache-perf_test.zig` (+5 -3) 📝 `packages/core/src/zig/text-buffer-view.zig` (+68 -8) 📝 `packages/core/src/zig/text-buffer.zig` (+21 -2) 📝 `packages/solid/tests/__snapshots__/textarea.test.tsx.snap` (+170 -0) 📝 `packages/solid/tests/textarea.test.tsx` (+134 -0) </details> ### 📄 Description Yoga calls measureForDimensions repeatedly during layout. This adds caching keyed by (buffer, epoch, width, wrap_mode) to avoid repeated rope walks. - Use epoch instead of dirty flag since other code paths clear dirty - Reuse measure arena with retain_capacity to reduce mmap churn during streaming - Add fast path for width=0 or wrap_mode=.none that skips virtual line calculation I can split up the arena-reuse if you prefer that in another PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:47:06 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#563
No description provided.