Repository navigation
Cap parallel collectors in omarchy-agent-usage-update - #19026
Conversation
[Medium impact] The reviewed changes appear safe to merge, with no new actionable findings. SummaryCaps
Reviews (6) · Last reviewed commit: "Cap the collectors with a plain slot loo..." · Reviewed by Greptile |
1f29b74 to
ee7bdd0
Compare
|
Data point from #18973, in case it helps pick the default. On an i7-1255U (4P+8E, 15 W, 12 threads), the 23 collectors cost 499 CPU-s sequentially (41 s wall, cold; 475 CPU-s warm, since So a cap of 2 converts that into ~250 s on 2 cores. I think that is the right trade — 10 of 12 threads stay free, which is the whole point — but it is worth saying in the body that a refresh can now take minutes on a laptop, so nobody is surprised when the panel's numbers look stale for a while. Two notes from checking the consumer side:
Happy to re-run my telemetry with the patch applied and report the before/after wall time if that's useful for the PR. |
|
Thanks for the detailed telemetry on the i7-1255U and for verifying Updated the PR description to call out the longer refresh wall time on large local session histories (and aligned the PID-reaping note with the current |
The usage refresh started every collector at once, so each periodic run pinned every core for the length of the scan. Keep two running. Take each exit status from wait on that collector's pid: wait -n returns 127 when several have already finished, and that 127 is not a failed collector. A capped refresh can run longer than the Codex forced-read window. The updater's pid keeps that one scan valid until the refresh exits. A stamp inherited without that parent still expires. Fixes omacom#18973
ee7bdd0 to
92e5b50
Compare
|
Classification is unsettled. GPT-6 in Codex (High) classified this as a bug fix for the unbounded collector concurrency reported in #18973; the separate classifier, deepseek-v4p1-flash (effort unspecified), returned enhancement. I read the PR description, discussion and linked issue, and inspected the change for classification. Runtime verification has not run, and no class or verification labels were applied. This is waiting on the maintainer to resolve the classification before verification continues. |
|
Adding a controlled thermal data point for #18973 on Omarchy 4.5.0-3, MacBookPro14,3, kernel In the installed build, the Agents timer defaults to 900 s and calls
The comparison covers one disabled slot, and battery charge differed between the two runs. It supports the scheduled refresh as the trigger on this setup. The thermal effect of the proposed two-collector cap, which release introduced the behavior, power draw, and S3 behavior remain unverified. |
|
The cap leaves the other threads free, but when the foreground is already using all of them, the two collectors still compete with it at normal priority. Dropping the updater to idle CPU and I/O priority fixes that, and the collectors inherit it: [[ $collector_jobs =~ ^[1-9][0-9]*$ ]] || collector_jobs=2
+chrt --idle -p 0 $$
+ionice -c 3 -p $$
+
collector_pids=()I tried it on this branch (92e5b50) on a 5600X (6c/12t). I ran a CPU-bound load on all 12 threads doing fixed 8ms units of work, timed each unit during a forced refresh, and repeated each case 5 times:
With 4 threads left free I couldn't measure any difference, so it only matters when nothing is spare. That's the case for a game, say, or a laptop with fewer threads. Under full load the refresh takes longer (about 7.5s vs 4s), since it only gets leftover time. The refresh PID handling you already added covers a refresh that runs long. On an idle machine the time is the same. I had this in #19831 (jampick's #17983 does the same), but it fits better here. Happy to close mine if you pick it up. |
|
The queued fold from #19831 remains unapplied because classification is still unsettled: GPT-6 in Codex (effort not exposed) calls this a bug fix, while the classification-only reviewer deepseek-v4p1-flash (effort unspecified) again returned enhancement. GitHub also reports a conflict with current I read the updated discussion and linked issue, checked the base-branch rules and updater, and inspected the change for classification. No worker verification ran, no code was pushed, and no verification labels were applied. This is waiting on the maintainer to resolve classification before the fold and runtime verification can continue. |
|
Sizing data for the cap, measured on the machine where I hit this (i7-1255U, 4P+8E, 12
Measured with getrusage over the whole tree, idle baseline 0.22 threads. So the burst is Two things that bear on the cap:
On @itstxl's idle-priority diff: agreed, and the numbers they measured (108 ms -> 47 ms Correction to my earlier comment in #18973: the "499 CPU-s" figure was a measurement bug on |
quattro deleted test/shell.d/agent-usage-codex-rollouts-test.sh when it slimmed the shell suite (omacom#19904), and this branch had extended it with the cases for a refresh stamp older than its window. The deletion stands: the file's other cases went with it on quattro, and bringing it back for these would undo that. The stamp's ancestor check is left covered only by the updater test that the pid is exported. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Running two collectors at a time needs only a wait for a free slot before each start: wait -n frees one, and each collector's status is still read from its own pid afterwards, which bash keeps after wait -n has reaped it. That replaces the polling reaper, and the 50ms sleeps that made a refresh over the 24 collectors take 1.2s where this takes 0.9s. The refresh pid and the ancestor walk in collectors.py are gone: they only spared a repeated Codex scan in a refresh that runs past five minutes, and the stamp window can be raised if one ever does. OMARCHY_AGENT_USAGE_JOBS is gone too, since nothing set it but the tests. The test covers what the change is: no more than two at once, every record written, a failure still reported, and a run where every collector passed still succeeding, which is the case that breaks if a status is ever lost to wait -n. Co-Authored-By: itstxl <154011486+itstxl@users.noreply.github.com> Co-Authored-By: Opus 5.5 High <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Reviewed, and reduced at the maintainer's request to the smallest change that caps the collectors. The cap itself works: on a stock Omarchy worker (bash 5.3.20, 4 cores) What I pushed, and why
What was checked All of it ran on the worker, nothing on a maintainer's machine. The cap test fails against Second opinion Opus 5.5 (high) and muse-wonder (high, via pi) each read this head, in two rounds; I am Fable 5.2 in Claude Code. Their independence from my reasoning is not guaranteed. What they added beyond agreement:
Both ended with nothing open on Still open, for the maintainer
|
quattro now caps the collectors at two at a time (omacom#19026) with the same slot loop this branch had, so the merge takes quattro's loop, its cap of two over this branch's four, and its test of the cap. What is left of this branch is the idle CPU and I/O priority. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Cap parallel collectors in omarchy-agent-usage-update The usage refresh started every collector at once, so each periodic run pinned every core for the length of the scan. Keep two running. Take each exit status from wait on that collector's pid: wait -n returns 127 when several have already finished, and that 127 is not a failed collector. A capped refresh can run longer than the Codex forced-read window. The updater's pid keeps that one scan valid until the refresh exits. A stamp inherited without that parent still expires. Fixes omacom#18973 * Cap the collectors with a plain slot loop Running two collectors at a time needs only a wait for a free slot before each start: wait -n frees one, and each collector's status is still read from its own pid afterwards, which bash keeps after wait -n has reaped it. That replaces the polling reaper, and the 50ms sleeps that made a refresh over the 24 collectors take 1.2s where this takes 0.9s. The refresh pid and the ancestor walk in collectors.py are gone: they only spared a repeated Codex scan in a refresh that runs past five minutes, and the stamp window can be raised if one ever does. OMARCHY_AGENT_USAGE_JOBS is gone too, since nothing set it but the tests. The test covers what the change is: no more than two at once, every record written, a failure still reported, and a run where every collector passed still succeeding, which is the case that breaks if a status is ever lost to wait -n. Co-Authored-By: itstxl <154011486+itstxl@users.noreply.github.com> Co-Authored-By: Opus 5.5 High <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: itstxl <154011486+itstxl@users.noreply.github.com>
Fixes #18973.
omarchy-agent-usage-updatestarted everyomarchy-agent-usage-*collector at once. Each one re-scans local session stores, so on a machine with real agent history a refresh held every core for the length of the scan, and since the agents widget runs it on a timer, games and the desktop hitched every 15 minutes.The collectors now take turns, two at a time: before starting one, the updater waits for a free slot with
wait -n, and each collector's status is still read from its own pid afterwards, so a failing collector is reported as before and the rest are still written. The other threads stay free for whatever is in the foreground.The cost is wall time. A refresh takes roughly half the sum of the collectors rather than the slowest one: over the 24 collectors on a machine with no history, 0.9s instead of 0.6s, and on a large history it can be a minute or more. That includes the
--limits-onlyrefresh the panel runs when it opens, which is network probes rather than scans, so its records arrive two at a time as well. Each record still appears as soon as its collector writes it, andMain.qmlalready collapses refreshes requested while one is running into a single rerun.