FrankenTerm

Three-Tier Scrollback

242 words1 min read5 subsectionsFrom the README at ft 0.15.21

On this page5
Tier transitionsHot tierWarm tierCold tierWhy this layout

In a simple sizing model, 200 panes retaining roughly 20 MB of uncompressed backbuffer each consume about 4 GB before other process costs. That is an illustrative calculation, not a measured comparison against every stock terminal. ft keeps scrollback in three tiers and migrates lines between them based on access patterns and pressure.

Tier transitions

new line
  │
  ▼
┌──────────┐
│   HOT    │  VecDeque in RAM, ~200 bytes/line
│ (last N) │
└──────────┘
  │ aged out (configurable: line count, time)
  ▼
┌──────────┐
│   WARM   │  zstd-compressed in RAM, ~40 bytes/line (~5:1 ratio typical)
│ (mid-age)│  Decompressed on demand
└──────────┘
  │ evicted (configurable: pressure tier, age)
  ▼
┌──────────┐
│   COLD   │  Persisted in SQLite output_segments
│ (queryable on demand) │
└──────────┘

Hot tier

A bounded VecDeque of decoded terminal lines. Direct indexing for renderer paint; O(1) push to the head. Tier boundary is configurable (default: most recent N lines, with N depending on pane priority).

Warm tier

Block-compressed (zstd) older lines. Compression block size is tuned so a single block is roughly the size of a screenful. Decompression is on-demand: a request for line 5000 decompresses only the block containing that line, not the entire warm tier.

Cold tier

When a line is evicted from warm (under Critical/Emergency pressure or aged past the warm threshold), it is dropped from RAM. Within the configured durable-retention window, the line remains queryable via the output_segments table (which is the canonical source of truth) and via FTS5 search; age, count, or storage-size retention may later prune it.

Why this layout

  • Renderer hot path stays fast. The renderer only reads from the hot tier.
  • Tier eviction does not create an immediate search gap. Lines that leave RAM remain searchable in SQLite until the configured durable-retention policy prunes them.
  • Memory scales sublinearly with scrollback depth. Adding 10× more scrollback doesn't add 10× RAM.