Skip to content

perf(editor): reduce redraw work during cursor navigation - #436

Merged
fcoury-oai merged 1 commit into
mainfrom
perf/drawing-navigation
Nov 4, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
perf/drawing-navigation

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Moving the cursor one line could rebuild indentation guides for the whole viewport and copy rows that Red had already saved in its last frame. Both costs showed up even when the cursor stayed in the same indentation scope.

This change reuses the guides until the scope, viewport or document changes. Cursor redraws compare affected rows against the last flushed frame, with the full redraw path handling invalidation and resize. It also fixes a Windows startup issue where the terminal's reply to a graphics capability query could arrive as keystrokes.

The new PTY/ConPTY replay sends real navigation commands, waits for each expected cursor position on the statusline, and checks the saved documents. The CI matrix covers cursor movement, scrolling, direction changes, and window and buffer switching on all three operating systems. For profiling, RED_PERF=bounded records fixed-size histograms, and short traces correlate input dispatch with successful flushes.

Measurements

In the final seven-pair macOS run, median in-viewport latency fell from 1.76 to 0.98 ms. The p95 moved from 3.79 to 3.73 ms and varied with host load. Linux in-viewport p95 fell from 1.82 to 1.15 ms, and scrolling p95 fell from 2.47 to 2.20 ms. Window and buffer switching showed no consistent speedup. Windows passed the interactive navigation and save checks. A full Windows timing comparison is still open. Measurement report

How to Test

  1. Run cargo run --locked --release -- src/editor.rs. Move with j and k between lines of equal indentation, then into and back out of a nested block. The active guide should stay aligned within the first scope and move to the correct column at each boundary.
  2. Scroll past the bottom of the viewport, resize the terminal, and reverse direction. Check the cursor, guides and statusline for stale cells. Open :vsplit Cargo.toml and use Ctrl-w w to return to the source file. Its cursor should return to the original line.
  3. For an automated check, run cargo test --locked --release --lib editor::navigation_perf_tests::. To reproduce the timed runs, follow the native replay runbook.

Local validation used the temporary dependency mirror. All 2,913 enabled library tests passed, and the 30-minute macOS soak verified the final document after 72,000 navigation inputs.

@fcoury

fcoury commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T17:29:31.283733Z d706195 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: d7061955d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcoury-oai
fcoury-oai merged commit 4906e4f into main Nov 4, 2026
15 of 17 checks passed
@fcoury-oai
fcoury-oai deleted the perf/drawing-navigation branch November 4, 2026 17:58
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.

2 participants