Skip to content

Perf(qt): LRU-cache QtStickyHeader docs/pixmaps and skip occluded opaque strips in scrollContentsBy - #2336

Merged
trissim merged 1 commit into
mainfrom
perf/qt-scroll-sticky-lru-opaque-clip
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/qt-scroll-sticky-lru-opaque-clip

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown

Numbers

  • Live #comms 412x915 FrameProbe 5s fling: QtStickyHeader.draw_pinned stack share 1.6% -> 0.3% (5.3x reduction), LayoutRequest/QtHistoryWindow 44x -> 0x, worst_stall_ms 9.0 ms -> 7.7 ms.
  • 4-round alternating unprofiled A/B benchmark (240 scroll steps across 20 headers at 412x915):
    • origin/main: 59.707, 61.957, 60.239, 58.710 ms (median 59.973 ms, 239 QTextDocument builds)
    • this PR: 30.391, 34.248, 34.601, 35.177 ms (median 34.425 ms, 20 QTextDocument builds — 1.74x wall-clock speedup, 11.95x fewer document layouts)

Mechanism

  1. QtStickyHeader bounded LRUs + no-op geometry guard (src/toad/qt/history.py):
    • draw_pinned() previously replaced self.laid_out with only the current header and wiped self._pixmap_cache = None on every message-boundary crossing, rebuilding QTextDocument + setHtml + layout + raster QImage on every switch and calling resize()/move()/raise_() unconditionally (44 LayoutRequest/QtHistoryWindow events in 5s).
    • Now retains recently pinned QTextDocuments (OrderedDict, cap 32) and rasterized QImages (OrderedDict, cap 16) while layout_context is unchanged, and skips no-op resize/move/raise_.
  2. VirtualRowCanvas.scrollContentsBy opaque-cover exclusion (src/toad/qt/virtual_scroll.py):
    • Split floating_covers() into (covers, opaque) using WA_OpaquePaintEvent and subtract opaque rects from viewport.update(dirty) (skipping viewport.update altogether when empty) so occluded pixels under opaque floating siblings like QtStickyHeader are never invalidated on scroll.

Verification

  • tests/model/test_android_perf_ux_arrivals.py: 42/42 passed in 0.70s (including new test covering QtStickyHeader LRU hits, no-op resize/move guards, and VirtualRowCanvas.scrollContentsBy opaque vs translucent cover clipping).
  • REL_IMPORTS=0, qt_inherit_ratchet 0/0/0/0/0, shadow_check 0, guarded_imports 0.

@trissim
trissim merged commit 1b2b71c into main Nov 27, 2026
1 of 2 checks passed
@trissim
trissim deleted the perf/qt-scroll-sticky-lru-opaque-clip branch November 27, 2026 21:08
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