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
desktop: live preview typing is over the 16 ms gate on the CI runner with per-line styles #193
Finding 30 in the review of #145 (Minor, #145 (review)) pointed out that the 16 ms typing budget had been measured only on one fast developer machine. It asked for a named reference machine and a measurement on it before Phase 7. The fix named the CI runner as that machine (docs/plans/0009-mygo-desktop.md:469-471). The closing review (#145 (review)) then asked for the runner's figure to be recorded at the gate. Plan 0009 still gives only the developer machine's figures.
Here are the runner's figures for BenchmarkTypingInALongNote/live, from the desktop job of ci.yml:
main at 2f540d4 (run 43024507355): 12.2 ms in live preview, 3.3 ms in source mode.
#188 reports 12.5 ms on the developer machine and closes #146. Part of #146's done-when is typing under 16 ms (make desktop-bench). The runs at the stack's current heads (265f641, 0be18a5) failed at the apt install, before the benchmark, so the current figure on the runner is not known.
Left to do:
Measure live preview's cost on the runner at the stack's current head.
What line styles added, per keystroke, from go test -cpuprofile:
+1.5 ms in livepreview.(*Scanner).Scan. Fixed in ac176f7. On every keystroke it ran three regular expressions on each of the 10,000 lines to find headings and done tasks (quoteRe, headingRe, taskRe), outside the scanner's per-line cache. A line's shape now comes from a cache keyed by its text. That also covers the three regular expressions main already ran per line to follow paragraphs.
About 0.9 ms in MyGo's (*view).settleLineStyles. It maps every style through each edit with LineOf and LineStart, which are linear scans of the rope. It runs on every edit, whether or not the app calls SetLineStyles, which already skips unchanged styles. This is in the fork (frostyard/next), not in this repository.
What's left is MyGo's per-keystroke work, which main pays too:
rope.LineStart for every replacement in SetReplacements (about 17% of samples);
(*view).measureWraps;
bracket matching (enclosingBrackets);
the highlighter.
The runner isn't one machine
The two runner figures above came from different CPUs:
main at 2f540d4 (run 43024507355) ran on an Intel Xeon 6973P-C: source mode 3.3 ms, live preview 12.2 ms.
Line styles barely touch source mode, so its 3.3 ms against 5.1 ms shows the EPYC runner itself is about 1.5× slower. On that machine, main itself would take about 18.8 ms, over the 16 ms gate.
Scaled from the local ratios, #188 at ac176f7 should be about 13.3 ms on the Xeon runner, under the gate, and about 20.5 ms on the EPYC one, over it.
Can it get under 16 ms within the stack?
On the Xeon runner it should. On the EPYC runner it can't: even main is over there, and the rest of the cost is MyGo's.
What would settle the gate, and which is for the owner to choose:
Measure relative to main in the same job, so the comparison is on the same CPU (for example, live preview no more than 10% over main). Or pin a runner class, or record the CPU next to each figure.
Cut MyGo's linear rope lookups per replacement and per style (SetReplacements, settleLineStyles) with an incremental line index. That's fork or upstream work, outside this stack.
The runner's figure at the stack's current heads (ac176f7, 5ff1f19, c4bc2d5) is still unknown. Their desktop jobs failed at apt-get, because azure.archive.ubuntu.com didn't resolve, before the benchmark ran. I'll re-run them when the mirror is back.
ac176f7 (each line's style is worked out once per text) is on main. The Native desktop app job's BenchmarkTypingInALongNote/live on commits of main that include it:
2 of these 5 runs are over 16 ms, and the figure depends on which CPU the runner gets. docs/plans/0009-mygo-desktop.md still records only the developer machine's figures.
Reopened: frostnotes#216 made live-preview typing faster, but the 16 ms gate still reads differently on different CI runner CPUs (12.9 to 20.8 ms on the same code). The gate policy for CI is still open, so this issue stays open until it is settled.
Activity
perf(desktop): work out each line's style once per text
bketelsen commentedon Nov 11, 2026
Profile of a live-preview keystroke with per-line styles
These are
BenchmarkTypingInALongNote/livefigures, 300 keystrokes per run, on a Ryzen AI MAX+ 395. The "2 cores" column is pinned withtaskset -c 0-1.main(MyGo v0.9.0, no line styles)265f641(line styles)ac176f7(this fix)What line styles added, per keystroke, from
go test -cpuprofile:livepreview.(*Scanner).Scan. Fixed inac176f7. On every keystroke it ran three regular expressions on each of the 10,000 lines to find headings and done tasks (quoteRe,headingRe,taskRe), outside the scanner's per-line cache. A line's shape now comes from a cache keyed by its text. That also covers the three regular expressionsmainalready ran per line to follow paragraphs.(*view).settleLineStyles. It maps every style through each edit withLineOfandLineStart, which are linear scans of the rope. It runs on every edit, whether or not the app callsSetLineStyles, which already skips unchanged styles. This is in the fork (frostyard/next), not in this repository.What's left is MyGo's per-keystroke work, which
mainpays too:rope.LineStartfor every replacement inSetReplacements(about 17% of samples);(*view).measureWraps;enclosingBrackets);The runner isn't one machine
The two runner figures above came from different CPUs:
mainat2f540d4(run 43024507355) ran on an Intel Xeon 6973P-C: source mode 3.3 ms, live preview 12.2 ms.2a7637f(run 43014898853) ran on an AMD EPYC 7763: source mode 5.1 ms, live preview 23.5 ms.Line styles barely touch source mode, so its 3.3 ms against 5.1 ms shows the EPYC runner itself is about 1.5× slower. On that machine,
mainitself would take about 18.8 ms, over the 16 ms gate.Scaled from the local ratios, #188 at
ac176f7should be about 13.3 ms on the Xeon runner, under the gate, and about 20.5 ms on the EPYC one, over it.Can it get under 16 ms within the stack?
On the Xeon runner it should. On the EPYC runner it can't: even
mainis over there, and the rest of the cost is MyGo's.What would settle the gate, and which is for the owner to choose:
mainin the same job, so the comparison is on the same CPU (for example, live preview no more than 10% overmain). Or pin a runner class, or record the CPU next to each figure.SetReplacements,settleLineStyles) with an incremental line index. That's fork or upstream work, outside this stack.The runner's figure at the stack's current heads (
ac176f7,5ff1f19,c4bc2d5) is still unknown. Their desktop jobs failed atapt-get, becauseazure.archive.ubuntu.comdidn't resolve, before the benchmark ran. I'll re-run them when the mirror is back.frostyard-machines commentedon Nov 12, 2026
Triage against
mainat b9c6c90: still valid.ac176f7 (each line's style is worked out once per text) is on main. The
Native desktop appjob'sBenchmarkTypingInALongNote/liveon commits of main that include it:2 of these 5 runs are over 16 ms, and the figure depends on which CPU the runner gets.
docs/plans/0009-mygo-desktop.mdstill records only the developer machine's figures.docs(plans): record the runner's typing figure at plan 0009's gate
perf(desktop): try each overlay pattern only on a line that can match it
docs(plans): record the runner's figures by CPU at plan 0009's gate
frostyard-machines commentedon Nov 12, 2026
Reopened: frostnotes#216 made live-preview typing faster, but the 16 ms gate still reads differently on different CI runner CPUs (12.9 to 20.8 ms on the same code). The gate policy for CI is still open, so this issue stays open until it is settled.