Repository navigation
perf(process): isolate agent exec IO in delegated cgroups - #188379
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c9b1b3071
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: blocked before merge. What this changesThis PR separates Linux agent commands from Gateway processes using delegated cgroups with aggregate IO and memory pressure limits and lower CPU priority. Example: A Linux Gateway has a 4 GiB exec memory allowance and one backing device.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 8 items remain Keep open: this maintainer-directed performance improvement has value, but execution-cleanup regressions and unmigrated consumers block merge. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway startup prepares kernel resource policy; process brokers, command adapters, and PTY helpers place command trees into the exec cgroup while service installation and Doctor manage delegation. flowchart TD
A[Service installation and Doctor] --> B[Delegated service cgroup]
B --> C[Gateway leaf]
C --> D[Gateway startup policy]
D --> E[Agent exec leaf]
C --> F[Broker and command adapters]
F --> E
E --> G[Commands and descendants]
Technical reviewBest possible solution: Keep the shared cgroup placement design, restore bounded cancellation and canonical cleanup errors, and complete the existing consumer cutover. Do we have a high-confidence way to reproduce the issue? Source establishes the Windows cancellation and cleanup-classification regressions, and exact-head CI confirms several consumer failures; no target code was executed during this review. Is this the best way to solve the issue? One startup policy owner with placement at existing process boundaries is appropriate, but replacing extension execution must preserve its established cancellation and error contracts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b186cf209834. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +452, Tests +278, Docs +66, Other +553. Total +1349 across 38 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 9:59 AM ET / 13:59 UTC. |
Complete worker COMMIT measurement and update service/process fixtures for the delegated cgroup contract.
3c9b1b3 to
a5ae78c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a116f4c0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the outstanding lifecycle review findings in
Independent review is clean. The private environment marker is removed and the environment budget remains unchanged at 458/458. The PR records the x64 throttling smoke and missing long comparison. The mock baseline only shrinks by six obsolete entries requested by CI. All other baseline and budget files are unchanged. Exact-head CI has completed. Landing uses the authorized inherited/unrelated-failure exception: four pagination assertions reproduce on unchanged main parent |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae782ab0ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…88379) * perf(process): isolate agent exec IO in delegated cgroups * fix(process): preserve exec cleanup classification Complete worker COMMIT measurement and update service/process fixtures for the delegated cgroup contract. * fix(process): require explicit delegation for exec isolation * test(process): type the cleanup fixture PID pair * test(process): preserve exports in delegation mocks * fix(process): discover exec delegation from kernel state * fix(process): preserve stop and fallback cancellation lifecycles * fix(process): fence Windows fallback signals after root exit * test(process): define native exit state in Windows fixtures * fix(cli): recognize delegated Gateway installation identity
What Problem This Solves
Disk-heavy agent commands contend with Gateway SQLite writes when their process trees share the Gateway's systemd cgroup. This change gives host agent-exec trees their own resource controls while keeping the Gateway in an uncapped sibling leaf.
User Impact
Agent exec receives an aggregate
io.maxceiling,cpu.weight=10, andmemory.high. Disk-heavy commands intentionally run more slowly to leave resources for interactive requests. The Gateway leaf receives no IO cap from this feature.Delegation is an explicit operator action:
openclaw gateway install --forceoropenclaw doctor --fixinstallsDelegate=yesandDelegateSubgroup=gateway(systemd 254+). systemd moves the launcher into the Gateway leaf before startup, leaving the service root empty for controller enablement. Normal updates preserve existing unit delegation policy, including its absence; they do not opt existing units in. Custom service policy is retained. Deployment controllers that assume root cgroup membership need coordinated adoption.Without writable delegation, available controllers, and valid leaf placement, isolation leaves the cgroup layout unchanged, continues running, and emits one startup diagnostic directing the operator to Doctor. Unsupported backing filesystems also preserve working exec with a diagnostic.
Why This Change Was Made
io.maxuses blk-throttle, including with thenonescheduler. The startup owner resolves the state directory's exact mount, keeps md/RAID and device-mapper logical devices, normalizes partitions, and accounts for all btrfs members. The ceiling is a pressure budget, not measured storage bandwidth: one existing exec memory allowance per five minutes, split equally between reads and writes and across devices. IOPS use a 4 KiB equivalent; finite ancestor ceilings further cap each corresponding dimension at half its allowance.Runtime detection reads
/proc/self/cgroupand verifies writable delegated controls, leaf placement, and controllers. Helpers discover kernel-owned policy; existing broker IPC carries placement context where necessary. There is no new environment variable or user configuration. The environment budget stays unchanged at 458. The only baseline edit removes six obsolete mock exemptions; no baseline or budget is raised.Broker children, host exec anchors, background descendants, PTY helpers, and extension
ctx.execshare the placement owner. Extension exec reuses the owned child adapter while preserving custody, cancellation, bounded output, and background-child lifetime. Windows fallback cancellation retains its five-second grace and forced cleanup, and refuses PID-based signals after observed root exit. Hosted stop and startup installation self-proof recognize the managed/gatewayleaf while preserving exact PID, service-manager, invocation, and migration checks.The complete production-source delta is +543 lines. The new kernel/device owner and explicit installer contract require growth; the direct extension fallback, startup environment handoff, and its propagation/cache machinery are removed. Benchmark usage lives in
scripts/perf/team-shape-stress.md; the shared performance README is unchanged.Evidence
Reviewed head:
3b91424a444fa35773ef6168beb7dc77881daea4. Independent subagent review (autoreview route unavailable) is clean after the routing, cleanup, explicit opt-in, and delegated-service identity repairs.config/env-var-count-budget.txtunchanged.Linux x64 smoke and stated proof gap
Blacksmith Testbox
tbx_01m66ccqggh6g3pb1n2dpwfg1nhad 4 CPUs, about 16 GiB RAM, and systemd 255. Initial base and candidate builds passed. On thenonescheduler, real agent exec writers inheritedio.max: measured cgroup writes were approximately 6.2 MB/s under a 6,898,409 bytes/s per-direction ceiling. Gatewayio.maxremained empty. This is short placement/throttling evidence, not a latency comparison or proof of the final revision.The long comparison is missing: ten-minute counterbalanced base/candidate timing and allocation runs under disk-heavy agent exec have not completed. No SQLite commit-p99 or main-thread-stall improvement is claimed. Final seven-route Linux placement and real installer-to-Doctor repair also remain unverified on Linux. The maintainer accepts the stated long-comparison gap and will run the real host comparison after explicit delegation. A long x64 comparison can run if capacity is granted immediately; queued leases are stopped rather than awaited. No production host was modified or load-tested.
Inherited pagination failures
The maintainer authorized the inherited-failure exception after baseline proof. The unchanged main parent
cd963a2f16bbb9854596b0c8de8bd3a053419f67, run through both complete files withnode scripts/run-vitest.mjs src/gateway/server.chat.cli-history.test.ts src/gateway/server.chat.gateway-server-chat-b.test.ts --maxWorkers=1, produced 4 failed, 61 passed in 168.51 s:server.chat.gateway-server-chat-b.test.ts:chat.history backfills older offset pages across a dense silent gap(nextOffsetundefined instead of 1);chat.history centers a bounded page around a message id(hasMoretrue instead of omitted).server.chat.cli-history.test.ts:chat.history pages the full local prefix and external-only claude-cli rows;chat.history pages when every older claude-cli import duplicates a local row(bothhasMorefalse instead of true).These exactly match current-head CI run 41090495897, jobs 124184436259 and 124184436276. Upstream #188372 is already included in the executed baseline. CI tested merge
3b02afe24df18edf3586cd0db7d85cf09a927606, with main parent2eef065f0f89960d0aaebfc64647386715cc9abe. The response-page owner, cursor helper, and both failing tests are byte-identical between the executed baseline and that tested merge.Final CI and unrelated failures
Exact-head CI completed with 81 successful jobs, 25 skipped jobs, four failed test buckets, and the aggregate CI-gate failure. Build, lint, types, baseline ratchets, and all three PostgreSQL shards passed. Dependency and security-sensitive review checks passed; the independent review is clean and the four actionable review threads are resolved. Failed CI is not described as green. Landing uses the maintainer-authorized inherited/unrelated-failure exception.
Besides the pagination assertions above:
server.health-store-scheduling.test.ts, “registered Gateway health/status preserve separate resident snapshots while serving HTTP,” counted 11 resident selections instead of 12 while returning the correct payload. The complete two-case file passed five consecutive runs on the PR head and five on unchanged main parentcd963a2f16bbb9854596b0c8de8bd3a053419f67. The test and relevant health/summary/projection owners are unchanged through CI's actual main parent. Independent source review found that a background health collection can warm the shared cache between reset and spy attachment; the precise failing interleaving remains unproven. This meets the maintainer's five-run unrelated-flake rule, not a claim that the flake was fixed.server.plugin-reload-send-revocation.product.test.ts, “runs Bob's allowed and revoked retained sends in a prebound owned process,” andserver.plugin-reload-send-continuation.product.test.ts, “runs all three real reload continuations in a prebound owned process,” both timed out at 120,000 ms. Both exact signatures also occur on scheduled mainba6cfcd58df47a3037507362e45ed95757fae41c, run 41080670581, job 124149134806: 120,061 ms and 120,016 ms respectively. Local focused pairs also passed on both revisions; another head replay reproduced the continuation timeout. These replays are supplementary: the matching scheduled-main failures establish attribution. Baseline replay used CI's Node 24 launcher, head replay Node 26, and both used the pinned Bun test runtime; the actual CI main parent also includes newer continuation-fixture diagnostics/setup.Earlier config-readiness failed once and later passed; that prior failure remains unexplained, not claimed fixed. No CI reruns or dispatches were used to chase green.