Repository navigation
Show the menu before its guard batch runs, cutting open time from ~140 ms to ~40 ms on laptops - #16784
Show the menu before its guard batch runs, cutting open time from ~140 ms to ~40 ms on laptops#16784hegjon wants to merge 4 commits into
Conversation
Every menu open ran the guard batch and the icon rescan from the open path: one login bash with the shipped menu's 275 when/checked/disabled guards in eight subshells, ~150 processes and ~0.7 s of CPU on a two-core laptop, plus a find over every icon directory. Started there, they compete with the first frame for the cores. On a ThinkPad T550 (i5-5300U) the menu took 131-158 ms from the keypress to a mapped layer, and 42-53 ms with the batch left out; a panel on the same OverlayWindow maps in ~30 ms. Building the 52 KB script was another 17 ms of main-thread JS before the window could show. The menu already opens on the previous batch's answers, so both now wait until the window has revealed its content plus one frame (50 ms after OverlayWindow's contentRevealed, 500 ms if it never reveals), and a menu closed before then runs neither. The script is built once per item set, since items are replaced whole and never edited in place. The batch runs under nice -n 10, so it also yields to the compositor and whatever the user is doing. The rescan still runs on every open, as omacom#15048 left it, only later. T550, dispatch to Hyprland's openlayer event, six opens: 37-47 ms, from 131-158. The batch starts ~80 ms after the open and its answers land ~0.4 s after it, as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge. SummaryThe menu now shows its card before starting the guard batch and icon scan.
No new actionable issues were found. The three earlier concerns are addressed. Tests were not run during this review.
|
…ch in docs/menu.md The review pointed at AGENTS.md: the menu's tests live in menu-test.sh and menu-guards-test.sh, not in a new file, and a test must not restate the implementation. The separate file is gone and its checks on the text of openExistingMenu with it; what remains in menu-test.sh exercises the scheduling (fallback versus reveal, run once, cancel on close) and the guard script cache through the extracted functions, and fails on the base branch. docs/menu.md's guard section now says the batch starts once the card is on screen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
AGENTS.md asks for full lines in Markdown, breaking only at structural boundaries; the paragraph the previous commit edited was still wrapped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks, @hegjon. This one has been read but not yet reviewed or run, because the two models classifying it disagree on what it is, and the kind decides how it is verified. Claude Opus 5.5 read it as an No class label has been added, and nothing was run on a worker. It is waiting on the maintainer to settle which it is; once that is decided it will be reviewed and tested on that basis. |
|
This is an If fresh numbers would help, I'll follow up with a new measurement run. |
|
New numbers from the lab machines. The branch is merged with Same measurement as in the description: Open time in ms, range (median):
Measured on 2026-11-03 with Claude Code running Claude Opus 5.5 ( |
|
As a shower tough, would it be possible to generate the menu entries ahead of time? Either the whole menu or parts of it? |
Opening the Omarchy menu took 131-158 ms on a ThinkPad T550 (i5-5300U, 2 cores) from the keypress to a mapped layer, where a panel on the same
OverlayWindowmaps in ~30 ms. The desktop this was first noticed on took ~27 ms, which is why it was easy to miss.Cause.
openExistingMenu()ran the guard batch and the icon rescan itself. The batch is one login bash with the shipped menu's 275when:/checked:/disabled:guards in eight subshells: ~150 processes and ~0.7 s of CPU on that machine, standalone and idle. Started from the open path, it competes with the first frame for the cores: the main thread's next event-loop turn came 120 ms late in half the opens, and the render thread and the compositor starved with it. Building the 52 KB script cost another 17 ms of main-thread JS beforeopened = truecould take effect. Traced withperf traceandstrace: quickshell forks the batch at +0 ms, is busy or starved until +75 ms, creates the window and its render thread from +75 to +131 ms, and the layer maps at ~+135 ms. The iconfindover 7335 files adds ~5-10 ms.Fix. The menu already opens on the previous batch's answers (#15049), so both wait until the card is on screen.
scheduleOpenWork()replaces the two calls inopenExistingMenu(). ATimerrunsevaluateGuards()andrefreshIcons()50 ms afterOverlayWindow'scontentRevealed(one frame, so the processes never land on the frame that first shows the card), or after 500 ms if the window never reveals. Closing before then cancels the work; a menu opened onto an already revealed window waits the 50 ms only.root.itemsis replaced whole on every rebuild and never edited in place, so the object's identity is the key.nice -n 10, so it yields to the shell, the compositor and whatever the user runs.test/shell.d/menu-open-work-test.shcovers the scheduling (fallback vs. reveal, cancel on close, run-once), the script cache and the batch command, in the same body-extraction style asoverlay-window-test.sh.Timing
T550,
hyprctl dispatchto Hyprland'sopenlayerevent, six opens each, hypoland compositor, omarchy-dev r7218 (the open path is identical to r7338/quattro tip):evaluateGuards)Same measurement on the rest of the fleet, stock then this branch, six opens each, with the compositor each machine ran at the time (the test laptops run Hypoland, a Hyprland fork; the desktop stock Hyprland):
Measured from the open, the batch starts about 80 ms later on the two-core Broadwell/Skylake laptops and the desktops, 105-135 ms on the X200 and 145-170 ms on the Chromebook; its answers land about 0.4 s after the open on the two-core laptops (0.39 s with the batch on the open path), 0.25 s on the Galaxy Book, 0.95 s on the X200 and 1.4 s on the Chromebook, under
nice -n 10.perf recordover three stock opens, children inherited: quickshell 12 %, its render thread 5 %, child processes 83 % (find 12, bash 11, pgrep 5, hyprctl 5, jq 5, ...).Verification
menu-test.sh,menu-guards-test.sh,menu-guard-budget-test.sh,overlay-window-test.shand the newmenu-open-work-test.shpass.qmllintadds oneunqualifiedwarning foronContentRevealedChanged: if (contentRevealed && ...), the same form as theonShownChangedline above it; no new errors.Tooling
The investigation (perf, strace, the Hyprland event-socket harness), the patch, the test and the fleet measurements were done with Claude Code running Claude Fable 5.1 (
claude-fable-5-1) at reasoning effort 80, directed and reviewed by the author in one session on 2026-10-27.🤖 Generated with Claude Code