Skip to content

perf(history): load the replay emulator only for eligible logs - #33894

Closed
OrcaWin wants to merge 7 commits into
OrcaWin/mem-02-ssh-boundaryfrom
OrcaWin/mem-04-history-replay
Closed

OrcaWin wants to merge 7 commits into
OrcaWin/mem-02-ssh-boundaryfrom
OrcaWin/mem-04-history-replay

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Current disposition: deferred for this RAM project; keep draft. This boundary did not demonstrate an individual full-idle memory saving: xterm remains eager through other runtime owners. Evidence #33912 is merged independently into main; its tooling/report provides no reason to merge this implementation.

ELI5

History discovery should not load an emulator until there is terminal output to replay.

What Changed

Import the real emulator after metadata, log-size, decoding and generation checks. Preserve replay serialization and emulator disposal. A module-load or constructor failure now retains the existing checkpoint fallback and releases replay admission.

Why

This removes history discovery as an eager emulator edge. Other runtime terminal owners still load xterm in a full idle session, so this PR claims no full-session xterm memory saving.

Visual Proof

N/A — main-process loading/lifecycle changes; no rendered UI change. Hidden Playwright CDP checks on the complete stack passed, including the rendered SSH add-host/test/refusal flow; see the evidence PR.

Testing

Existing history suite: 55 tests passed. New real-emulator first-use test and load-failure/checkpoint/semaphore regression test passed. Included in the successful integrated Linux build. The combined recommended gate passed 23/24 checks (22,643 tests passed, 3 failed). The three daemon initialization failures also reproduce at the pinned upstream base; the complete gate remains failing. See #33912 for the control and exact cases.

Local runtime evidence is Linux x64/Electron 43.8.1. macOS physical footprint and native Windows/macOS behavior are not measured locally. Remote, folder workspace, mobile and serve contracts remain in scope; there is no wire-protocol change.

Review

Historical experimental stack 3/6. Depends on #33892. Review this PR against its configured base branch.

Evidence and benchmark: #33912. The historical measured stack measures −4.44 MB median idle V8 heap and −5.87 MB median Linux RSS (n=3, 120 seconds, fresh hidden profiles, telemetry/GPU disabled). macOS physical footprint is unverified. M3 is a separate experiment on performance hold; M4/M5 do not make xterm/YAML cold at full idle.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content copied.

Checklist

@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-04-history-replay branch from 8f25712 to 0e7cb2d Compare October 26, 2026 10:43
@OrcaWin
OrcaWin changed the base branch from OrcaWin/mem-03-rpc-boundary to OrcaWin/mem-02-ssh-boundary October 26, 2026 10:43
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-02-ssh-boundary branch from 759b6b2 to c5f3a4e Compare October 26, 2026 10:52
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-04-history-replay branch from 0e7cb2d to 8be5df9 Compare October 26, 2026 10:52
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-02-ssh-boundary branch from c5f3a4e to da5e68f Compare October 26, 2026 11:22
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-04-history-replay branch from 8be5df9 to 7483234 Compare October 26, 2026 11:22
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-02-ssh-boundary branch from da5e68f to c5f3a4e Compare October 26, 2026 12:01
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-04-history-replay branch from 7483234 to 8be5df9 Compare October 26, 2026 12:01
@OrcaWin
OrcaWin force-pushed the OrcaWin/mem-02-ssh-boundary branch from aba5da7 to 452d566 Compare October 27, 2026 00:50
@OrcaWin

OrcaWin commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: most of this diff comes from a stacked base about 3,400 commits behind main (SSH startup and quit-registration commits), and the history change itself is a few production lines. That change defers the HeadlessEmulator import in history-reader.ts, but main still imports HeadlessEmulator eagerly in production from history-reader.ts:9, durable-history-replay-emulator.ts:1, terminal-checkpoint-serializer.ts:5, and daemon/sessions/session-output-plane.ts:6, so no module load is saved in a real process. The PR body reports no idle saving of its own. Its two new tests assert module-import counts, which the test policy does not allow. A change against main that shows a measured saving across all eager importers would be welcome.

@OrcaWin OrcaWin closed this Nov 8, 2026
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