Skip to content

Reduce large-document typing and unwrapped scrolling work - #482

Merged
simonbs merged 6 commits into
mainfrom
codex/ipad-scroll-edit-performance
Nov 2, 2026
Merged

simonbs merged 6 commits into
mainfrom
codex/ipad-scroll-edit-performance

Conversation

@simonbs

@simonbs simonbs commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

A 25 MiB short-line JSON fixture took about 234 ms per middle-document character insertion on a USB-connected iPad Pro (12.9-inch, 3rd generation), iPadOS 26.6. The final candidate reduces that median to 117 ms. Unwrapped long-line fast-scroll work falls from 16.01 to 5.61 ms median and from 30.78 to 9.43 ms p95.

Measured operation Main baseline Final candidate
Short-line JSON character insertion 234.19 ms 117.31 ms
Unwrapped long-line fast-scroll work, median 16.01 ms 5.61 ms
Unwrapped long-line fast-scroll work, p95 30.78 ms 9.43 ms
Short-line JSON line break 236.09 ms 236.01 ms
Short-line JSON join 249.68 ms 247.41 ms

The paired Release runs use the same two performance cases/order, 390×700-point viewport, disabled spelling/autocorrection, no coverage, serial execution, and an app host isolated from session restoration. Edit figures are five synchronous API samples; scroll-work figures are 90 callbacks. These are not keyboard-latency or compositor frame-rate measurements.

Changes:

  • Add a bounded structural-equality preflight over the pinned Tree-sitter internals. It returns no changed ranges only when structure, alias context, coordinates, language and included ranges match; uncertain/recovery/external-scanner cases retain the stock comparator. The submodule is unchanged. Dependency updates must rebuild this helper and rerun the differential tests.
  • Derive horizontal visible spelling ranges only when requested, using immutable fragments and coordinates from the completed layout. Replace snapshots/invalidate results every layout and clear at zero viewport. Preserve native bidi mapping and renderer geometry. Also skip language discovery when spelling is disabled.
  • Release canceled highlight snapshot ownership without waiting for main-queue delivery. Keep active query/token application snapshots alive, reject stale/reentrant results, and deliver cancellation callbacks even before execution. Dispose at most one canceled payload on a private background executor; busy callers release synchronously, preventing an unbounded document-retention queue.
  • Use set membership to reconcile injected language regions and free the NSString byte buffer after conversion failure.
  • Add opt-in device-screen geometry for existing large-file checks, preserving their original default dimensions.

Validation:

  • Final implementation: 14 focused lifetime/cancellation/bounds/performance checks, all 8 large-file glyph/geometry/pixel oracles plus 4 distributed traversal cases, and 2 full-screen 1366×1024-point rendering oracles passed on the physical iPad.
  • An 88-check spelling/folding/Unicode/prefix/native-layout regression run passed before the final disposal executor change; relevant async and rendering behavior was rechecked above.
  • 900 deterministic mutations compare exact accelerated byte/point ranges with stock Tree-sitter. Scoped strict SwiftLint and whitespace checks passed.
  • Initial/intermediate combined runs lost the host with SIGKILL in the short-line unwrapped oracle; isolated retries and final combined suites passed. No crash/Jetsam report establishes the original kill cause.

Structural JSON edits still take roughly 235–247 ms: parsing and the stock structural comparison remain bottlenecks. Physical touch/keyboard XCUITests are unverified because their runner has no provisioning profile and Xcode has no signed-in account to create one. App-side preview deferral and benchmark-host isolation are committed separately in the app repository; its canonical framework pin is unchanged. CI build/test (Xcode 16.4 and 26.2), example build, SwiftLint and documentation passed. CodeQL is still running; this PR is not merged.

@simonbs simonbs changed the title Reduce large-document typing latency and redundant editor work Reduce large-document typing and unwrapped scrolling work Nov 2, 2026
@simonbs
simonbs marked this pull request as ready for review November 2, 2026 19:29
@simonbs
simonbs merged commit 40b2a8e into main Nov 2, 2026
9 checks passed
@simonbs
simonbs deleted the codex/ipad-scroll-edit-performance branch November 2, 2026 20:19
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