Skip to content

perf: remove repeated segmentation and quadratic composer navigation - #508

Open
raiseCatError wants to merge 1 commit into
devfrom
perf/20261025-input-layout
Open

raiseCatError wants to merge 1 commit into
devfrom
perf/20261025-input-layout

Conversation

@raiseCatError

@raiseCatError raiseCatError commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Long-command editing repeatedly constructs native grapheme segmenters and recalculates prompt width for each glyph. Visual-row movement additionally recalculates the full layout for every possible token boundary, producing a ~3-second arrow-key stall in the saved workload.

Reuse a lazily created segmenter, calculate prompt width once per row, and capture all caret positions in one pass through the shared wrapping implementation. Navigation retains token boundaries, paste-label mapping, earliest-token ties and clamping when clusters join across separately typed tokens. Temporary caret storage is linear; no input cache, dependency or worker is added.

Measured on M2 / 8 GiB / macOS 27 / Node 26.12, against unchanged dev:

  • One visual-row moveUp in a long Unicode command: median 3,041.94 → 2.12 ms.
  • 30 long-command edit/layout/highlight steps: median 201.97 → 46.75 ms.
  • Built-frontend long-command typing-update p95: 45.86 → 8.78 ms; deletion-update p95: 13.06 → 7.01 ms (seven warm disposable sessions, 105 observations each). PTY observations, not physical key-to-pixel latency.
  • None-prefix long-layout component median regressed 3.4% in this small sequential sample; no gain claimed there. No application idle/startup-memory gain claimed. Raw per-stage samples and conditions are in docs/performance/2026-10-25-input.md.

Deterministic resource/scaling regressions were observed failing before implementation, then passing. Compatibility tests enumerate token positions across Unicode, split combining clusters, wrapped paste labels, narrow widths and styled/empty prefixes. Independent read-only review approved with no concrete blocker. Focused input tests and build pass; full canonical npm run verify passed with explicit xterm-256color/truecolor capabilities, NO_COLOR unset, two workers and private short T7 fixtures. No test assertions/deadlines weakened.

Physical Ghostty/Zed QA: NOT RUN. Check long Unicode typing/deletion, wrapped/multiline vertical movement and selection, resized/styled/None prompts, multiple paste atoms and unwrap, Shift+Enter/Ctrl+J and Option+Backspace. Known intermittent macOS read issue is not claimed fixed. Keep the issue open pending hands-on validation.

Refs #507

Targets dev; do not merge automatically. Independent of output-rendering PR #506.

Exact-head CI: 10250f541f613153de10945aa11d3435cd92c2f4 passed macOS/Ubuntu shards, Quality and Node 22 compatibility; aggregate CI green. Fedora/timing jobs skipped by workflow conditions. CI run. PR remains unmerged.

Environment clarification: t7run supplies NODE_COMPILE_CACHE=/Volumes/T7Tmp/ai-dev/caches/node-compile; the original before/after runs inherited it. No OS-cache purge or true cold-start claim. Separate cache-disabled/private-cache startup controls are being retained in the local evidence.

This branch has not been deployed

No deployments
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