Skip to content

perf(process): sample quiet exec trees less frequently - #182452

Merged
steipete merged 7 commits into
mainfrom
steipete/perf-micro-exec-memory-sampler-alloc-20260919
Oct 24, 2026
Merged

steipete merged 7 commits into
mainfrom
steipete/perf-micro-exec-memory-sampler-alloc-20260919

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Decision: land under v5.6

Reopened for landing under the lead’s v5.6 decision. This is the requested interval-only follow-up to #182234. Allocation falls 78% and CPU 72%; GC +2.7 ms/min absolute = context under v5.6. Phase-aligned runaway proof passed: worst observed kill latency 5.031 seconds across three trials. The rebased head is landing under the standing unrelated-flake exception: the single failed CI file passed five Linux replays on both baseline and head, and its failing path cannot reach the changed watcher. CI is not claimed green.

What Problem This Solves

The existing Linux exec watchdog scans every thread and descendant in every command tree each second. The motivating pre-change live signal was 79.68 MiB allocated over 30 seconds in this path.

The proposed change retains the original independent per-tree watcher, reader, parser, Linux-only behavior, RSS plus private swap, all-thread descendant discovery, and visible memory-limit failure. After a completed sample below half the cap, an unchanged tree waits five seconds; newly discovered descendants or usage at/above half the cap restore one second. Errors retry after one second. No shared tick, Buffer reuse, new production reader, configuration, or cache.

Runtime production delta: +9 lines (17 added, 8 removed). The retained PID set is needed to detect new descendants. Separately, regression tests add 75 lines and reproducible measurement/proof scripts add 459 lines.

This explicitly accepts approximately six-second detection/kill latency for a fast runaway from a previously quiet tree. The real-procfs phase-aligned proof passed all three trials below; the worst observed kill latency was 5.031 seconds, within the accepted approximately six-second bound, including sampling overhead. This is a sampled watchdog, not a hard real-time deadline under arbitrary host stalls.

Measurement

Original measurement head: 8dbc029534f28d7750cfa2fd70cfd34df1c53227. Runtime source SHA-256: ef71af869b5d1834053117139e924ce256b0033c55b0d68219109320c7f12a21. Baseline source SHA-256: 8bf757074b77b4748d728a1b82fcd7e095fabbb053479df9af08314e8c77cda3, identical to the four preserved controls.

Same committed workload and helper bytes, Node 26.12.1 and dependencies, prepared synthetic fixtures, 20 watched trees with two worker-thread-spawned descendants each, five-second warmup, synchronized future start, 60-second captures, counterbalanced launch order, swapped interleaved CPUs in one exclusive slot. Guard unchanged; low CPU/IO priority; MemoryMax 24G and MemorySwapMax 0. Allocation sampling, untraced timing, and traced promotion use separate passes.

The original v5.4 acceptance rule was recorded before any new result: reject at >=20% adverse paired mean or >=10% in both pairs; a mixed-sign/unstable metric gets one predeclared extra pair and a signed absolute mean decision against 20% of mean baseline cost. GC/promotion/max-pause rejection requires matched same-mode controls. No trimming, after-the-fact maintenance exclusions, or normalization by major-cycle count.

Metric Baseline mean Candidate mean Absolute delta Mean paired delta Pooled delta
Sampled heap allocation (MiB/s; 2 pairs) 1.23851 0.269642 -0.968871 -78.23% -78.23%
Sampler-attributed allocation (MiB/s; 2 pairs) 0.96405 0.204492 -0.759558 -78.79% -78.79%
Untraced CPU (ms/60 s; original 2 pairs) 630.74 176.525 -454.215 -72.03% -72.01%
Untraced total GC (ms/1,200 tree-seconds; all 3 pairs) 5.93233 8.63355 +2.70122 +42.63% +45.53%
Untraced loop p99 (ms; original 2 pairs) 20.7831 20.7094 -0.073728 -0.35% -0.35%
Traced promotion (bytes/60 s; 2 pairs) 4.17156e+06 2.07767e+06 -2.09389e+06 -50.16% -50.19%

GC decision: original pairs were 5.39174→4.75683 ms (−11.78%) and 6.14154→6.65344 ms (+8.33%). Their mixed signs triggered the predeclared third pair: 6.26371→14.49040 ms (+131.34%). The three-pair signed absolute mean is +2.70122 ms/60 s, or +45.53% of the 5.93233 ms baseline mean. The lead subsequently classified this absolute increase as context under v5.6, reversing the initial rejection. The third candidate capture includes a 9.00921 ms incremental GC, retained in full. No untraced max-pause safeguard tripped. GC +2.7 ms/min absolute = context under v5.6: compared with the lead-reported production main-isolate GC of 1,000–3,000 ms/min, this is approximately 0.09–0.27% (order 0.1%). All observations remain reported unchanged.

Stable allocation/CPU/loop/promotion metrics retain their original two-pair decisions. Third-pair CPU was 1,255.175→176.296 ms and is retained as context, rather than changing the original CPU comparison.

Untraced post-capture 20-tree runaway request-to-root-exit times were baseline 122 / 1,023 / 1,011 ms, candidate 4,076 / 4,002 / 5,032 ms; all emitted the visible memory-limit diagnostic. These are three observations per side, not tail percentiles or phase-aligned worst-case proof.

Phase-aligned runaway proof

On the rebased source, a real tree with two worker-thread-spawned descendants began at approximately 202.5 MiB RSS plus swap, below half its synthetic 768 MiB cap. A leaf started with zero burst allocation, then touched a 768 MiB Buffer immediately after the watcher armed its real five-second timer. The proof observes and forwards timers unchanged; no fake clock or watcher override is used. Independent procfs observation verifies cap crossing, and the watcher’s ordinary limit callback kills the process group.

Trial Timer arm → burst Burst → over cap Burst → SIGKILL/root exit
1 2 ms 141 ms 5,031 ms
2 2 ms 123 ms 5,031 ms
3 2 ms 124 ms 5,028 ms

All trials emitted Command killed for exceeding its host memory bound, observed approximately 905 MiB at enforcement, and exited with SIGKILL. Worst observed latency: 5.031 seconds; accepted bound: approximately six seconds. These are three phase-aligned observations, not tail percentiles. The synthetic cap avoids allocating the approximately 45 GiB production cap while exercising the same interval and protection path. Guarded exclusive slot B, interleaved CPUs, Node 26.12.1, MemoryMax 24G, MemorySwapMax 0; no guard interruptions or exclusions.

Reproduction: node scripts/perf/child-memory-adaptive-runaway.ts --owner <compiled-child-memory-module> --output <result.json> on Linux. The measured module was generated from the unchanged committed TypeScript with Node’s stripTypeScriptTypes; source SHA-256 is recorded above.

Retained traced context: trace pair 1 recorded GC maxima of 7,469.05→6,615.30 ms (baseline/candidate) and totals of 7,498.83→6,621.04 ms. Both captures remain included; the guard did not abort. Traced timing is ineligible for the GC/max-pause gate under the predeclared rule. Promotion improved in both traced pairs (−53.14%, −47.18%), so no promotion-rejection calibration was needed.

Calibration and complete observations

Four same-workload untraced A/A controls were explicitly reused before new candidate results. Source, helper/fixture/benchmark bytes, runtime/dependencies, warmup, start barrier, duration, CPU placement/launch-order protocol, scopes and guard match. Their two swapped-block GC means were +14.67% and +10.16%; neither reached 20% mean or 10% adverse in both constituent pairs. No max-pause safeguard tripped. The original calibrated relative increase remains reported; v5.6 classifies its absolute cost as context.

A/A pair GC baseline→control (ms) Absolute delta Relative delta GC maxima baseline→control (ms)
1 10.8219 → 13.4023 +2.5804 ms +23.84% 1.6798 → 1.9849
2 5.2835 → 5.5740 +0.2904 ms +5.50% 0.6337 → 0.5866
3 5.6824 → 5.7076 +0.0252 ms +0.44% 0.6590 → 0.5501
4 5.7361 → 6.8766 +1.1405 ms +19.88% 0.6200 → 1.2815
Every capture: per-kind GC, tail sample counts, both maxima, and CPU

GC-kind cells are count / total ms / p95 ms / p99 ms; incremental cells are count / total ms / max ms. All GC tail counts are below 200, so those percentiles are context. Major counts are also below 50. Loop p99 counts are shown next to each value and exceed 1,000. Only untraced timing gates.

Capture/side CPU ms Total GC n/ms Minor GC n/total/p95/p99 Major GC n/total/p95/p99 Incremental n/total/max Max GC ms Loop p99 ms (n) Max loop ms
alloc1/baseline 748.876 67/24.0274 61/13.4958/0.8940/0.9940 3/9.8921/7.6140/7.6140 3/0.6396/0.2524 7.5827 21.512191 (2969) 52.985855
alloc1/candidate 219.359 24/9.8048 18/5.7415/0.4400/0.5980 3/3.3768/1.6140/1.6140 3/0.6864/0.2569 1.6094 21.151743 (2969) 36.143103
alloc2/baseline 675.269 65/14.5118 59/9.6922/0.3660/0.4660 3/4.2566/2.9420/2.9420 3/0.5630/0.2185 2.9296 20.774911 (2983) 21.676031
alloc2/candidate 183.310 23/8.5652 19/4.9781/0.4000/0.4040 2/3.1792/1.6220/1.6220 2/0.4079/0.2149 1.6212 20.643839 (2983) 21.463039
plain1/baseline 612.880 17/5.3917 15/4.6394/0.5460/0.5780 1/0.5884/0.5900/0.5900 1/0.1639/0.1639 0.5884 20.774911 (2984) 20.955135
plain1/candidate 168.475 20/4.7568 18/4.0976/0.3660/0.4040 1/0.4791/0.4800/0.4800 1/0.1801/0.1801 0.4791 20.709375 (2982) 20.922367
plain2/baseline 648.599 17/6.1415 15/5.4272/0.6820/0.6900 1/0.5546/0.5580/0.5580 1/0.1597/0.1597 0.6880 20.791295 (2985) 20.971519
plain2/candidate 184.575 21/6.6534 19/5.2838/0.3400/0.3680 1/1.0980/1.1020/1.1020 1/0.2717/0.2717 1.0980 20.709375 (2982) 21.233663
plain3/baseline 1255.175 17/6.2637 15/5.5373/0.5980/0.6660 1/0.5574/0.5580/0.5580 1/0.1690/0.1690 0.6627 20.824063 (2951) 386.400255
plain3/candidate 176.296 21/14.4904 19/4.7067/0.3380/0.4640 1/0.7745/0.7780/0.7780 1/9.0092/9.0092 9.0092 20.725759 (2981) 27.738111
trace1/baseline 455.858 44/7498.8274 42/7497.6432/2.3820/7471.1020 1/1.0162/1.0180/1.0180 1/0.1680/0.1680 7469.0504 20.692991 (2612) 7478.444031
trace1/candidate 112.061 17/6621.0399 17/6621.0399/0.5180/6619.1340 0/0.0000/0.0000/0.0000 0/0.0000/0.0000 6615.2982 20.529151 (2654) 6627.000319
trace2/baseline 784.471 18/6.8296 16/5.8947/0.4860/0.5540 1/0.7686/0.7700/0.7700 1/0.1663/0.1663 0.7686 20.807679 (2986) 20.971519
trace2/candidate 211.571 21/8.1711 21/8.1711/0.5500/0.7460 0/0.0000/0.0000/0.0000 0/0.0000/0.0000 0.7459 20.758527 (2984) 20.938751
AA1/baseline 644.433 17/10.8219 15/9.7293/1.3740/1.6860 1/0.8261/0.8260/0.8260 1/0.2664/0.2664 1.6798 21.839871 (2950) 95.682559
AA1/control 686.271 17/13.4023 15/11.7714/1.7580/1.9900 1/1.4612/1.4620/1.4620 1/0.1697/0.1697 1.9849 21.757951 (2958) 55.246847
AA2/baseline 623.041 17/5.2835 15/4.6843/0.4860/0.6340 1/0.4362/0.4360/0.4360 1/0.1631/0.1631 0.6337 21.168127 (2980) 27.623423
AA2/control 614.306 17/5.5740 15/4.9338/0.5420/0.5900 1/0.4519/0.4520/0.4520 1/0.1883/0.1883 0.5866 21.053439 (2983) 23.068671
AA3/baseline 643.445 17/5.6824 15/4.8801/0.5980/0.6620 1/0.6135/0.6140/0.6140 1/0.1888/0.1888 0.6590 20.774911 (2983) 21.643263
AA3/control 656.581 17/5.7076 15/5.1360/0.5380/0.5500 1/0.4144/0.4140/0.4140 1/0.1572/0.1572 0.5501 20.807679 (2983) 22.839295
AA4/baseline 640.178 17/5.7361 15/5.1622/0.6100/0.6220 1/0.4182/0.4180/0.4180 1/0.1558/0.1558 0.6200 20.758527 (2984) 23.101439
AA4/control 633.470 17/6.8766 15/6.2076/0.5860/1.2860 1/0.5208/0.5220/0.5220 1/0.1483/0.1483 1.2815 20.758527 (2984) 21.872639

All seven completed pairs are valid and retained, including four full allocation profiles. No capture was guard-aborted, trimmed, or excluded. One earlier setup attempt failed before fixture readiness/capture because the restored diagnostics import closure was incomplete. Its logs are preserved separately; the complete capsule passed import-only preflight before retry. No capture overlaps the predeclared production-restart exclusion window.

Evidence

43/43 focused sampler/supervisor tests and 22/22 source-closure tests passed. The adaptive regression cases failed on the original source at their intended quiet-cadence assertions. Process tests took 0.411 s; closure tests 51.70 s; combined wrapper 54.47 s. Core typecheck, changed-file lint/format, export-collision and diff checks passed.

Exact-head CI and aggregate PR gates passed on 8dbc029534f28d7750cfa2fd70cfd34df1c53227. Independent subagent review (autoreview route unavailable) is clean after correcting two type issues. The configured helper refused its provider selector at startup; no provider configuration was changed. The prior review remains applicable because the rebase changed none of the six PR files. Current rebased head: 6a2caa039412cf580b5f7aaf6931d9c0dd91c871; Rebased exact-head CI completed with one failing test file: src/agents/bash-tools.exec-launch-policy.integration.test.ts, two authority-retirement cases reporting service child cleanup identity lost: write EPIPE. This is classified as an unrelated relay-cleanup flake under the standing five-pass rule; see evidence below. All other selected test, lint, type and source-closure jobs passed; PR-context headings were corrected and its check now passes.

Exact-head CI exception and attribution

CI run 40082138260, head 6a2caa039412cf580b5f7aaf6931d9c0dd91c871, has one actual failing job: checks-node-changed-3. Its two failing cases are still rejects retired source authority after native launch with PTY=false, retained false/true, in src/agents/bash-tools.exec-launch-policy.integration.test.ts. Both report service child cleanup identity lost: write EPIPE; the aggregate CI gate fails downstream. All other selected jobs passed. Exact-head CI is red; landing uses the explicitly authorized unrelated-flake exception, not a green-CI claim.

The single failing file was replayed on Linux with the unchanged baseline sampler and this PR’s sampler, identical other source/dependencies, pinned Bun 1.4.4-canary.1+ef37c31de, one worker. Both sides passed 5/5 runs, 11/11 tests each (55/55 each), all exit code 0. Baseline wrapper durations: 68.00/39.27/33.66/34.80/35.22 seconds; head: 77.38/43.49/65.20/58.39/48.34 seconds. Node launcher was 26.12.1 versus CI’s 24.22.1; the Bun test runtime was the same. Baseline source hash 8bf75707… and head ef71af86… match the measured sources. No CI rerun was requested.

Command: OPENCLAW_VITEST_RUNTIME=bun OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/agents/bash-tools.exec-launch-policy.integration.test.ts --maxWorkers=1.

Causal source check: source-authority revocation rejects readiness at service-child-relay-host.ts:643; its catch stops the owner and rethrows. supervisor.ts:555–561 propagates that rejection before watchChildMemory at line 604. Therefore no changed watcher code executes in either failing case. CI’s EPIPE is emitted by the unchanged lineage-close notification at service-child-relay-host.ts:299. These files and the failing test are unchanged between the rebased main parent 62ef3ab149c8 and this PR; the comparison holds every other input fixed while replacing only the sampler with its baseline version. Passing replays establish the permitted flake attribution, not a repair of that cleanup race.

The previous independent review remains clean because all six PR files are byte-identical after the requested rebase. The native workflow preflight targets a new worktree in the shared checkout, prohibited by this lane’s isolation/compute rules; the authorized fallback is a squash merge pinned to the exact reviewed 40-character head.

No production deployment or live-after profile was performed. The 79.68 MiB/30 s live signal is pre-change only. Benchmark allocation is sampled V8 heap, excluding external Buffer storage; full-Gateway effects were not measured. Phase-aligned proof now passes on the byte-identical rebased sampler. No production deployment was needed.

Related: #182111, #182163, #182234.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T09:31:13.252696Z 6a2caa0 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: L labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR samples quiet Linux exec process trees every five seconds, returning to one-second sampling after discovering descendants or observing higher memory usage.

Example: A Linux command tree uses 192 MiB against a 768 MiB memory bound.

  • Before: The watchdog scans the tree every second regardless of its low usage.
  • After: Stable low usage permits five-second intervals; usage reaching 384 MiB or discovery of another descendant restores one-second intervals.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is focused and source review found no actionable defect, but this version's declared performance and runaway acceptance results are still pending.
Proof confidence 🦪 silver shellfish (2/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR, but its own landing criteria remain unfulfilled: the complete discussion supplies no adaptive-head allocation/CPU/GC results or phase-aligned runaway output, and the earlier implementation's measurements do not transfer to this source.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Concurrent Linux host commands make the Gateway repeatedly scan quiet process trees and allocate temporary procfs-reading data.
Reason: The maintainer-authored direction targets verified repeated work with a narrow implementation and explicitly accepts the slower-detection tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored optimization addresses a verified source of repeated work, and the pinned diff introduces no discrete correctness defect.

Priority: P2
Reviewed head: 8dbc029534f28d7750cfa2fd70cfd34df1c53227

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The declared adaptive-head performance comparison and real-procfs runaway result immediately after a quiet sample remain pending.
Agent review details

How this fits together

The process supervisor supplies an owned command-tree root and memory bound to the watchdog; Linux procfs supplies descendant identities, RSS, and swap, and an over-limit sample requests existing supervisor cancellation.

flowchart TD
  A[Gateway exec] --> B[Process supervisor]
  B --> C[Per-tree memory watchdog]
  D[Linux procfs] --> C
  C --> E[Adaptive sampling interval]
  E --> C
  C --> F[Supervisor cancellation and diagnostic]
Loading

Technical review

Best possible solution:

Keep adaptive scheduling inside the existing per-tree watchdog, preserving its accounting, independent cancellation, and documented sampled-protection limits.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes a fresh procfs traversal after each one-second timer for every watched tree; this read-only review did not independently reproduce the reported allocation magnitude.

Is this the best way to solve the issue?

The smallest complete change is to reuse the reader's existing PID set and select the next interval in the existing watcher, which this diff does without a shared scheduler, parser replacement, or competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d5872069d833.

Provenance checked

  • Procfs accounting and watchdog scheduling changes intended behavior with a stated reason (2d8051e: Protect Linux host command trees from runaway resident and swapped memory with sampled monitoring and existing supervisor cancellation.)
  • Host memory budget and diagnostic contract keeps the original intent (377c0fc: Allow legitimate larger commands on large hosts by removing the fixed ceiling while retaining scaled bounds and visible applied-limit diagnostics.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +9, Tests +75, Docs 0, Other +459. Total +543 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 17 8 +9
Tests 1 75 0 +75
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 459 0 +459
Total 6 552 9 +543

Review metrics

Metric Value Why it matters
Production versus test LOC Production +9 net; tests +75 net Production growth carries the reader's existing PID set into cadence selection; tests cover threshold and descendant transitions, read-error retry, and cancellation during an awaited read.

Root-cause cluster

Relationship: canonical
Canonical: #182452
Summary: This PR owns the requested interval-only follow-up for repeated watchdog scanning after the earlier allocation-focused implementation was rejected.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: This is a bounded Linux watchdog overhead improvement without evidence of an urgent user-facing regression.
  • add merge-risk: 🚨 availability: A command that becomes a runaway immediately after a quiet sample receives slower protection; the maintainer-authored body explicitly accepts approximately six-second detection rather than the previous one-second cadence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This is a bounded Linux watchdog overhead improvement without evidence of an urgent user-facing regression.
  • merge-risk: 🚨 availability: A command that becomes a runaway immediately after a quiet sample receives slower protection; the maintainer-authored body explicitly accepts approximately six-second detection rather than the previous one-second cadence.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Publish the declared adaptive-head paired measurements and phase-aligned runaway output, retaining all samples and applying the predeclared rejection criteria.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 5:07 AM ET / 09:07 UTC.

@steipete steipete closed this Oct 24, 2026
@steipete steipete reopened this Oct 24, 2026
Keep RSS plus private swap, all-thread descendants, and visible memory-limit termination. Share a nonoverlapping sampler and parse procfs numbers without per-file scratch buffers or strings.
Parse procfs Buffers without decoded strings or regex allocations. Keep one shared sampler detached from execution async context. FileHandle promise I/O increased sampled allocation by 218%, so retain the native readFile round trip.
Keep one nonoverlapping shared tick while allowing per-read Buffer owners to progress independently. Preserve cancellation and independent memory limits when another tree read is blocked.
Keep independent per-tree readers and timers. Sample stable trees below half their RSS-plus-swap cap every five seconds, returning to one second for newly discovered descendants, higher usage, or read errors. This explicitly accepts approximately six-second fast-runaway detection from a quiet tree; measurements gate landing.
@steipete
steipete force-pushed the steipete/perf-micro-exec-memory-sampler-alloc-20260919 branch from 8dbc029 to 6a2caa0 Compare October 24, 2026 09:29
@steipete
steipete merged commit a450743 into main Oct 24, 2026
157 of 163 checks passed
@steipete
steipete deleted the steipete/perf-micro-exec-memory-sampler-alloc-20260919 branch October 24, 2026 10:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged under the requested v5.6 decision and the standing unrelated-flake exception, pinned to reviewed head 6a2caa039412cf580b5f7aaf6931d9c0dd91c871.

Allocation fell 78% and CPU 72%; GC +2.7 ms/min absolute = context under v5.6. Three real phase-aligned runaway trials crossed the synthetic cap within 123–141 ms and exited via SIGKILL in 5.028–5.031 s. Worst observed kill latency: 5.031 s, within the accepted approximately six-second bound.

Exact-head CI run 40082138260 remains red only for src/agents/bash-tools.exec-launch-policy.integration.test.ts (two retired-authority cases, relay cleanup write EPIPE) and its aggregate gate. Both baseline and head passed five Linux/Bun replays, 11/11 tests each, all exit 0. Source inspection confirms startup rejection precedes watchChildMemory, so the changed watcher is outside the failing path. The full command, runtime difference, durations and causal evidence are in the PR body. No CI reruns were used to chase green.

Merge commit: a450743619d89ea899e4bcc1a93e375bed481674. The isolated sandbox is removed, no owned processes remain, and shared dependencies and production were left intact. No deployment was performed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
* perf(exec): reuse procfs storage across memory watches

Keep RSS plus private swap, all-thread descendants, and visible memory-limit termination. Share a nonoverlapping sampler and parse procfs numbers without per-file scratch buffers or strings.

* test(exec): time runaway kills from allocation request

* perf(process): preserve native procfs read fast path

Parse procfs Buffers without decoded strings or regex allocations. Keep one shared sampler detached from execution async context. FileHandle promise I/O increased sampled allocation by 218%, so retain the native readFile round trip.

* perf(process): parse procfs bytes without an async wrapper

* perf(process): sample independent exec trees concurrently

Keep one nonoverlapping shared tick while allowing per-read Buffer owners to progress independently. Preserve cancellation and independent memory limits when another tree read is blocked.

* perf(process): sample quiet exec trees less frequently

Keep independent per-tree readers and timers. Sample stable trees below half their RSS-plus-swap cap every five seconds, returning to one second for newly discovered descendants, higher usage, or read errors. This explicitly accepts approximately six-second fast-runaway detection from a quiet tree; measurements gate landing.

* test(process): prove adaptive sampler runaway latency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant