Repository navigation
Performance improvements: ASCII width fast paths, viewport-scoped highlights, span scans - #308
Merged
Merged
Conversation
…hlights, span scans Per-keystroke render cost for large documents, measured with the existing SteadyState/PerKeystroke benchmarks (main -> this commit): Type (insert/delete + render) @1000 lines: 13,561us -> 1,965us (6.9x) @100 lines: 1,839us -> 849us (2.2x) Navigate (caret move + render) @1000 lines: 844us -> 636us (1.3x) WordWrap @1000 lines: 7,446us -> 327us (22.8x) Changes: - UnicodeWidth.GetWidth(char): memoize widths for the ASCII range. Word wrap calls this per character per keystroke, and the Wcwidth lookup behind it costs a HashSet probe plus two dictionary lookups (~70ns/char). - UnicodeWidth.GetWidth(span) / GetLengthThatFits: skip runs of printable ASCII with a vectorized IndexOfAnyExceptInRange instead of walking them cluster by cluster. The run's last char is handed back to the UAX-29 walker when the run ends inside the text, since a following combining mark / ZWJ / VS16 clusters onto it. - CellRenderer: build the highlight lookup only from spans starting in the visible lines. Previously every span in the document was hashed on every render (~36% of a caret-move keystroke at 1000 lines). - Document: line/word boundary scans read the cached text as a span instead of the StringBuilder indexer, which is O(chunks) per access. - UnicodeWidthTests: differential tests pinning both fast paths to a walker-only reference over pairwise combinations of hazard strings (combining marks, ZWJ, VS16, CR LF, control chars), across every width budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
=====================================
Coverage 86.6% 86.7%
=====================================
Files 48 48
Lines 4131 4165 +34
Branches 685 691 +6
=====================================
+ Hits 3581 3614 +33
- Misses 383 386 +3
+ Partials 167 165 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Per-keystroke render cost for large documents, measured with the existing SteadyState/PerKeystroke benchmarks (main -> this commit):
Changes:
UnicodeWidth.GetWidth(char): memoize widths for the ASCII range. Word wrap calls this per character per keystroke, and the Wcwidth lookup behind it costs a HashSet probe plus two dictionary lookups (~70ns/char).
UnicodeWidth.GetWidth(span) / GetLengthThatFits: skip runs of printable ASCII with a vectorized IndexOfAnyExceptInRange instead of walking them cluster by cluster. The run's last char is handed back to the UAX-29 walker when the run ends inside the text, since a following combining mark / ZWJ / VS16 clusters onto it.
CellRenderer: build the highlight lookup only from spans starting in the visible lines. Previously every span in the document was hashed on every render (~36% of a caret-move keystroke at 1000 lines).
Document: line/word boundary scans read the cached text as a span instead of the StringBuilder indexer, which is O(chunks) per access.
UnicodeWidthTests: differential tests pinning both fast paths to a walker-only reference over pairwise combinations of hazard strings (combining marks, ZWJ, VS16, CR LF, control chars), across every width budget.