Skip to content

Cache sidebar row QImages (11x paint speedup, frame_work 69.3->37.7), fix CoalescedQEventLoop re-entrancy, clear NRA gate - #2330

Merged
trissim merged 1 commit into
mainfrom
perf/qt-sidebar-row-image-cache
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/qt-sidebar-row-image-cache

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown

Summary

  1. Sidebar row QImage cache (src/toad/qt/name_wave.py, tools/frame_work_baseline.json):

    • QtNameWaveDelegate.paint caches rendered row QImages per (id(row), span, width, height, state._value_, wraps, dpr), cleared in forget_rows() and _set_wave_accent(), passing active flash rows straight through to super().paint() and closing QPainter in try/finally.
    • 60-frame alternating wall-clock benchmark (12 waving rows): 55.4 ms -> 5.0 ms (11×).
    • Scratch-bus frame_work gate: 69.3 -> 37.7 Python calls/frame (-45.6%); verified follow-up run 38.0 within baseline, 0 px sideways drag, accent drawn 15–16/20 looks.
  2. CoalescedQEventLoop re-entrant processEvents() deadlock fix (src/toad/qt/client_start.py, tools/qt_scroll_profile.py):

    • _drain_ready() now defers ready callbacks when asyncio.current_task(self) is not None, preventing RuntimeError: Cannot enter into task ... while another task ... is being executed and lost task wakeups when processEvents() or a modal exec() runs inside an asyncio task.
    • Switched tools/qt_scroll_profile.py to run_qt_loop with XDG_CONFIG_HOME/XDG_STATE_HOME isolated under OUTDIR and clean shutdown. Live #comms (412x915) exits SCROLL_RC=0 with fling frame p95 0.826 ms / latency p95 3.393 ms, wheel frame p95 0.537 ms, arrival jump 0 px.
  3. Clear NRA semantic_refactor_gate (1 -> 0) + own_type_test (src/toad/client/theme_tones.py, src/toad/sidebar_rows.py, src/toad/client/line_blocks.py, src/toad/qt/history.py):

    • Declared ChannelRowTone(HueToneColour) and derived ChannelRowFace.row_tones = tuple(ChannelRowTone.__subclasses__()), clearing Toad's sole semantic_mirror_without_descent boundary finding (b662823ada).
    • Added LineBlock.triggers_header_collapse (True on Divider), removing isinstance(..., Divider) (IMPL-3) at QtHistoryWindow._header_collapse_at.

Verification

  • REL_IMPORTS=0, qt_inherit_ratchet.py: 0/0/0/0/0, shadow_check.py: 0, guarded_imports.py: 0.
  • tests/textual/test_name_wave_repaint.py + tests/guards/test_shared_frontend_members.py: 17 passed in 0.32s.
  • Focused tests/model/test_android_perf_ux_arrivals.py: 5 passed in 0.29s.
  • NRA scan on touched modules: semantic_refactor_gate gate_active: False, boundary: 0.

…7.7), fix CoalescedQEventLoop re-entrancy, clear NRA gate

- QtNameWaveDelegate.paint (src/toad/qt/name_wave.py): cache rendered
  row QImages keyed by (id(row), span, width, height, state._value_,
  wraps, dpr), invalidated in forget_rows() and _set_wave_accent(), with
  try/finally QPainter.end() and active-flash passthrough.
  - 60-frame waving sidebar benchmark (12 rows): 55.4ms -> 5.0ms (11x).
  - Scratch-bus frame_work gate: 69.3 -> 37.7 Python calls/frame (-45.6%),
    verified 38.0 within baseline, 0px sideways, accent drawn 15-16/20 looks.
- CoalescedQEventLoop._drain_ready (src/toad/qt/client_start.py): defer
  draining ready handles when asyncio.current_task(self) is not None
  (re-entrant QApplication.processEvents() / modal exec() inside an
  asyncio Task), preventing RuntimeError: Cannot enter into task and
  dropped task wakeups that deadlocked close_client().
- tools/qt_scroll_profile.py: run on CoalescedQEventLoop (matching
  desktop/Android), isolate XDG_CONFIG_HOME/XDG_STATE_HOME under OUTDIR,
  and remove bare task-cancel/quit in finally. Live #comms (412x915):
  clean SCROLL_RC=0, fling frame p95 0.826ms / latency p95 3.393ms,
  arrival reader jump 0px.
- Clear NRA semantic_refactor_gate (1->0) and own_type_test:
  - ChannelRowTone(HueToneColour) in src/toad/client/theme_tones.py,
    ChannelRowFace.row_tones derived via tuple(ChannelRowTone.__subclasses__()).
  - LineBlock.triggers_header_collapse (True on Divider) replacing
    isinstance(blocks[block_index], Divider) in QtHistoryWindow._header_collapse_at.
@trissim
trissim merged commit e9d1cab 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