Skip to content

Fix the bar startup stall and the shell restart race - #11015

Merged
dhh merged 5 commits into
omacom:quattrofrom
silversword411:perf/bar-click-target-cascade
Oct 4, 2026
Merged

dhh merged 5 commits into
omacom:quattrofrom
silversword411:perf/bar-click-target-cascade

Conversation

@silversword411

@silversword411 silversword411 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

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, with widgets/Indicators.qml as the largest multiplier, and the same cost at teardown is what makes omarchy-restart-shell race itself. Three changes:

Bar.qml — coalesce the plugin API resync and make ownership lookups O(1).
Every WidgetButton registers itself as a click target on creation. registerClickTarget replaces the clickTargets array, onClickTargetsChanged ran syncAllPluginBarApiObjects() inline, and that walked every plugin API × every click target × a linear scan of pluginObjectOwners in pluginObjectRecord. In an 8-second trace that was 1.36M pluginOwnsBarObject calls 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.

  • pluginObjectOwners is now a Map keyed by target, so pluginObjectRecord/mark/unmark/releasePluginObjects are O(1) per object (nothing outside Bar.qml read the array).
  • onActivePopoutChanged/onClickTargetsChanged/onLayoutConfigChanged schedule one resync per event-loop turn via Qt.callLater (same pattern onModuleSlotsChanged already uses for prunePluginBarApis). bindPluginBarApi still syncs a brand-new API inline, and requestPluginPopout/releasePluginPopout sync the owning API inline, so a plugin never observes a stale API on its own actions.
  • The layout is serialised once per flush instead of once per API (publicLayoutConfig() deep-copied per API per sync); each API still receives its own detached copy.
  • ModuleSlot's cursorShape binding read clickTargets for every slot on every monitor (26,700 evaluations per start); it is now gated on the slot's existing moduleHover.hovered, which is the only time the cursor is visible there.

Indicators.qml — instantiate only the current orientation's tree.
Both the Row and the Column were built and toggled with visible, so every indicator existed twice per bar, along with every process an indicator spawns (two voxtype status --follow per monitor from Dictation.qml). A Loader now picks the tree for 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 test/shell.d/indicator-contract-test.sh catches).

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 kill in timeout 5 and launched the replacement as soon as the loop ended; the fresh instance's -n no-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) until quickshell list shows 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:

stall (Configuration Loaded → polkit agent registered) bar fully populated quickshell CPU voxtype status followers
stock 19.8 / 19.8 / 20.3s 33.8 / 34.1 / 34.9s 29 / 29 / 30s 12
Indicators change 15.5 / 15.6 / 15.7s 28.8 / 30.1 / 30.2s 24 / 25 / 24s 6

With both shell changes, launching the shell from a v4-0-3 checkout 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. The Bar.qml change 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 onClickTargetsChanged 162 calls, Bar.qml:189 pluginOwnsBarObject 1,363,923 calls, Bar.qml:149 pluginObjectRecord 1,358,577 calls, Bar.qml:1916 cursorShape 26,700 evaluations, Indicators.qml 8.8s inclusive; perf: 85% of samples in libQt6Qml (Runtime::LoadElement, QObjectWrapper::virtualIsEqualTo, RuntimeHelpers::strictEqual, lookupScopeObjectProperty).

Test plan

  • ./test/all on this branch.
  • test/shell.d/bar-test.sh gains 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.sh pass with the restart change.
  • test/shell.d/indicator-contract-test.sh and bar-widget-contract-test.sh pass (the latter injects a bar whose serviceFor() is null and flips vertical).
  • Manual, on the 6-monitor machine: every widget clickable, tooltips, popouts, drag/reorder, workspace buttons, all six indicators toggle and reveal on hover, omarchy bar position left and back (exercises the orientation loader), omarchy-shell omarchy.indicators refresh, repeated omarchy restart shell.

silversword411 and others added 3 commits September 9, 2026 04:25
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>
@rdannenbring

Copy link
Copy Markdown

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 — syncAllPluginBarApiObjects re-running per click-target registration, with pluginObjectRecord scanning a list each time. In one startup trace, 358 rechecks produced 15,462 per-widget syncs and 1.7M pluginOwnsBarObject calls, ~85% of startup CPU.

Cherry-picked the three commits onto v4.0.4 (clean) and ran the shell from the checkout. Measured by pinging the shell every 50ms after launch, 3 runs each:

stock v4.0.4 this PR
frozen time after launch 11.7–12.1s 4.0–4.1s
shell stops stalling 14.0–15.2s 6.9–7.6s
teardown to process exit 3.1s 0.78s

All widgets render, indicators work, and omarchy bar position left and back exercises the new orientation loader cleanly. No new warnings.

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 ModuleSlot.injectProps() hands already-built widgets a different bar object, so WidgetButton.onBarChanged tears down and re-registers 114 of them over the next four seconds. A clone of omarchy.bar (loaded via pluginBarLoader, after the widgets are ready) registers each button once: 118 registers, 4 unregisters.

omarchybot and others added 2 commits October 2, 2026 12:53
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>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Optimizes bar startup and shell restart timing.

The PR appears safe to merge, with non-blocking concerns about immediate plugin API reads and regression coverage for the restart wait.

Findings

  1. P2 Restart wait goes untested ▶

Summary

The PR coalesces bar plugin-API updates, loads only the active indicator orientation, and waits for shell teardown before relaunching.

  • The deferred update changes when third-party widgets can observe newly registered click targets.
  • The added tests do not exercise the new instance-list wait.
Diagram
sequenceDiagram
  participant Widget
  participant Bar
  participant API
  Widget->>Bar: registerClickTarget(target)
  Bar->>Bar: update clickTargets
  Bar-->>Widget: return
  Widget->>API: read clickTargets
  API-->>Widget: previous value
  Bar->>API: deferred resync
Loading

Reviews (1) · Last reviewed commit: "Say what the bar's ownership Map actuall..."

Comment thread test/shell.d/bar-test.sh
Comment on lines +33 to +54
# 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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Click targets update late shell/plugins/bar/Bar.qml:220 ▶

    When a third-party widget calls api.registerClickTarget(target) and reads api.clickTargets before the next event-loop turn, the new target is missing. Registration now schedules the API update rather than completing it inline, so an immediate ownership check can use stale data. Popout requests receive an inline update, but click-target registration does not.

@omarchybot omarchybot added the ready Good to merge label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on a worker, with two commits pushed to your branch.

Pushed to your branch

  • 9af38fc merges current quattro, which conflicted in bin/omarchy-restart-shell. The resolution keeps 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.
  • efa6082 corrects the comment above pluginObjectOwners in Bar.qml. Qt's Map finds a key by scanning its keys (ESTable::get in qtdeclarative), so the lookups are not O(1), and the description's O(1) claim is off for the same reason. The speedup is real: it comes from no longer copying and rescanning the owner array in QML on every registration.

Reproduced on an Omarchy ISO VM (Quickshell 0.3.1, Qt 6.11.2) with six outputs (one real, five hyprctl output create headless) and the stock layout, measured from omarchy-restart-shell by pinging the shell every 50ms:

  • quattro: IPC stalls until 8.8–9.0s after the restart, and the new shell uses 7.4–7.7s of CPU in its first 45s.
  • This head: 2.8–3.3s and 2.1–2.5s, over five runs.
  • With the running shell SIGSTOPped for 7s during a restart, quattro refused the replacement as "already running", the old shell exited two seconds later, and no shell was left. This head waited it out, exited 0 and left one shell.

Tests on the same worker at efa6082: bar-test, indicator-contract-test, bar-widget-contract-test, restart-shell-test, launch-shell-test, shell-launch-test, bin-style-test, runtime-smoke-test and lock-fingerprint-indicator-test pass. ./test/cli passes apart from "vscode generated theme references current theme file", which fails the same way on quattro. Moving the bar to the left and back, which rebuilds the indicators through the new loader, logged no warning that quattro does not log too.

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 quattro takes after 5s today, now at a much higher threshold, and the readiness loop then reports the failure rather than claiming success, so it is not a blocker. The second round, on this head, found nothing further. Where it agreed with my conclusions, it had read them first, so that agreement is not independent.

Greptile's note on test/shell.d/bar-test.sh is right: the restart test's quickshell stub does not answer list, so the suite never exercises the new wait loop. The worker run above did exercise it.

Related: #13141, #8630, #14021 and #7546 also change bin/omarchy-restart-shell and will conflict with this one. #14012's cause, the 2-second readiness poll, is the loop this replaces with a 60-second deadline.

Nothing is left for you to do; this waits on the maintainer.

omarchybot added a commit to JeronimoColon/omarchy that referenced this pull request Oct 7, 2026
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>
ryanrhughes pushed a commit that referenced this pull request Oct 16, 2026
* 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)
@emirb emirb added this to the 4.0.5 milestone Oct 17, 2026
aledbf added a commit to Construct-Linux/os that referenced this pull request Oct 18, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants