Skip to content

Conversation

@leftspin
Copy link
Contributor

@leftspin leftspin commented Jan 20, 2026

Summary

  • Add LineLayoutCache to cache CTLine objects and ViewLineInfo per buffer row, avoiding repeated CTLineCreateWithAttributedString calls for unchanged lines
  • Add RenderingStrategy enum (.legacy, .cached) with runtime toggle via renderingStrategy property
  • Add cache metrics and telemetry (LineLayoutCacheMetrics) for observability
  • Add comprehensive test suite for cache behavior, invalidation, and rendering correctness

Test coverage

  • LineLayoutCacheTests - cache hits/misses, invalidation, generation tracking
  • RenderingStrategyTests - strategy switching, visual equivalence
  • TerminalUpdateRangeTests - dirty region tracking
  • ViewLineInfoTests - line info construction

Expected performance characteristics

Scenario Cache benefit
Scrolling through static content (scrollback, less, git log) High - lines cached by absolute buffer row, scroll back = cache hit
Mostly static display (editors, shell with visible history) Good - only changed lines invalidated
Full-screen refresh every frame (top, htop) Minimal - all lines invalidated each cycle

The cache keys on absolute bufferRow, not screen position, so viewport scrolling without content changes yields cache hits on revisited lines.

TODO

  • Cache eviction strategy (LRU or size cap) to bound memory usage for large scrollback

@leftspin
Copy link
Contributor Author

Just PR’ing as a heads up. Currently testing in my visionOS remote term app. Getting improve fps and lower latency especially with tmux panes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant