Skip to content

Qt: enable QTextLayout.setCacheEnabled(True) on bold wave layouts and share QtWaveBandCache - #2322

Merged
trissim merged 1 commit into
mainfrom
perf/qt-name-wave-layout-cache
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/qt-name-wave-layout-cache

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown

Summary

Cut waving sidebar and tab-bar paint time by enabling glyph-engine caching on Toad's only two QTextLayout allocations and eliminating per-tick FormatRange allocations on the tab bar:

  1. Glyph caching on both QTextLayouts (src/toad/qt/name_wave.py):
    • QtNameWaveDelegate.bold_titled (:94) and QtSessionTabBar.bold_line (:465) are the only two QTextLayout constructions in src/toad/qt/, and neither called setCacheEnabled(True) (unlike pyqt_reactive's StyledTextRenderer.prepare).
    • Calling setCacheEnabled(True) before beginLayout() cuts 3,000 waving QTextLayout.draw(..., inks) paints from 63.1 ms -> 36.1 ms / 61.8 ms -> 37.2 ms (1.7x faster, unprofiled warm alternating A/B), and cuts full QtNameWaveDelegate.paint() by ~24%.
  2. Shared QtWaveBandCache(BandCells) (src/toad/qt/name_wave.py):
    • Hoisted accent, accent_format, bounded inks cache, _init_wave_ink, _set_wave_accent, and cached_band_inks into QtWaveBandCache(BandCells) inherited by both QtNameWaveDelegate and QtSessionTabBar (deleting the duplicated accent_format setup and eliminating per-tick QTextLayout.FormatRange allocation in QtSessionTabBar.paintEvent).

Verification

  • Focused pytest (tests/textual/test_name_wave_repaint.py, tests/model/test_android_perf_ux_arrivals.py): 37 passed in 0.67s (including assertions on cacheEnabled() is True for both bold_titled and bold_line, shared cached_band_inks reuse, and set_colours invalidation).
  • tools/qt_inherit_ratchet.py: 0 / 0 / 0 / 0 / 0.
  • tools/shadow_check.py: 0.
  • tools/guarded_imports.py: 0.
  • REL_IMPORTS=0.

@trissim
trissim merged commit 33f983b into main Nov 27, 2026
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