Skip to content

Desktop: performance audit of November 2026, baseline and work packages - #477

Open
MopigamesYT wants to merge 24 commits into
devfrom
perf/audit
Open

MopigamesYT wants to merge 24 commits into
devfrom
perf/audit

Conversation

@MopigamesYT

Copy link
Copy Markdown
Member

Part of #473
Part of #474
Part of #475
Part of #476

Summary

Phase 1 of the desktop optimisation round, measuring and planning only (no fixes). The baseline was measured on the test VM with a 200-chat state and a 4,000-row chat, on llvmpipe and on virgl, including the theme system (palette changes, shader backgrounds, and blur from #472 measured on its branch). docs/perf/2026-11-audit.md has the numbers, the flame-graph findings, 16 ranked hotspots, and four independent work packages, one issue each:

Screenshots

No visible change.

Technical details

  • internal/ui/bench.go: new ONELOOP_BENCH modes idleblur, stream, type, sidebar, split, files, theme, startup, soak. ONELOOP_BENCH_SECONDS sets the span, and ONELOOP_BENCH_PROFILE=<dir> writes CPU, heap and allocs profiles plus goroutines. Reports add whole-frame percentiles, allocations and KB per frame, heap/RSS/goroutines/GC at launch, before and after the span, and the launch milestones.
  • internal/ui/desktop.go: benchMark() milestones along runDesktop. They do nothing unless ONELOOP_BENCH is set.
  • internal/ui/perf_bench_test.go: headless BenchmarkPerf* on Fyne's test driver: chat open (first/cached, 500/4,000 rows), one transcript layout, a scroll step, a streamed delta, a markdown parse, renderChats with 200 chats, themeChanged.
  • scripts/perf/genstate: synthetic state (chats, subchats, projects, pictures, and an optional theme from docs/themes). scripts/perf/run.sh runs the modes on fresh copies of it and keeps reports, gctrace, the developer log and profiles.
  • The VM (Proxmox 111) was switched to virtio-gl for the GPU runs, then set back to virtio and shut down.
  • Checks: gofmt, go build ./..., go vet ./internal/ui ./scripts/..., go test ./internal/ui.

Assisted-by: Claude Opus 5.5 low

🤖 Generated with Claude Code

…tate (#473)

Headless benchmarks of the hot paths (perf_bench_test.go), new
ONELOOP_BENCH modes (stream, type, sidebar, split, files, theme, startup,
soak) with memory, allocations per frame, launch milestones and pprof
output, a synthetic state generator and a runner for the test VM.

Assisted-by: Claude Opus 5.5 low
@MopigamesYT MopigamesYT added enhancement New feature or request desktop Desktop app (Linux, Windows) labels Nov 16, 2026
canvas.Image keeps one decoded SVG per (resource, colour) instead of
colourising and parsing the XML at every Refresh; the sidebar keeps its
project and chat rows between renderings and refreshes only those that
changed; the ⋯ inset is a constant instead of a row built per row.
BenchmarkPerfRenderChats: 19.5 ms, 5.1 MB, 73.9k allocs -> 2.5 ms,
1.05 MB, 18.1k allocs on the same machine.

Assisted-by: Claude Opus 5.5 low
The XDG portal answers at launch with the variant already in use, and
Fyne then re-themed every window (~180 ms on the UI thread, llvmpipe).
The variant is applied only when it changes, and a variant-only change
no longer re-themes the windows: 1loop sets a new theme when its own
follows the system.

Assisted-by: Claude Opus 5.5 low
…475)

The ring (512 px, decoded, inked, resampled) is drawn once per ink and
size, off the UI thread, and shared by the marks. The phone remote, the
linked servers, the update check and the other windows of the last run
start 100 ms after the window shows, behind the first frame.

Assisted-by: Claude Opus 5.5 low
…aches freed off screen (#473)

Assisted-by: Claude Opus 5.5 low
… linear open (#473)

Visible rows already measured at the current width are no longer
re-measured each frame. Adds transcript layout tests.

Assisted-by: Claude Opus 5.5 low
The caret blink and the frame hook kept the window repainting at 8 fps
forever with the composer focused. The caret now blinks without a full
window refresh and stops after inactivity; the frame hook is no longer a
never-ending fyne.Animation. Patches the vendored Fyne (third_party/fyne:
widget cursor animation, common canvas, driver refresh counter).

Assisted-by: Claude Opus 5.5 low
Fyne cleared the measured text sizes with the icons on every theme
change, and ThemeOverride reset every cache once per widget under it
(thousands for the transcript). A new ResetThemeColourCaches drops the
themed icons only, once per override apply. The theme folder is
watched with fsnotify instead of polled (go.mod: fsnotify now direct).

Assisted-by: Claude Opus 5.5 low
…inux (#476)

Fyne's Noto Sans and DejaVu fonts are stored gzipped and unpacked on first
use. On Linux the 4.2 MB EmojiOneColor font is no longer bundled: emoji use
the system's colour emoji font, loaded the first time one is drawn. Windows
keeps the bundled font, which its own emoji font cannot replace.
Release binary: 47.2 MB to 41.9 MB.

Assisted-by: Claude Opus 5.5 low
Every style and every theme reset parsed the same font files again; the
audit measured 17.7 MB of duplicate parsed faces.

Assisted-by: Claude Opus 5.5 low
GOGC 50: a collection when the heap grows by half rather than doubles.
GOGC in the environment still wins. No memory limit: one below the live
heap (a 40,000-row chat open) made the collector run back to back on the
test VM and the window crawl.

Assisted-by: Claude Opus 5.5 low
…utine (#476)

Under Fyne's test driver, fyne.Do ran its function on the calling goroutine,
so work handed to the UI from timers and goroutines ran alongside the test:
600 to 1,100 data races per race-detector run. Work from other goroutines now
waits in a queue that the test goroutine runs (fyne.Do, DoAndWait, Drain, a
new app). Only DoAndWait from another goroutine gets a helper that runs the
queue after 20 ms, so it cannot deadlock.

Assisted-by: Claude Opus 5.5 low
Each save, 400 ms after a change, encoded every chat into one buffer the size
of the state file (97 MB on a real install), grown by doubling, then wrote it:
a few hundred MB of garbage per save while agents stream, which drove a
running 1loop past 1.4 GB of RSS. The chats are now encoded and written one
at a time through a buffered file; the file is the same, byte for byte.

Assisted-by: Claude Opus 5.5 low
MopigamesYT and others added 8 commits November 17, 2026 11:08
Desktop: faster startup and a sidebar that reuses its rows (#475)
Conflict in glfw/loop.go settings listener: kept both the VariantOnly early return and the KeepFonts cache reset.
No textual conflict; fixed the ring tests that waited on a fyne.Do now queued by the #476 test driver (added test.Drain).
Desktop: memory and binary size, race-free UI tests (#476)
Desktop: long chats: transcript layout, streamed markdown, scroll bench (#473)
Desktop: nothing redraws when idle, cheaper theme changes (#474)
@MopigamesYT

Copy link
Copy Markdown
Member Author

Found while testing on the linux-test VM (Plasma Wayland, 1280×800). I merged this PR alone onto dev 8089b0a and compared it with dev, on the same profile and the same screens.

1. Every outline is bright. The settings search field, the outlined buttons (New theme / Duplicate / Open folder, Later), the #rrggbb field and the cards are drawn with bright light-grey borders, where dev has subtle dark ones (Settings → General → Appearance shows it best). It comes with this PR into #498 and #501. I didn't find the line responsible: the theming change (repaint(changed, fontsChanged) with fynedriver.KeepFonts) and the vendored Fyne font/painter changes are the first places I'd look.

2. The composer and the sidebar footer move 14 px down. On dev the composer's top edge is at y=639 and the window's last 14 px are empty. With this PR it's at y=653, and the bottom of the window holds content. The first window (1180×760) is taller than the screen's work area (746 px above Plasma's panel), so the bottom of Settings in the sidebar, the composer's edge and the last line of the Tasks view's context overview are now under the panel. The window size itself is #512 (dev too); this PR is what makes it visible.

3. It clashes with #496. This PR changes repaint(changed recolour) to repaint(changed recolour, fontsChanged bool), while #496 adds internal/ui/theme_switch_colours_test.go:36, which calls repaint with one argument. Whichever merges second breaks go vet ./internal/ui and the UI tests: not enough arguments in call to repaint.

This branch has not been deployed

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

Labels

desktop Desktop app (Linux, Windows) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants