Repository navigation
Fix the bar startup stall and the shell restart race - #11015
Conversation
Indicators.qml built both the horizontal Row and the vertical Column and toggled them with `visible`, so every indicator existed twice per bar, and so did every process an indicator spawns: Dictation.qml ran two `voxtype status --follow` per monitor. On a six-monitor bar that is 72 indicator instances and twelve followers for six visible icons, and each instance registers a click target and re-syncs the active-indicator model as its state resolves at startup. A Loader now instantiates the tree that matches `root.vertical`. Each tree is wrapped in an Item that keeps the stock explicit implicit-size expressions, so the root's size still follows the blocks synchronously; a bare positioner only updates its implicit size on polish, which the indicator contract test's center-hover check catches. Measured on a six-monitor, 23-widget bar (three runs each, `omarchy restart shell`): time from "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 15.5-15.7s, quickshell CPU 29-30s -> 24-25s, voxtype followers 12 -> 6. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every WidgetButton registers itself as a bar click target when it is created. registerClickTarget replaced the clickTargets array, the change handler ran syncAllPluginBarApiObjects() inline, and that walked every plugin API times every click target times a linear scan of pluginObjectOwners in pluginObjectRecord. Startup is a few hundred registrations, so the cost is quadratic in bar size and multiplied by the number of monitors: a six-monitor, 23-widget bar spent 16-20 seconds of pegged QML thread before it was populated, and an 8-second qmlprofiler capture showed 1.36 million pluginOwnsBarObject calls and 46-71ms per registration. - pluginObjectOwners is a Map keyed by target, so pluginObjectRecord, markPluginObject, unmarkPluginObject and releasePluginObjects are O(1) per object. Nothing outside Bar.qml read the array. - The activePopout, clickTargets and layoutConfig change handlers schedule one resync per event-loop turn through Qt.callLater, the way onModuleSlotsChanged already defers prunePluginBarApis. bindPluginBarApi still syncs a brand-new API inline, and requestPluginPopout and releasePluginPopout sync the owning API inline, so a plugin never reads a stale API on its own actions. - A flush serialises the layout once and hands each API its own parsed copy instead of deep-copying it once per API per sync. - ModuleSlot's cursorShape read clickTargets for every slot on every monitor (26,700 evaluations per start). It is now gated on the slot's HoverHandler, which is the only time the cursor is over it. Measured on the same bar, launching the shell from a checkout with this and the indicators change (two runs): "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 0.70s, bar populated 1.7s after launch (from ~30s), quickshell CPU 29-30s -> 2.0s. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
omarchy-restart-shell stopped the running shell with `quickshell kill` under a five-second timeout and launched the replacement as soon as the loop ended. A six-monitor bar takes 5.4-6.0 seconds to tear down (every widget button unregisters its click target on destruction, and each unregistration re-synced every plugin API), so the client timed out while the shell was still exiting, the fresh instance's no-duplicate check saw the dying one and quit, and the user was left with no bar and "Omarchy shell did not become ready after restart". Give the kill client thirty seconds, then wait, bounded, until `quickshell list` shows no instance of the session config before launching. The readiness check also waits on a sixty-second deadline instead of twenty attempts: a large bar answers ping only after its plugins have loaded, which on the stock bar was well past the old twelve-second window. Verified three consecutive restarts against the stock shell on the six-monitor machine: each returned 0 in about six seconds with exactly one instance and no "already running" in the journal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
79cce4e to
cf6b525
Compare
|
Thanks for digging into this and for the thorough write-up — the profile signature in the description matched what I was seeing exactly, and saved me from opening a duplicate. Independent confirmation on very different hardware: 2 monitors, 40 third-party plugins, ~45 bar widgets, Omarchy v4.0.4. I profiled the same stall before finding this PR and landed on the same code — Cherry-picked the three commits onto
All widgets render, indicators work, and One more contributor to the same cascade, which this PR makes cheap but doesn't remove: the stock bar builds its buttons twice. 116 register as widget components arrive, then |
Resolve bin/omarchy-restart-shell by keeping quattro's shell_ready flag, lock re-securing and notification wait after the readiness loop, with this branch's 60-second readiness deadline in place of the 20-attempt loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qt's V4 Map (ESTable::get) finds a key by scanning its keys, so ownership lookups are not O(1). The win is that a registration no longer copies the owner array and rescans it in QML. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
| # Every click target registration used to resync every plugin api inline. With | ||
| # six monitors' worth of widgets that is hundreds of full walks at startup, so | ||
| # the change handlers coalesce into one deferred resync and ownership lookups | ||
| # are keyed by target instead of scanning an array. | ||
| if ! rg -q 'onClickTargetsChanged: schedulePluginBarApiSync\(\)' "$ROOT/shell/plugins/bar/Bar.qml"; then | ||
| fail "bar coalesces plugin api resyncs instead of running one per click target change" | ||
| fi | ||
| if ! rg -q 'Qt\.callLater\(root\.syncAllPluginBarApiObjects\)' "$ROOT/shell/plugins/bar/Bar.qml"; then | ||
| fail "bar defers the coalesced plugin api resync to the event loop" | ||
| fi | ||
| if ! rg -q 'pluginObjectOwners\.get\(target\)' "$ROOT/shell/plugins/bar/Bar.qml"; then | ||
| fail "bar looks plugin object ownership up by target instead of scanning" | ||
| fi | ||
| pass "bar coalesces plugin api resyncs and looks ownership up by target" | ||
|
|
||
| # Both bar orientations used to be instantiated and toggled with `visible`, | ||
| # doubling every indicator (and every process an indicator spawns) per bar. | ||
| if ! rg -q 'sourceComponent: root\.vertical \? verticalIndicatorsTree : horizontalIndicatorsTree' \ | ||
| "$ROOT/shell/plugins/bar/widgets/Indicators.qml"; then | ||
| fail "indicators instantiate only the tree for the current bar orientation" | ||
| fi | ||
| pass "indicators instantiate only the tree for the current bar orientation" |
There was a problem hiding this comment.
Restart wait goes untested These assertions check source text but not whether the new behavior works. The restart test’s Quickshell stub does not respond to
list -a -j, so its wait loop exits immediately in tests. A regression that launches the replacement while the old shell is still exiting could therefore pass the suite; add a case where a listed instance delays launch.
Comments Outside DiffThese findings could not be posted inline.
|
|
Reviewed and verified on a worker, with two commits pushed to your branch. Pushed to your branch
Reproduced on an Omarchy ISO VM (Quickshell 0.3.1, Qt 6.11.2) with six outputs (one real, five
Tests on the same worker at efa6082: Second opinion: Codex Medium, two rounds. The first found the O(1) comment above. It also pointed out that the restart still launches if the old shell outlasts both 30-second waits. That is the path Greptile's note on Related: #13141, #8630, #14021 and #7546 also change Nothing is left for you to do; this waits on the maintainer. |
quattro guarded the same cursorShape binding with moduleHover.hovered so only the hovered slot runs the hit test (omacom#11015). Keep that guard and this branch's live hover coordinates together: the guard alone still hit-tests at the MouseArea's press-only mouseX/mouseY. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Instantiate only the current orientation's indicator tree Indicators.qml built both the horizontal Row and the vertical Column and toggled them with `visible`, so every indicator existed twice per bar, and so did every process an indicator spawns: Dictation.qml ran two `voxtype status --follow` per monitor. On a six-monitor bar that is 72 indicator instances and twelve followers for six visible icons, and each instance registers a click target and re-syncs the active-indicator model as its state resolves at startup. A Loader now instantiates the tree that matches `root.vertical`. Each tree is wrapped in an Item that keeps the stock explicit implicit-size expressions, so the root's size still follows the blocks synchronously; a bare positioner only updates its implicit size on polish, which the indicator contract test's center-hover check catches. Measured on a six-monitor, 23-widget bar (three runs each, `omarchy restart shell`): time from "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 15.5-15.7s, quickshell CPU 29-30s -> 24-25s, voxtype followers 12 -> 6. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Coalesce plugin API resyncs and key bar object ownership by target Every WidgetButton registers itself as a bar click target when it is created. registerClickTarget replaced the clickTargets array, the change handler ran syncAllPluginBarApiObjects() inline, and that walked every plugin API times every click target times a linear scan of pluginObjectOwners in pluginObjectRecord. Startup is a few hundred registrations, so the cost is quadratic in bar size and multiplied by the number of monitors: a six-monitor, 23-widget bar spent 16-20 seconds of pegged QML thread before it was populated, and an 8-second qmlprofiler capture showed 1.36 million pluginOwnsBarObject calls and 46-71ms per registration. - pluginObjectOwners is a Map keyed by target, so pluginObjectRecord, markPluginObject, unmarkPluginObject and releasePluginObjects are O(1) per object. Nothing outside Bar.qml read the array. - The activePopout, clickTargets and layoutConfig change handlers schedule one resync per event-loop turn through Qt.callLater, the way onModuleSlotsChanged already defers prunePluginBarApis. bindPluginBarApi still syncs a brand-new API inline, and requestPluginPopout and releasePluginPopout sync the owning API inline, so a plugin never reads a stale API on its own actions. - A flush serialises the layout once and hands each API its own parsed copy instead of deep-copying it once per API per sync. - ModuleSlot's cursorShape read clickTargets for every slot on every monitor (26,700 evaluations per start). It is now gated on the slot's HoverHandler, which is the only time the cursor is over it. Measured on the same bar, launching the shell from a checkout with this and the indicators change (two runs): "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 0.70s, bar populated 1.7s after launch (from ~30s), quickshell CPU 29-30s -> 2.0s. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Wait for the old shell to exit before restarting it omarchy-restart-shell stopped the running shell with `quickshell kill` under a five-second timeout and launched the replacement as soon as the loop ended. A six-monitor bar takes 5.4-6.0 seconds to tear down (every widget button unregisters its click target on destruction, and each unregistration re-synced every plugin API), so the client timed out while the shell was still exiting, the fresh instance's no-duplicate check saw the dying one and quit, and the user was left with no bar and "Omarchy shell did not become ready after restart". Give the kill client thirty seconds, then wait, bounded, until `quickshell list` shows no instance of the session config before launching. The readiness check also waits on a sixty-second deadline instead of twenty attempts: a large bar answers ping only after its plugins have loaded, which on the stock bar was well past the old twelve-second window. Verified three consecutive restarts against the stock shell on the six-monitor machine: each returned 0 in about six seconds with exactly one instance and no "already running" in the journal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Say what the bar's ownership Map actually saves Qt's V4 Map (ESTable::get) finds a key by scanning its keys, so ownership lookups are not O(1). The win is that a registration no longer copies the owner array and rescans it in QML. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Codex Medium <noreply@openai.com> (cherry picked from commit 454b67d)
Omarchy's bar took 20 s to fill on a six-monitor machine (omacom/omarchy#11015), and nothing in our report would have said so: a PASS means an extension is active, not what it cost. The report now reads the session's start from the journal after the fact: the shell's unit starting, "GNOME Shell started" (its startup animation complete, which comes before the extensions finish - they load on the main loop in turns), and each extension from "Loading extension" to the state it ended in, which the extension manager logs at debug priority. The test layer keeps those lines with G_MESSAGES_DEBUG="GNOME Shell": the shell's JavaScript logs under that domain once environment.js sets it, and quoted, since systemd reads a bare space as a second assignment. shell-startup.txt lists the extensions slowest first; the report's line carries both totals and the slowest. boot.txt gains the user manager's own analyze, which the system's chain stops short of. Not a gate: a VM's numbers are not a machine's. On the test disk the shell takes 3.0 s from its unit to startup complete and 3.9 s to the last extension loaded, AppIndicator the slowest at 0.6-0.9 s; on the stick 5.2 s and 6.7 s, with Tiling Shell at 2.1 s over emulated USB. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Summary
The bar takes 16–20 seconds of pegged single-core QML time to populate on a 6-monitor machine with a full widget layout (23 widgets per bar). Profiling with perf and qmlprofiler put the whole stall in
shell/plugins/bar/Bar.qml's click-target bookkeeping, withwidgets/Indicators.qmlas the largest multiplier, and the same cost at teardown is what makesomarchy-restart-shellrace itself. Three changes:Bar.qml — coalesce the plugin API resync and make ownership lookups O(1).
Every
WidgetButtonregisters itself as a click target on creation.registerClickTargetreplaces theclickTargetsarray,onClickTargetsChangedransyncAllPluginBarApiObjects()inline, and that walked every plugin API × every click target × a linear scan ofpluginObjectOwnersinpluginObjectRecord. In an 8-second trace that was 1.36MpluginOwnsBarObjectcalls and 46–71ms per registration; startup alone is a few hundred registrations, so the cost is quadratic in bar size and multiplied by monitor count.pluginObjectOwnersis now aMapkeyed by target, sopluginObjectRecord/mark/unmark/releasePluginObjectsare O(1) per object (nothing outsideBar.qmlread the array).onActivePopoutChanged/onClickTargetsChanged/onLayoutConfigChangedschedule one resync per event-loop turn viaQt.callLater(same patternonModuleSlotsChangedalready uses forprunePluginBarApis).bindPluginBarApistill syncs a brand-new API inline, andrequestPluginPopout/releasePluginPopoutsync the owning API inline, so a plugin never observes a stale API on its own actions.publicLayoutConfig()deep-copied per API per sync); each API still receives its own detached copy.ModuleSlot'scursorShapebinding readclickTargetsfor every slot on every monitor (26,700 evaluations per start); it is now gated on the slot's existingmoduleHover.hovered, which is the only time the cursor is visible there.Indicators.qml — instantiate only the current orientation's tree.
Both the
Rowand theColumnwere built and toggled withvisible, so every indicator existed twice per bar, along with every process an indicator spawns (twovoxtype status --followper monitor fromDictation.qml). ALoadernow picks the tree forroot.vertical. Each tree is wrapped in anItemthat keeps the stock explicit implicit-size expressions, so the root's size still follows the blocks synchronously (a bare positioner only updates its implicit size on polish, whichtest/shell.d/indicator-contract-test.shcatches).omarchy-restart-shell — wait for the old shell to actually exit.
The same cascade runs in reverse at teardown (every button unregisters on destruction), so the stock shell takes 5.4–6.0s to exit on this machine. The restart script wrapped
quickshell killintimeout 5and launched the replacement as soon as the loop ended; the fresh instance's-nno-duplicate check saw the still-dying one and quit, leaving no bar. Worse, the readiness ping was answered by the dying instance, so the script reported success (reproduced: exit at 11:14:52.59, "already running" at 11:14:57.61 — 5.01s). The client now gets 30s, the script then waits (bounded) untilquickshell listshows no instance of the session config, and readiness waits on a 60s deadline instead of 20 attempts. Three consecutive restarts against the stock shell: exit 0 in ~6s, one instance, no "already running".Measurements (6 monitors, 23 widgets/bar, Omarchy 4.0.3, 3 runs each,
omarchy restart shell)The Indicators change was measured in isolation as a user-plugin clone before this branch existed:
voxtype statusfollowersWith both shell changes, launching the shell from a
v4-0-3checkout on the same machine (two runs): stall 0.70s / 0.70s, bar fully populated 1.69s / 1.70s after launch (stock: ~30s after launch), quickshell CPU 2.0s / 2.0s, clean log. TheBar.qmlchange is the bulk of it: it removes the per-registration cost rather than the registration count. Teardown drops from 5.4–6.0s to ~1.2s.Profile signature for reference (qmlprofiler, 8.4s capture during the stall):
Bar.qml:317 onClickTargetsChanged162 calls,Bar.qml:189 pluginOwnsBarObject1,363,923 calls,Bar.qml:149 pluginObjectRecord1,358,577 calls,Bar.qml:1916 cursorShape26,700 evaluations,Indicators.qml8.8s inclusive; perf: 85% of samples in libQt6Qml (Runtime::LoadElement,QObjectWrapper::virtualIsEqualTo,RuntimeHelpers::strictEqual,lookupScopeObjectProperty).Test plan
./test/allon this branch.test/shell.d/bar-test.shgains source-shape assertions for the coalesced resync, the keyed ownership lookup, and the single-orientation indicators tree.test/shell.d/restart-shell-test.sh,bin-style-test.sh,launch-shell-test.sh,shell-launch-test.shpass with the restart change.test/shell.d/indicator-contract-test.shandbar-widget-contract-test.shpass (the latter injects a bar whoseserviceFor()is null and flipsvertical).omarchy bar position leftand back (exercises the orientation loader),omarchy-shell omarchy.indicators refresh, repeatedomarchy restart shell.