Skip to content

mecatui: shrink ui.Model so the reducer stops copying 66 KB per message #2411

Open

Description

@peppescg

Problem

ui.Model is 66,400 bytes and is passed by value through the Bubble Tea reducer chain (Update → update → afterEvent → dispatchNonInputMsg → onStreamMsg → updateStreamEvent → …). Each value-receiver frame copies it, so every message, keystroke, and stream delta copies 66 KB several times.

  • A keystroke frame benchmark spends ~0.6 ms and ~1.8 MB of allocation in the reducer alone.
  • The event goroutine's stack doubles to 4–8 MiB; most of it sits freed in the stack pool.

Proposal

Move the cold sub-states behind pointers (schedule, worktrees, overlay states, possibly prompt) so the Model falls under ~20 KB. This needs care wherever a reducer relies on value-copy semantics (copy-on-write or explicit clones there).

Acceptance

  • unsafe.Sizeof(ui.Model{}) stays under a guard test threshold.
  • The keystroke frame benchmark shows fewer bytes per op.
  • No behavior change (existing suites and goldens).

Activity

  1. self-assigned this
    on Oct 18, 2026
  2. added
    tuimecatui terminal UI (rendering, keybindings, footer, panes, scrollback)
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

tuimecatui terminal UI (rendering, keybindings, footer, panes, scrollback)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions