perf(progress): smooth all-agent loading output#1078
Conversation
Throttle usage progress rendering to the existing spinner tick instead of redrawing on every state mutation. This avoids bursty terminal writes when all-agent reports start and finish many loaders at once. Suppress nested per-agent loader progress during all-agent reports so only the aggregate loader status owns the terminal line. Wake the progress worker with a condition variable on stop so short commands do not wait for the spinner sleep interval. Validated with pnpm run format, pnpm typecheck, direnv exec . pnpm run test, and TTY hyperfine comparisons against the committed fixture.
📝 WalkthroughWalkthroughThis PR refactors the agent loader configuration to force JSON output for internal loader operations and upgrades the progress spinner thread synchronization from atomic-bool polling to Mutex+Condvar-based coordination with lazy rendering. ChangesAgent Loader JSON Configuration
Progress Spinner Thread Safety Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | c763be9 | Commit Preview URL Branch Preview URL |
May 19 2026, 08:55 PM |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 12204 🏁 Script executed: Length of output: 58826
|
Check the progress worker running flag before entering the timed condvar wait. This handles the case where stop notifies between rendering and the worker starting to wait, so short commands do not fall back to the full spinner interval. Validated with direnv exec . cargo fmt --manifest-path rust/crates/ccusage/Cargo.toml --check and direnv exec . cargo test --manifest-path rust/Cargo.toml -p ccusage progress::tests.
|
@coderabbitai I pushed a follow-up commit addressing your Condvar stop-wake race note by checking the running flag before entering the timed wait. Validation:
Please review the latest push. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1821 🏁 Script executed: Length of output: 10726
let Ok(guard) = lock.lock() else { break; };
if !*guard { break; } // ← pre-wait check (new)
let Ok((guard, _)) = cvar.wait_timeout(guard, SPINNER_INTERVAL) else { break; };
if !*guard { break; } // ← post-wait checkThis closes the race window precisely: if Everything else from the original commit — throttled rendering, (^◕ᴥ◕^) If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact sizeLower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Summary:
Why:
The all-agent command can start and finish many loaders quickly, causing bursty terminal redraws that are hard to follow and slower in TTY output. This keeps the visible progress stable while avoiding unnecessary stderr writes and stop-time sleep waits.
Validation:
@coderabbitai please review this PR.
Summary by cubic
Smooths all-agent progress by throttling renders to the spinner tick and hiding nested per‑agent loaders. Also ensures immediate stop wake by closing a race, so short runs don’t wait.
Refactors
json: trueloader_shared, so only the aggregate owns the terminal line.Condvarto wake the worker on stop, eliminating stop-time delay.Bug Fixes
Written for commit c763be9. Summary will update on new commits. Review in cubic
Summary by CodeRabbit