Measure the sidebar rebuild before optimising it #17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The sidebar is rebuilt from scratch whenever anything changes:
rebuild_sidebarincrates/terminalko/src/window.rscallsadw::Sidebar::remove_all, then rebuilds every section and every row, andrestores the selection by session id.
That is deliberate and documented (
docs/spec/session-sidebar.md):AdwSidebarItemhas no setters, so a row cannot be updated in place, and withtens of sessions rebuilding is cheaper than the bookkeeping incremental updates
would need — and cannot drift from the model.
It is called from: session state changes, foreground-program changes (every two
seconds per session, when the program changes), bells, colour changes, and every
create, delete, rename or move.
The concern
With hundreds of sessions this is wasteful, and the foreground-program path makes
it periodic rather than only user-driven. Nobody has reported a problem, and
nobody has measured it — this issue is to measure first and only then change
anything.
Work
program against
terminalko_config::Store, ordconf load), then timerebuild_sidebarand watch for dropped frames while a session's foregroundprogram changes.
GTK_DEBUG=interactiveandGSK_RENDERERtimings are enough;there is no need for a profiler at first.
documented measurement is worth more than an optimisation nobody needed.
(drag-reorder), which replaces
adw::Sidebarwith aGtkListViewover aGListStoreof row objects — and a list model can be updated in place.Doing this issue separately would mean writing that machinery twice.
Acceptance criteria
docs/spec/session-sidebar.md: how many sessions, how long arebuild takes, and whether anything is visibly dropped.
it should be issue #1's list view rather than a second mechanism.
Notes
Measured. PR #27 has the spec change and the generator.
Release build, five hundred sessions across twenty folders: 152.6 ms median per rebuild. The curve is roughly linear at ~0.3 ms a session — 3.5 ms at ten, 5.3 ms at twenty, 13.2 ms at fifty, 46.6 ms at two hundred. The 60 Hz frame budget runs out at about sixty sessions.
Nothing is visibly dropped at the sizes anyone has. It very much is at five hundred: with twenty sessions running something whose foreground program keeps changing, the sidebar rebuilds ~6.8 times a second at ~149 ms each, which is about a second of main-thread work per second — the window stops drawing rather than dropping the odd frame. The same test at fifty sessions with ten busy is ~4% of the main thread.
Two things the measurement settled that the issue could not assume:
Store::layoutplus every per-row settings read is 1.7 ms of the 152.6 ms. So the model is not the problem and caching it would buy nothing — a list view is exactly the right fix.Leaving this open, per the issue: the fix is #1's
GtkListView+GListStore, not a second mechanism here.