Skip to content

Bake name-wave accent bands into cached QTextLayouts (1.92x sidebar / 1.33x tab-bar wave speedup) - #2328

Merged
trissim merged 1 commit into
mainfrom
perf/bake-wave-band-qtextlayout
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/bake-wave-band-qtextlayout

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown

Summary

  • Passing dynamic selections (FormatRange lists) into QTextLayout.draw(painter, origin, inks) on every 60–120 Hz name-wave frame forced Qt C++ onto its slow selection-splitting draw path (69.79 ms vs 29.05 ms for 5,000 draws — 2.4x slower).
  • Replaced QtWaveBandCache.inks / cached_band_inks with QtWaveBandCache.clone_layout + baked_band_layout(base, span) (bounded to BANDED_KEPT = 512, cleared on accent/font/style/palette changes) shared by both QtNameWaveDelegate and QtSessionTabBar.
  • Deleted QtNameWaveDelegate.text_inks, title_length, _painted_index, and _painted_span; both sidebar rows and busy tab titles now draw via Qt's fast selection-free QTextLayout.draw(painter, origin) path.
  • Fixed wall-clock phase flake in tests/model/test_android_perf_ux_arrivals.py:1314 by passing a deterministic AnimationClock(..., now=lambda: 0.5).

Alternating unprofiled wall-clock benchmarks (1 warm-up + 5 alternating runs)

  • Sidebar (QtNameWaveDelegate, 11 waving rows × 100 frames):
    • Before (draw(..., inks)): median 150.11 ms ([174.83, 116.01, 150.11, 161.53, 83.23])
    • After (baked_band_layout): median 78.18 ms ([78.18, 84.24, 79.50, 48.54, 70.02])
    • 1.92× faster
  • Tab bar (QtSessionTabBar, 3 waving tabs × 200 frames):
    • Before: median 95.30 ms ([89.01, 95.30, 149.52, 88.80, 98.72])
    • After: median 71.88 ms ([65.97, 75.08, 69.79, 74.65, 71.88])
    • 1.33× faster

Verification

  • REL_IMPORTS=0, tools/qt_inherit_ratchet.py: 0/0/0/0/0, tools/shadow_check.py: 0, tools/guarded_imports.py: 0
  • pytest tests/textual/test_name_wave_repaint.py tests/model/test_android_perf_ux_arrivals.py: 42 passed in 0.84s

… sidebar and 1.33x faster tab-bar wave painting
@trissim
trissim merged commit 8375095 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