Skip to content

perf(ink): cache text measurements across yoga flex re-passes - #14818

Merged
ethernet8023 merged 1 commit into
mainfrom
ink-perf
Apr 23, 2026
Merged

perf(ink): cache text measurements across yoga flex re-passes#14818
ethernet8023 merged 1 commit into
mainfrom
ink-perf

Conversation

@ethernet8023

@ethernet8023 ethernet8023 commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Why did i write this PR?

Scrolling in the new TUI the thinking info expanded was mad laggy

What does this PR do?

Adds a per-ink-text measurement cache keyed by width|widthMode to avoid re-squashing and re-wrapping the same text when yoga calls measureFunc multiple times per frame with different widths during flex layout re-pass

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • adds caching in ui-tui/packages/hermes-ink/src/ink/dom.ts

How to Test

  1. Expand the thinking box while the model is doing a long thinking process
  2. scroll up and down a lot

previously, you'd get a ton of lag (in yoga layout)
now, you get no lag :D

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: NixOS + fish + ghostty

Adds a per-ink-text measurement cache keyed by width|widthMode to avoid
re-squashing and re-wrapping the same text when yoga calls measureFunc
multiple times per frame with different widths during flex layout re-pass.
@ethernet8023
ethernet8023 merged commit c95c6bd into main Apr 23, 2026
9 of 10 checks passed
@ethernet8023
ethernet8023 deleted the ink-perf branch April 23, 2026 23:58
@alt-glitch alt-glitch added type/perf Performance improvement or optimization P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 24, 2026
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
perf(ink): cache text measurements across yoga flex re-passes
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
perf(ink): cache text measurements across yoga flex re-passes
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
perf(ink): cache text measurements across yoga flex re-passes
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
perf(ink): cache text measurements across yoga flex re-passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants