You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(editor): emphasis layers and find search left from #4428 #4436
Follow-up to #4428 (perf audit, editor lane). Items left out of that PR:
E6b, layers only for laid-out emphases. Find on a 5000-line script costs 76 ms of main CPU per find-field character; the regex is about 4 ms of it, the rest is one emphasis layer per match (18,569 layers for t). At 10 MB it is 713 ms a character. The gate needs a footprint row after the find term, which the harness does not record yet. Touches the one manager under brackets, snippet fields, diagnostics and find.
E6a, find search off the main thread. Do it after E6b: alone it does not make the field responsive (regex 86 to 111 ms of the 713 ms at 10 MB).
Not an issue any more: the 67 M instructions per key below 500,000 characters (12e). type-490k 110 M, type-510k 131 M, type-10k 87 M.
Numbers and harness: perf audit run dir results/editor/, plan entry E6 in plan/editor.md.
Two more costs for E6a and E6b, found in the performance plan's editor review:
While the panel is shown, every editor keystroke runs findAfterEdit, which copies the document and searches all of it again (FindPanelViewModel.swift:106-108, FindPanelViewModel+Find.swift:41-47).
layoutDidUpdate and markNeedsGeometryUpdate walk every emphasis layer (EmphasisManager.swift:247-268). A match that is not laid out stays pending, so every later layout pass, each scroll frame included, walks all of them while matches are shown.
For the change:
Keep matches as a sorted range array and shift them on an edit; re-search only the edited lines in literal and whole-word modes, and off main for a regular expression.
Keep match emphases out of the per-layout walk, for example in an interval index queried by the laid-out range.
Measure editor keystroke median and p95 in a 1.9M-character file with the panel open and a common term entered.
Activity
datlechin commentedon Nov 24, 2026
Quiet pass 2: E3b FAIL, drop. type-10mb is 140.8 M instructions a key, under TablePlus's 291 M (load not quiet, but the margin is 2x).
datlechin commentedon Nov 25, 2026
Two more costs for E6a and E6b, found in the performance plan's editor review:
findAfterEdit, which copies the document and searches all of it again (FindPanelViewModel.swift:106-108,FindPanelViewModel+Find.swift:41-47).layoutDidUpdateandmarkNeedsGeometryUpdatewalk every emphasis layer (EmphasisManager.swift:247-268). A match that is not laid out stays pending, so every later layout pass, each scroll frame included, walks all of them while matches are shown.For the change: