Skip to content

fix(process): keep large command queues responsive - #127145

Merged
steipete merged 1 commit into
mainfrom
codex/perf-command-queue-rings
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-command-queue-rings

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where large bursts of same-priority queued commands became progressively slower to enqueue and start. A 10,000-command burst spent 3.23 seconds enqueueing and 1.89 seconds draining because each operation repeatedly scanned or shifted the full pending array.

Why This Change Was Made

The process command-queue owner now uses three fixed-priority FIFO circular queues, giving append and head removal amortized constant-time behavior while retaining existing foreground/normal/background priority and FIFO ordering. The process-global singleton performs one versioned in-memory conversion after a SIGUSR1 restart so pending work created by the prior array-backed implementation is preserved; there is no persisted migration or public contract change.

User Impact

Large command bursts remain responsive instead of blocking the process for seconds. Queue priority, lane/group arbitration, wait diagnostics, cancellation/clear behavior, restart preservation, and admission policy are unchanged.

Evidence

  • Exact pre-fix proof: 512 paused enqueues performed 130,816 comparisons and draining performed 131,328 shifted-slot operations. The current-main owner files were unchanged from that red baseline before this patch.
  • Node 26.5.1 benchmark at 10,000 commands: enqueue 3,228.9 ms → 65.7 ms (49.1×); drain 1,887.2 ms → 59.3 ms (31.8×). The 5K→10K slope fell from 4.56×/4.34× to 2.09×/2.18×.
  • Final rebased head: 77/77 focused queue tests. The patch-identical pre-rebase head also passed the complete src/process suite (385 passed, 8 skipped) and 22/22 embedded-agent lane caller tests.
  • node scripts/check-changed.mjs -- <four changed paths> passed all core/core-test typechecks, changed-file lint, formatting, dead exports, import cycles, and repository guards. The patch ID is byte-identical after the non-overlapping rebase.
  • Fresh final-head autoreview: TruffleHog clean; no accepted/actionable findings; patch is correct confidence 0.98.

Risk is low-to-moderate and internal: the queue representation changes, but the tests cover partial drain/growth wraparound, every priority, capacity-group arbitration, clear/reject, restart migration, caller liveness, and backing allocation release.

AI-assisted. I understand the change and verified the final patch; no agent transcript is included because transcript-sharing consent was not provided.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 21, 2026 10:08
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 709957e1fa3a6a1ae1c244b76d748afb32aff8ce:

  • Deterministic current-main red proof: 512 same-priority entries caused 130,816 enqueue comparisons and 131,328 shifted drain slots.
  • Fixed-priority FIFO rings preserve priority/FIFO/capacity-group ordering and supported in-process restart state; 10K enqueue improved 3,228.9 → 65.7 ms and drain 1,887.2 → 59.3 ms.
  • Final focused coverage: 77/77; patch-identical broader coverage: 385 process tests passed (8 skipped) and 22/22 embedded-agent callers.
  • Changed-file gates and fresh autoreview passed; production +159/-46, tests +122/-6.
  • Exact-head CI run 32471249751 is green; native review artifacts and hosted/Testbox prepare-run passed.
  • Latest ClawSweeper state is acknowledgment only: no findings or requested rank-up moves.

No agent transcript is attached because consent was not provided.

@steipete
steipete merged commit 9b37e53 into main Aug 21, 2026
291 checks passed
@steipete
steipete deleted the codex/perf-command-queue-rings branch August 21, 2026 10:19

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants