Repository navigation
Reuse in-flight line highlighting and stop canceled queries - #462
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated line preparation could cancel and restart equivalent highlighting, while canceled Tree-sitter queries continued collecting matches. Keep one pending request for unchanged line input, cancel it on invalidation/removal/offscreen transitions, and reject obsolete operation/input identities before applying styles鈥攊ncluding after client theme callbacks.
Background captures now own copied trees and share frozen predicate text per generation, so editing cannot mutate their inputs. Query iteration cooperatively stops between matches/captures. Synchronous destination preparation still applies styles before measurement; it now also refreshes visible fragments when revealing an already-visible destination leaves the scroll offset unchanged. The fresh-editor rendering oracle reproduced that redraw bug on the predecessor before verifying the fix.
Evidence
Compared Release builds against
df9b56fd94131c0f60477613dda8f29e7f0aabe7on the same dedicated iPhone 17 Pro / iOS 27.2 simulator. For five synthetic cancellation trials, median remaining worker time after canceling an executing dense 60 KB JSON query fell from 40.326 ms to 0.141 ms; the 600 KB stress case fell from 670.783 ms to 0.072 ms. Whole-process CPU measurements showed the same bounded benefit.No steady-scroll speedup is demonstrated. Two ordinary-scroll runs per version separated loading, first traversal, reversals, cached revisits, and horizontal scrolling. Sampled steady traversal canceled no requests in either version; initial unwrapped layout starts/cancellations fell from 32/16 to 17/1. Callback stalls and CPU varied. Frozen predicate text adds a document-sized UTF-16 snapshot (about 50 MiB for this local fixture). Full measurements, methodology, and limits are in HighlightingPerformance.md.
Validation
Physical-device performance, compositor hitch traces, and long wrapped-line marked-text composition during pending work remain unverified. Display-link delays are main-run-loop stall proxies, not compositor frame guarantees. No phone app or primary checkout sources were changed. Stage 1 only; no appearance-only rewrapping, chunked highlighting, or memory eviction.