Skip to content

open path: view settings class set up after startup; rows laid out once; qt_drive waits for sidebar rows - #2112

Merged
trissim merged 2 commits into
mainfrom
fork-qt-open-path
Nov 18, 2026
Merged

trissim merged 2 commits into
mainfrom
fork-qt-open-path

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown

Summary

This cuts the cost of opening a page in the Qt client, together with three library PRs. Toad's own part is small:

  • ObjectConfiguration.prepare_settings_type. It sets up, once, what every view's configuration is built from: the views' lazy settings class, each nested lazy class, and their annotations (one instance is validated). This is inherently first-time class setup, already cached per class by objectstate, and the first view the reader tapped used to pay for it. ApplicationLifetime.start now runs it once the first frame and the restored tabs are up, before settle_heap, so the classes are frozen with the rest. Both frontends inherit it. It follows qt start: first frame in 0.3 s at phone speed; APK ships bytecode; settings pages build lazily #2104's rule: nothing before the first frame.
  • PreparedOnFill.resolved. pyqt-reactive now measures only a row's final formatting (PyQT-reactive#63). A history row's measurement can resolve to its pending stand-in, which the delegate estimates instead of laying out. fill is unchanged, so this works with the installed delegate too.
  • qt_drive (tools only):
    • FRAME_TIME_OPEN times the open path per action: view configuration, lazy types, the row delegate's sizeHint / measured_height / arrivals / relayouts, and settings writes with their snapshot and invalidation.
    • FRAME_TIME_WRITES logs each settings write with the number of registered states.

The library PRs this needs

PR What it does Needed for
OpenHCSDev/PyQT-reactive#63 A row is laid out once, in its final form. Preparations arrive in batches, one relayout per batch the row-layout numbers
OpenHCSDev/ObjectState#70 A write's snapshot walks only the scopes it captures. A state opened under clean ancestors resolves its saved epoch from its live one the settings-write and view-build numbers
OpenHCSDev/python-introspect#29 resolved_class_annotations is resolved once per class most of the settings-write and view-build numbers

None of the three is an API this PR requires. Toad behaves as before on the installed libraries; tools/android/check.sh passes against the installed runtime.

How the runtime and APK pick them up. The agent-comms runtime resolves each library at main when it is built: its build.json records requested_revision: main, and the current runtime has objectstate 93c87f4, pyqt-reactive 96cce1b and python-introspect 5106570. The APK bundles that runtime's site-packages (tools/android/build.sh RUNTIME …). So the path is:

  1. Merge the three library PRs.
  2. Build a new runtime (a new core-…-lock-…).
  3. Build the batch APK from it.

Toad's uv.lock pins older commits of these libraries (objectstate d34d758, pyqt-reactive 3f0e2c0, python-introspect adc02dc) that neither the runtime nor the APK use, so this PR leaves it alone.

Measured

Phone speed (CPUQuota=45%, one core, Pixel 8a profile), unprobed qt_drive actions, 3 runs per tree, median. "Before" is #2106's head with the installed libraries. "After" is this change with the three library branches.

Opening a page:

before after
cold #comms: view configuration 399 ms 130 ms
cold #comms: its lazy types (now warmed at start) 238 ms 0 ms
cold #comms: worst stall 912 ms 661 ms
second channel (#scratch): view configuration 126 ms 51 ms
#scratch: preparation arrivals / relayouts 97 / 11 9 / 5
#scratch: relayout time 547 ms 490 ms
#scratch: worst stall 675 ms 599 ms
thread: view configuration 103 ms 46 ms
thread: worst stall 606 ms 546 ms

Mixed result. #scratch's total sizeHint time didn't improve (658 → 860 ms median, with a wide spread: 430–910 ms). Rows are now laid out once, in their final form, but QListView still asks every model row for its height on each relayout. That final layout of the page's rows is now the largest remaining cost of a second channel.

The sidebar drag's release (#2107's qt_drive drag_speed, same throttle, 3 runs each) carries one settings write:

release
installed libraries 420 ms (405, 668, 420)
with ObjectState#70 and python-introspect#29 197 ms (222, 197, 170)

Why one write cost so much. Invalidation was already scoped by scope, type and field. Every view's configuration is a lazy copy of the whole settings tree, so each open view is a real dependent of a global write. What grew with everything registered was:

  • the snapshot's deep-copy walk of every state;
  • per-instance annotation resolution under validation.

Each is fixed at its owner. Unthrottled, with 8 views open, a write's median over three rounds of 80 writes went:

  • installed: 32.7 ms;
  • with the annotation cache: 30.1 ms;
  • with both library PRs: 25.0 ms.

Most of what's left is the copy of each changed view's snapshot. Each view really changed, because it inherits the field.

Note on the base. These runs were taken before this commit was rebased onto 7752071. The rebase conflicted only in qt_drive.py's argument parsing (#2111).

Gates (once, on this head)

  • Ratchet: bare 21/21, copies 0. shadow_check: 0.
  • tools/android/check.sh: exit 0 against the installed runtime (shipped app ran every view kind and bound key on a scratch bus).
  • TUI subset (15 files: sidebar, history, sticky header, forms, usage reports, application actions): 102 passed, 17 failed. Main fails 15 of the same.
    • The 2 branch-only failures are test_window_top_edge.py::test_wheel_up_through_saved_history_never_moves_forward[size0/1].
    • They also fail on main when the file runs alone (2 failed, 7 passed on both trees), so they're load-dependent and not from this change.
  • qt_drive scenarios, with the library branches, after the lookup fix below: history, composer, sticky, placement, menu, chrome, actions, frame, slide and tabs all exit 0.
    • composer's error lines are its deliberate failed send (6-failed, to an unknown channel).
    • Before the fix, history and composer failed at qt_drive.py:649 with StopIteration. On main, composer failed the same way.

Sidebar row lookups in qt_drive (second commit)

Scenarios took rows from the live sidebar with a one-shot next(). That raised StopIteration whenever the row wasn't drawn yet, which is the timing race two forks hit today.

  • Scenario.found(wanted, label, rows) owns every such lookup. It reads the rows again every tenth of a second through the loop the scenario steps run on, until a 20 s deadline. Past the deadline it raises LookupError, for example: the sidebar lists no channel #scratch after 20.0 s; it lists: '#comms', 'dm-peer'.
  • channel_row, thread_row and the new listed_thread wait through it, and channel_listed is gone.
  • Every one-shot next() over sidebar or thread rows goes through found now. So do the two scenarios that took threads[0] or children[0] from a list that could still be empty.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

trissim and others added 2 commits November 18, 2026 03:26
…asure pending stand-ins

- ObjectConfiguration.prepare_settings_type makes the views' lazy settings class, each
  nested one, and validates one instance, so their annotations resolve once. That is
  class setup the first view the reader opened used to pay (238 ms median at a phone's
  speed on the cold #comms open). ApplicationLifetime.start runs it once the restored
  tabs are up, before the heap settles, in both frontends.
- PreparedOnFill.resolved: pyqt-reactive measures a row's final formatting only; what a
  history row's measurement resolves to may be its pending stand-in, which is estimated
  instead of laid out (pyqt-reactive#63 calls it; an older delegate fills as before).
- qt_drive: FRAME_TIME_OPEN times the open path per action (view configuration, lazy
  types, the row delegate, settings writes and their snapshot and invalidation);
  FRAME_TIME_WRITES logs each settings write with the registered states (tools only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
… one is named

The sidebar is a live list, filled from observations that can arrive after the step
that reads it. Scenarios took rows from it with a one-shot next(), which raised
StopIteration whenever the row was not drawn yet (history and composer at
qt_drive.py:649 today, twice, on main as on branches).

Scenario.found(wanted, label, rows) owns every such lookup. It reads the rows
again every tenth of a second, through the loop the scenario's steps run on,
until a 20 s deadline. Past the deadline it raises LookupError naming the missing
row and every row listed. channel_row, thread_row and the new listed_thread wait
through it, and channel_listed goes. Every one-shot next() over sidebar or
thread rows now goes through found, and so does each scenario that took
threads[0], children[0] or thread_rows()[0] from a list that could
still be empty, and #2110's ArrivalScenario, which used channel_listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
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