Repository navigation
virtual rows: a row is laid out once, in its final form; preparations arrive in batches - #63
Merged
Merged
Conversation
… arrive in batches A row's formatting is prepared on the delegate's pool. Until now the row was laid out meanwhile as its plain text (a QTextDocument filled, sized and cached), and when the formatting arrived that document and height were dropped and the row laid out again; each arrival also started its own relayout of the view. Opening a page of history in Toad's Qt client laid out 256 plain documents it threw away, and took 103 arrivals and 13 relayouts. - A row still being prepared is a PendingRow: it stands in at a height estimated from its text's lines (no document) and paints that text with drawText. Nothing is cached for it, so its prepared formatting is laid out once when it arrives. RowFormatting.final says which a formatting is; resolved() lets a formatting that prepares on demand resolve before it is measured. - One RowPreparations runnable drains a PreparationQueue and hands finished rows to the GUI thread in batches: when the queue empties, and at most every BATCH_SECONDS while it works. _rows_prepared stores a batch, and the view lays out once for it on the next frame. - final_document is the cached laid-out document (None while pending); paint and sizeHint use it. row_document still answers a pending row (a tap over it) with a plain document it does not keep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…hat its key cached Toad's history delegate (since toad#2110) overrides _row_prepared(key, prepared) and calls it from adopt(), and while a row's new look is prepared it draws the look the row last showed, a final formatting cached under the new key. So: - _row_prepared(key, prepared) is the per-row arrival hook again. It stores the formatting, drops the documents and heights cached under the key, and starts the coalescing timer, so the view lays out once per frame however many land. _rows_prepared hands each row of a batch to it. - _cached_widths indexes the widths each key has a document or height at, so the drop takes only that key's entries, not a scan of every cache. A pending row still caches nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A virtual row is now laid out once, in its final form, and finished preparations reach the GUI thread in batches. Each batch costs one relayout of the view.
Before. While a row's formatting was being prepared on the pool, the row was laid out as plain text: a
QTextDocumentwas filled, sized and cached. When the formatting arrived, that document and its height were dropped and the row was laid out again. Each arrival also started its own relayout.After:
PendingRow. A row still being prepared stands in at a height estimated from its text's lines, with no document laid out. It paints that text withdrawText. Nothing is cached for it, so the arrival lays it out once.RowFormatting.finalsays whether a formatting is the row's real one.RowFormatting.resolved()lets a formatting that prepares on demand resolve before it is measured.RowPreparationsrunnable drains aPreparationQueue. It hands finished rows over when the queue empties, and at most everyBATCH_SECONDS(0.1 s) while it is still working._rows_preparedstores a batch, and the existing 16 ms timer lays the view out once for it.final_documentis the cached laid-out document, orNonewhile the row is pending.paintandsizeHintuse it.row_documentstill answers a pending row (a tap over it) with a plain document it doesn't keep.LogItemDelegate.painted_documentpasses a pending row'sNonethrough to the new paint.Measured in Toad's Qt client
Phone speed (45% of one core, Pixel 8a profile), unprobed
qt_drive actions, 3 runs per tree, median. The action is opening a second channel (#scratch), cold:sizeHinttimeThe remaining relayout time is the final layout of the page's rows:
QListViewasks every model row for itssizeHint. The page's worst single stall didn't move within the noise (450 → 470 ms median).Tests
tests/test_virtual_rows.pyandtests/test_log_viewer_lifecycle.py: 16 passed (main: 15).test_window_snapshot_bindings.pyneedsvispy, and the remaining suite segfaults offscreen on both trees.The matching Toad change,
PreparedOnFill.resolved, needs this merged first.🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3