Skip to content

perf(gui): cut per-frame allocs in scrollbars, Text a11y and showcase catalog - #992

Merged
mike-ward merged 2 commits into
mainfrom
perf/scrollbar-text-a11y-allocs
Oct 11, 2026
Merged

mike-ward merged 2 commits into
mainfrom
perf/scrollbar-text-a11y-allocs

Conversation

@mike-ward

Copy link
Copy Markdown
Collaborator

Summary

Three allocation cuts, found by profiling real frames.

  • Stock scrollbars: 7 allocs per bar per frame → 1. Every scrollable container builds two bars every frame, even when nothing overflows. A bar was a Row/Column with a thumb child and four closures, each holding its own copy of ScrollbarCfg. Now scrollbarView builds both shapes directly, and its handlers are shared funcs that read the settings through a new eventHandlers.scrollbar field. Every scrolling widget saves 12 allocs per frame (Combobox open 30→18, CommandPalette 42→30, ListBox virtualized 107→95, VirtualList 70→58). Bars with a Thumb/Track hook are unchanged. eventHandlers moved to gui/shape_events.go unchanged, because shape.go sat at the 800-line gate.
  • Text a11y: 1 fewer alloc per Text per frame. accessInfo lives on the textView, as tc and anim already do. a11yInfoProse is removed.
  • Showcase catalog → VirtualList. Only the visible rows are built: about 240 fewer allocs (−33%) and about 30% less frame time on every showcase page.

Tests

  • TestScrollbarStockAllocs (failed with 7 before the change) and TestTextA11YInfoNoAlloc.
  • TestScrollbarStockBehaviour: thumb placement, hover, drag and gutter press. It passes before and after.
  • New goldens scroll_column and scroll_column_hover, recorded on the old code; the new code matches them byte for byte.
  • TestCatalogBuildsOnlyVisibleRows (failed with 78/78 before) and TestCatalogRowClickSelects.
  • make prepush is green.

🤖 Generated with Claude Code

… catalog

- Stock scrollbar is one scrollbarView that builds its bar and thumb
  shapes directly; its handlers are shared funcs reading the settings
  through eventHandlers.scrollbar. 7 allocs per bar per frame -> 1, so
  every scrollable container saves 12. Hook (Thumb/Track) bars unchanged.
  eventHandlers moved to shape_events.go to keep shape.go under the
  800-line gate.
- Text keeps its accessInfo on the textView, as it does tc and anim:
  one fewer alloc per Text per frame. a11yInfoProse removed.
- Showcase catalog sidebar is a VirtualList: only visible rows are
  built (about 240 fewer allocs per frame on every page).

Tests: alloc tests for the scrollbar and Text, stock-scrollbar behaviour
test, scroll_column goldens recorded on the old code and matching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mike-ward mike-ward mentioned this pull request Oct 10, 2026
2 tasks done
@mike-ward
mike-ward merged commit 7c78b5f into main Oct 11, 2026
56 of 57 checks passed
@mike-ward
mike-ward deleted the perf/scrollbar-text-a11y-allocs branch October 11, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant