Skip to content

perf(editor): speed up repeated edits - #267

Merged
fcoury-oai merged 2 commits into
mainfrom
fcoury/edit-replay-performance
Aug 17, 2026
Merged

fcoury-oai merged 2 commits into
mainfrom
fcoury/edit-replay-performance

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Dot-repeat, macros, counted edits, and visual-block replay were rebuilding frames and publishing document changes for individual replayed characters. A short repeat could therefore perform over a hundred full renders, while block insertion constructed thousands of hidden scratch frames.

Changes

  • Add nested edit batches that preserve synchronous text, marks, modes, and undo state while coalescing rendering and derived notifications. External actions flush first; plugin mode transitions remain ordered.
  • Give long replays bounded checkpoints and Ctrl-C cancellation, preserving queued input and undoable partial edits.
  • Send canonical UTF-16 edits to incremental LSP servers with exact-preimage checks and full-text fallbacks.
  • Reuse document-aware editor-window rendering, compact adjacent insert undo records, and batch safe ASCII runs in embedded text areas.
  • Add deterministic regressions, a real-PTY benchmark, a local LSP reconstruction fixture, and measurement/architecture documentation.

Results

Local release samples on macOS arm64, with 2,000 Rust lines and trace instrumentation:

Operation Before After
128-character dot-repeat 68.5 ms 7.2 ms
128-character macro 69.2 ms 6.3 ms
16-row block insertion 1,593 ms 91 ms

Dot renders and LSP notifications fell from 130/128 to 1/1. Full-sync repeat payload fell from 4.75 MB to 37 KB. These are diagnostic samples, not CI timing thresholds. See docs/performance-edit-replay-2026-08-17.md for the complete comparison and retained scope decisions.

How to Test

  1. Build with cargo build --locked --release -p red --bin red, then run python3 scripts/edit_replay_bench.py --binary target/release/red. All eight scenarios should save the exact expected text; short dot/macro replay should publish one final frame.
  2. Run the benchmark with --plugins --split --scenario dot --scenario block, then with --lsp incremental --unicode --crlf. Repeat with --lsp full --scenario dot --scenario undo. Shared views must agree, and the local LSP fixture must reconstruct the document exactly with increasing versions.
  3. In a disposable file, run :register a irepeat-me-repeat-me-repeat-me-<Esc>, then 5000@a and press Ctrl-C while it runs. Expect Normal mode and replay interrupted; u and Ctrl-r must undo and restore the partial insertion without damaging the original text.

Validated at 5050e50: 2,784 tests passed, one ignored; strict all-target/all-feature Clippy and format checks passed. The retained smoke also passed 42 before/after PTY cases and six manual checks, including shared splits and cancellation undo/redo. Protocol coverage uses a deterministic local server, not every production language server.

@fcoury-oai
fcoury-oai merged commit ac89827 into main Aug 17, 2026
11 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/edit-replay-performance branch August 17, 2026 20:23
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