Repository navigation
fix(queue): avoid repeated scans when cancelling backlogs - #148754
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 12:37 AM ET / 04:37 UTC (Revision 2). ClawSweeper reviewWhat this changesReplaces command-queue ring storage with linked entries so backlog cancellation avoids repeated scans, and adds cancellation and cleanup regression coverage. Merge readiness✅ Ready for maintainer review The fix remains useful: current main and the latest release still rescan pending entries during cancellation. No actionable patch defects were found. The updated measurements and explicit acceptance of the performance tradeoff resolve the previous review’s evidence request. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s command queue schedules pending agent and background tasks under priority and concurrency limits. Caller or restart cancellation removes waiting tasks, while admitted tasks retain their existing cancellation ownership. flowchart TD
A[Agent and background tasks] --> B[Priority queues]
B --> C{Capacity available}
C -->|Yes| D[Admitted task execution]
C -->|No| B
E[Caller or restart cancellation] --> F[Unlink pending entry]
B --> F
F --> G[Reject pending promise]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -25, Tests +242. Total +217 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cancellation within the existing queue owner, with constant-time unlinking and unchanged priority, concurrency, and active-task semantics. Do we have a high-confidence way to reproduce the issue? Yes: pause a lane, enqueue a large backlog, and abort its pending entries; current main visibly rescans the shrinking priority ring for every cancellation. This review established the mechanism from source and inspected supplied native measurements without running code. Is this the best way to solve the issue? Yes. Direct unlinking repairs the existing storage owner, removes both identified repeated scans, and preserves the documented queue contract without another implementation or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f10235f1a28. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '0945dabbe487213e95e84a72ad1aae3659e0e000': (115 commits) fix: omit automation service aliases from squash coauthors (#148883) test: restore services typecheck shard headroom (#148885) perf(trajectory): avoid native probes for truncation records (#148870) improve(gateway): load cron only when reload requests it (#143500) fix: resolve issue #146088 — [Bug]: The most recent Linux AppImage does not ship with the correct versions of libs needed to run (#148174) refactor(theme): share nonvirtual ANSI color lookup (#148717) perf(gateway): scope exact session row topology reads (#148836) improve(memory): reduce vector replacement overhead (#148201) fix(i18n): keep HTTP headers out of native translations (#147119) refactor(plugins): share source-root display formatting (#148646) fix(cron): reject blank script paths before mutations (#148787) refactor(config): share audit positional scanning (#148643) fix(test): restore infrastructure typecheck shard headroom (#148861) fix(release): harden package validation fallbacks (#148729) refactor(config): share leaf and descendant unset pruning (#148216) test: reuse prepared runtime for pristine preflight (#148858) fix(ui): settle global model drafts across agent switches (#148843) fix(queue): avoid repeated scans when cancelling backlogs (#148754) fix(logging): orphaned \\\\?\\ path markers corrupt redacted Windows diagnostics (#147542) refactor(hooks): share optional reply metadata projection (#148641) ...
What Problem This Solves
Fixes quadratic CPU work when a gateway restart or caller cancels a large backlog of queued commands.
User Impact
Cancelling pending work no longer rescans the remaining backlog for each entry. Priority, FIFO ordering, capacity limits, and already-active task behavior remain unchanged.
Why This Change Was Made
Each priority queue now links its pending entries directly, so cancellation unlinks only the affected entry. A fired once-abort listener also avoids a redundant search through the remaining shared-signal listeners. Removal clears queue membership and references before cleanup can reenter the queue.
The change removes 25 production lines and adds cancellation, ordering, refill, cleanup, and deterministic work-growth coverage. The obsolete ring-allocation lint suppression is removed from its exact allowlist.
Evidence
git diff --checkpassed on the reviewed bytes.a4790958b284dfa50fed9c4ae4a5e6685e798435with head604a7e85592e0667a4c5d83d42addcc9eb7ee673. Both queue modules used the same native TypeScript source-load transform, detached before warmup; all 195 install inputs and candidate source bytes stayed unchanged.4f665096f379c0ebee0db0fd1f580cea1572ef0556fab90724474799e9058822; native command/artifact checks passed and its owned lease was stopped.4a8d6309c8f0c5bf1af962de45fbbbada6675c5a2ec56f50b7bcc53e29dcd295. An earlier attempt stopped before tests because a stale local base ref produced the wrong carrier parent; it is retained as a launcher failure, not test evidence.