Skip to content

Preserve measured wraps for appearance-only highlighting - #463

Merged
simonbs merged 1 commit into
mainfrom
codex/preserve-highlight-wraps
Oct 27, 2026
Merged

simonbs merged 1 commit into
mainfrom
codex/preserve-highlight-wraps

Conversation

@simonbs

@simonbs simonbs commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Asynchronous highlighting previously repeated line-break searches for every measured character even when only colors changed. Compare final font runs after applying captures; when they match, retain wrap boundaries and geometry while rebuilding CoreText drawing lines and updating fragment-tree/cached renderers. Font changes still fully reflow. Complete styles, backgrounds, shadows, hidden whitespace, and partial-line continuation remain supported.

Based on main after #462 was squash-merged as 2f08c831270c505ef42b2e8371d41fd86cfae7d9; this PR contains stage 2 only. Only the stage 2 commit was replayed across the squash ancestry. The resulting files are identical to the previously verified head 853ffc5c96e406e06c5667cbc02ef015c5a7603c, so existing local validation remains applicable. Measurements used predecessor 23cd5eb4e24d68098f046cdf4a13f0e19b863aed; its later test-helper extraction changed no production behavior.

Measurements

On the same Release iPhone 17 Pro / iOS 27.2 simulator, eight measured trials on the local fixture's 58,901-byte longest line reduced median isolated completion redisplay from 40.135 ms to 3.996 ms for all 2,027 wrapped fragments, 1.248 ms to 0.575 ms for the visible prefix, and 1.855 ms to 0.672 ms unwrapped. This controlled benchmark excludes font classification and query/token costs.

Ordinary-scroll smoothness is not demonstrated. The equivalent real-highlighter scroll pair had mixed CPU results and worse callback-stall counts. Requests, offsets, and content dimensions matched. Load and unchanged initial typesetting also varied materially. Full phase, memory, methodology, and limitation details are in AppearanceHighlightingPerformance.md. Fixtures, instrumentation, logs, and recordings remain local.

Follow-up ordinary-scroll comparison

A serialized A–B–B–A Release comparison against #462 passed eight benchmark test executions. Median scroll-process CPU was 11.781 → 11.889 s unwrapped and 3.501 → 3.312 s wrapped. Callback intervals over 25 ms remained mixed (unwrapped A: 130/132, B: 153/131; wrapped A: 5/6, B: 17/6). All phase offsets/content dimensions and request counts matched. Two samples per revision establish neither general smoothness gains nor a systematic regression; the isolated long-line completion reduction remains this PR’s demonstrated benefit. These are instrumented Simulator run-loop measurements, not physical-device compositor hitches.

Validation

  • Final uninstrumented Release run: 62 focused tests passed, including fresh rendering/geometry comparisons, navigation, Unicode/bidi/tabs, partial continuation, font reflow, editing/undo, and marked-text composition. Earlier passing complete-style, embedded-language/stale-request, background-overlay, and existing composition checks were reused.
  • Release Example build, changed production SwiftLint, and whitespace checks pass. Existing dependency/example build warnings remain.
  • Wrapped/unwrapped slow drags, flings, reversals, and horizontal gestures captured locally. Spread frames and 6-fps motion windows showed no blank viewport, missing band, or obvious unintended jump. Newly exposed lines can briefly await async coloring; settled pixels are checked against fresh rendering.

Physical-device performance and compositor hitch traces remain unverified. The composition oracle synchronously settles final state; its main-queue barrier does not prove all background requests completed. Primary checkout and phone app were untouched. No range chunking or cache eviction.

@simonbs
simonbs force-pushed the codex/preserve-highlight-wraps branch from 4f76cb5 to 853ffc5 Compare October 27, 2026 12:39
Base automatically changed from codex/reuse-highlight-requests to main October 27, 2026 12:50
@simonbs
simonbs force-pushed the codex/preserve-highlight-wraps branch from 853ffc5 to 56cf114 Compare October 27, 2026 12:51
@simonbs
simonbs merged commit 978b808 into main Oct 27, 2026
9 checks passed
@simonbs
simonbs deleted the codex/preserve-highlight-wraps branch October 27, 2026 13:05
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