Skip to content

desktop: live preview typing is over the 16 ms gate on the CI runner with per-line styles #193

Closed

Description

@bketelsen

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:

#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:

Where: internal/desktop/editor/live.go (the line styles), internal/desktop/editor/typing_bench_test.go, docs/plans/0009-mygo-desktop.md.

Severity: Minor (finding 30 of the review of #145).

Activity

  1. added
    bug
    on Nov 11, 2026
  2. bketelsen commented on Nov 11, 2026

    @bketelsen
    ContributorAuthor

    Profile of a live-preview keystroke with per-line styles

    These are BenchmarkTypingInALongNote/live figures, 300 keystrokes per run, on a Ryzen AI MAX+ 395. The "2 cores" column is pinned with taskset -c 0-1.

    all cores 2 cores allocs/op
    main (MyGo v0.9.0, no line styles) 8.75 ms 9.0 ms 10,134
    #188 at 265f641 (line styles) 11.4 ms 12.0 ms 12,916
    #188 at ac176f7 (this fix) 10.1 ms 9.9 ms 9,951

    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:

    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.

  3. frostyard-machines commented on Nov 12, 2026

    @frostyard-machines
    Contributor

    Triage against main at b9c6c90: still valid.

    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:

    commit run runner CPU live
    3d84a45 43127310696 Xeon 8370C 20.77 ms
    22c0655 43131798511 EPYC 9V74 15.40 ms
    e817b05 43139223248 EPYC 7763 20.48 ms
    1c6ac8e 43145932676 EPYC 9V45 13.28 ms
    b9c6c90 43147531919 EPYC 9V45 12.91 ms

    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.

  4. added 3 commits that reference this issue on Nov 12, 2026
    1898fdd
    c58b98c
    ee4f533
  5. frostyard-machines commented on Nov 12, 2026

    @frostyard-machines
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions