Repository navigation
Conversation
Follow every thread descendant list and share reads within each sample instead of scanning every host PID. Preserve RSS-plus-swap accounting, migrated descendants, independent watcher deadlines, and cancellation. Remove the census crossover and timeout fallback.
|
🦞👀 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. |
|
Codex review: blocked before merge. What this changesThis PR replaces whole-host Linux memory scans with shared reads confined to watched command trees. Example: Forty watched command trees run alongside 3,000 unrelated sleep processes.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this maintainer-authored PR fixes a source-confirmed current-main inefficiency, with no discrete correctness findings; the author’s explicit performance hold remains unresolved. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe process supervisor supplies command roots and memory limits to the Linux watchdog, which reads procfs and requests tree termination with a diagnostic when RSS plus swap exceeds the limit. flowchart TD
A[Gateway exec command] --> B[Process supervisor]
B --> C[Shared sampling clock]
C --> D[Watched tree procfs reads]
D --> E[RSS plus swap accounting]
E --> F[Tree termination and diagnostic]
Technical reviewBest possible solution: Retain one ancestry-based accounting owner with tick-local sharing, preserving enforcement and cancellation while meeting the recorded performance acceptance rule. Do we have a high-confidence way to reproduce the issue? Current main demonstrably selects a whole-host /proc census at twenty watches; the body supplies a concrete 3,000-unrelated-process workload and reports an exact-parent failing regression, but this review ran no reproduction. Is this the best way to solve the issue? Reusing the existing all-thread ancestry walker removes unnecessary host work without changing the accounting boundary; the remaining question is whether the chosen sharing representation meets its performance criteria. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b31a8082cac3. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -61, Tests -8, Docs 0, Other +24. Total -45 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 November 2, 2026, 1:11 AM ET / 06:11 UTC. |
Share numeric memory totals and descendant PID arrays instead of retaining raw procfs buffers and thread directory lists. Preserve independent watches, early memory enforcement, and cancellation-safe shared discovery.
|
Merged via squash.
|
…190897) * fix(process): scope child memory scans to watched trees Follow every thread descendant list and share reads within each sample instead of scanning every host PID. Preserve RSS-plus-swap accounting, migrated descendants, independent watcher deadlines, and cancellation. Remove the census crossover and timeout fallback. * perf(process): retain parsed child-memory facts per tick Share numeric memory totals and descendant PID arrays instead of retaining raw procfs buffers and thread directory lists. Preserve independent watches, early memory enforcement, and cancellation-safe shared discovery.
What Problem This Solves
Linux memory monitoring scans every host PID once twenty command watches are active. The shared census in #189629 was calibrated on a 200-process host; on hosts with thousands of unrelated processes, its CPU and allocation scale with the host rather than the commands being monitored.
User Impact
Monitoring now follows only watched command trees. RSS-plus-swap bounds, worker-thread descendants, callback context, independent stalled watches and the one/five-second cadence remain intact. Descendants that migrate to another cgroup remain covered while their ancestry is intact. No configuration or migration is required.
Why This Change Was Made
Remove the whole-host forest, crossover thresholds, hysteresis and census timeout/fallback. Share parsed memory totals and child PID arrays within one tick; each watcher retains its own visited set and total, and the next tick reads fresh kernel facts. Production code shrinks by 48 lines.
Cgroup membership alone loses migrated descendants. Per-command memory.max would change RSS-plus-swap accounting and require restructuring the populated agent-exec hierarchy. Keeping the ancestry owner preserves the existing enforcement contract.
Evidence
Synthetic Linux x64, Node 26.12.1; measured two CPUs, 7.65 GiB RAM. One fixed forest contains 40 roots with four worker-thread-spawned children each, plus 3,000 unrelated sleep processes (~3,350 visible processes). Five serial interleaved original/candidate pairs per watcher count; dense 30 s warmup + 30 s capture, quiet 10 + 30 s. Values are median [minimum, maximum]; with five samples, empirical nearest-rank p95 is the maximum, not a robust population-tail estimate. V8 allocation includes collected objects but excludes external Buffer storage.
Baseline A/A controls:
Accepted tradeoffs: one-watch median main CPU rises 37.028→47.700 ms/min (+10.672 ms/min), with effectively flat allocation and loop p99. At forty watches, total GC rises 8.608→10.366 ms/min (+20.4%); median maximum GC pause rises 0.303→0.440 ms, and the largest observation is 0.639→1.912 ms. I accept these measured costs for the repeatable loaded-work reduction: forty-watch total CPU falls by 418.470 ms/min, allocation by 18.390 MB/min, and old-space by 6.764→5.163 MB. The loop monitor has 20 ms resolution and cannot rule out smaller latency costs. This is not an all-metrics-improve claim.
An earlier complete local Linux arm64 VM series remains an adverse qualification result: forty-watch median loop p99 30.818→38.470 ms and median window maximum 43.876→99.877 ms; twenty-watch median maximum GC pause 2.032→3.501 ms. Later local pairs were steadier, but load observations do not prove the cause. I retain that uncertainty rather than dismissing it as noise; the controlled Linux result supports this scoped landing, not a universal tail-neutrality claim.
Separate ten-second work-count probe (instrumented, not timing evidence): filesystem callback jobs 6,694→3,520; directory jobs 2→400; promises 13,746→10,968; timer creations 5→81. Task-directory reads are needed for every-thread ancestry and timer rearming increases as walks settle independently; these costs are included in total CPU/allocation above. The regression test proves zero unrelated-host PID reads. Overlapping trees share each PID observation and count descendants once within each command's total.
Separate collected-object allocation profile attributes 65.771→40.045 MB/min to owner stacks. CPU profiles show sampled inclusive owner time 39.145→8.985 ms over the 20-second startup/warmup/capture profile; this supports attribution and is not the timing table. The first raw-buffer-sharing candidate was rejected for retained old-space and major GC; the final implementation retains parsed facts only.
Real Linux worst-phase runaway with twenty overlapping observers: 5.008→5.009 s from burst to SIGKILL, after forest cleanup. Separate cgroup-migration proof moves both worker children outside the parent cgroup: original 5.099 s, final 5.011 s, correct memory-limit diagnostic and six-second deadline. No fake clocks.
50 child-memory/supervisor tests pass; the new owned-only and overlap-sharing regressions fail against the exact parent (2 failures, 9 passes). Exec-runtime caller tests: 36 pass, two Linux broker cases skipped on macOS. Final pnpm check:changed passes. Fresh Codex autoreview of the full diff and owner/caller: scoped-clean P0–P2. Exact reviewed head 4ebc0ee has GREEN native CI-watcher result for run 41399986835, excluding ten superseded checks.
Rerun with the committed fixture and measurement scripts: start
node scripts/perf/child-memory-fixture.cjs forest 40 4 <roots.json> 3000; bundle the original owner at 52c1064 and this head with the same esbuild settings, then runchild-memory-measure.ts --owner <bundle> --roots <roots.json> --trees 40 --watched 1|20|40 --descendants 4 --warmup-seconds 30 --seconds 30 --output <json>serially, using 10 s quiet warmup. Run--work-countsand--allocationsseparately;--cpu-profcaptures attribution. Usechild-memory-adaptive-runaway.ts --owner <bundle> --observers 20 --descendant-cgroup <private fixture cgroup> --output <json>for the migration proof.No live deployment or production data was used. Database/workspace size does not participate in this owner. No Control UI import boundary changed; no full-Gateway throughput is claimed.