Repository navigation
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR shares one procfs sampler and reusable buffer across Linux command memory watches. Example: A Linux Gateway monitors 20 concurrent command trees.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed optimization addresses repeated allocation in the existing watchdog, and source review found no discrete introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe process supervisor registers owned command trees with the memory watchdog; procfs supplies resident memory, swap, and descendants, and over-budget samples request existing tree cancellation. flowchart TD
A[Host exec command] --> B[Process supervisor]
B --> C[Shared memory sampler]
D[Linux procfs] --> C
C --> E[Per-command budget check]
E --> B
B --> F[Tree cancellation and diagnostic]
Technical reviewBest possible solution: Retain the existing watchdog owner and merge the shared-buffer implementation only after its declared performance and reliability criteria hold. Do we have a high-confidence way to reproduce the issue? Current-main source establishes per-tree timers and repeated readFile, regex, and string-split allocation; the magnitude of the performance cost has not been demonstrated. Is this the best way to solve the issue? Sharing storage inside the existing watchdog is coherent, preserves its callers and accounting contract, and removes the replaced implementation without adding a competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bff1d869fcef. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +72, Tests +128, Other +281. Total +481 across 5 files. Added test files: 0. View PR surface stats
Review metrics
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 October 24, 2026, 1:10 AM ET / 05:10 UTC. |
1746a9b to
ae24a23
Compare
ae24a23 to
a7f9866
Compare
a7f9866 to
5976d13
Compare
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.
5976d13 to
624230a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 624230a479
ℹ️ 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".
| await Promise.all( | ||
| Array.from(watches, async (watch) => { |
There was a problem hiding this comment.
Keep slow tree scans from delaying other memory watches
On Linux, a command with a large process/thread tree or slow procfs reads now delays subsequent memory checks for every other command: Promise.all must finish before the shared timer is rearmed, and watches registered meanwhile cannot start sampling either. The new blocked-read test demonstrates this gap by expecting no further reads for five seconds, even after the slow watch is stopped. Previously, unrelated watches continued sampling independently. A different command that grows past its budget during this gap can exhaust host memory before protection runs. Keep the shared timer, but track in-flight scans per watch so one slow tree cannot suspend protection globally.
AGENTS.md reference: AGENTS.md:L68-L68
Useful? React with 👍 / 👎.
|
Closing without merging under the predeclared v5.4 gate. The final candidate lowered sampled allocation 23.25% and untraced CPU about 20%, but total GC increased from 6.111 to 13.303 ms per 60-second/20-tree window (+7.192 ms; +117.68% pooled), with both swapped pairs adverse. Four matched untraced A/A controls stayed below the paired gates; their provenance was fixed before reading this candidate's untraced results. Promotion was also higher, but was not the calibrated rejection basis. The earlier GC-neutral serialized variant is not a safe fallback: its independent-tree regression fails because one pending procfs read delays another tree's memory-limit notification. The final concurrent source passes all 44 focused tests and exact-head CI, but those checks do not waive the measured GC rejection. The PR body contains absolute/relative results, collection and tail counts, both maxima, control calibration, prior variants, and proof limitations. All 36 completed pairs are retained; no capture was trimmed or guard-excluded. No production deployment occurred. Proposed production delta was +56 lines; none is landing. Remaining experiments were stopped, and the isolated sandbox is being removed after evidence export. |
Decision
Measurement says skip: do not merge. The final concurrent candidate reduces sampled V8 allocation and CPU, but fails the predeclared total-GC/work gate after four matched untraced A/A controls. No production deployment was performed.
Final tested head:
624230a47907f902720785ec395b592907d0c0e6; sampler source SHA-256963aefe71bc2f696fee6d5f6cbf7cc767e9270b4700a6663d0e84b97d254276a.Workload and acceptance
Real Linux procfs, 20 independent execution trees, each with two worker-thread-spawned descendants. Prepared fixtures, five-second warmup, synchronized future start, counterbalanced launch order, and two swapped pairs of interleaved CPUs per mode. Each measured side ran for 60 seconds: 1,200 protected tree-seconds. Node 26.12.1; separate allocation, untraced, and traced-promotion modes. Shared slot/guard, low CPU/IO weights, MemoryMax 24G and MemorySwapMax 0 throughout.
The committed driver is
scripts/perf/child-memory-measure.ts, invoked with--owner <immutable-baseline-or-candidate-module> --trees 20 --seconds 60 --start-file <shared-barrier> --output <side-result> --runaway. Allocation adds--allocations; promotion uses--expose-gc --trace-gc-nvpand--gc-log. Plain runs use neither. Source snapshots were native-stripped with identical module topology; the baseline source hash8bf757074b77b4748d728a1b82fcd7e095fabbb053479df9af08314e8c77cda3matched main at the final rebase.Predeclared v5.4 rules: reject an eligible metric at ≥20% adverse paired mean or ≥10% in both pairs; mixed-sign or >5× baselines get one extra pair and a signed-absolute-mean decision. Untraced GC/work, loop, and max-pause gates; promotion has a separate traced baseline. p99 requires 1,000 samples, p95 200; major-GC tails are context below 50 collections. Per-pause changes below 1 ms are context. Max-pause safeguard is candidate >max(50 ms, 2× baseline). GC/promotion/max-pause rejection requires four matched same-mode A/A controls; noisy controls require a longer fixed-work protocol and fresh controls. No trimming, maintenance exclusions, or normalization by collection count.
Final candidate results
Means below are over two matched pairs per mode. Percentages show both the mean paired change and the ratio of aggregate means. Allocation is sampled V8 heap allocation, not external Buffer storage or full-Gateway allocation.
Untraced GC rose 106.02% and 129.49% in the individual pairs: both exceed the 10% adverse rule, and the paired mean exceeds 20%. Its absolute mean increase is 7.19 ms per minute at this workload. That small absolute cost does not waive the specified total-GC gate.
Untraced runaway request-to-root-exit observations, including page touching: baseline 97 / 1,043 ms, candidate 289 / 294 ms. Each side still had all 20 trees watched and emitted the visible memory-bound diagnostic. These are two observations per side, not a p95/p99 claim.
Promotion rose 22.84% and 30.79%, but promotion is not the calibrated rejection basis. Two traced A/A controls had already started when the GC rejection was issued; both completed and were retained (4,131,680→4,138,664 bytes and 4,115,608→4,121,288 bytes). The remaining two traced controls and final-head functional probe were not run after rejection.
Matched untraced calibration
The four immediately preceding baseline/baseline controls used the same immutable baseline, benchmark and fixture bytes, Node/dependencies, 20-tree workload, 60-second duration, warmup, start barrier, instrumentation, slot, swapped CPUs, launch order, scopes, and guard. Reuse was explicitly recorded before any concurrent-candidate untraced result was read. All four controls are retained, assessed as two swapped blocks.
Block 1's paired GC mean was +14.67% (+1.4354 ms absolute); block 2 was +10.16% (+0.58285 ms). Neither reaches 20%, neither is ≥10% in both of its constituent pairs, and no max-pause safeguard trips. Every control side had 17 collections. Thus these controls do not invalidate the candidate's much larger GC rejection signal; no lengthened protocol was required.
Per-kind GC, tail counts, both maxima, and untraced control diagnostics
Each GC cell is
count / total ms / p95 ms / p99 ms. All GC percentile counts below 200 are context; major counts are also below 50. Loop p99 sample counts are shown directly beside the value. Allocation/traced timing is context only; only plain candidate/control timing gates.Earlier variants and correctness
readFileround trip and was discarded.The tested final change used one detached, nonoverlapping shared tick, concurrent independent tree traversal, and synchronous byte parsing while retaining all-thread descendant discovery, RSS plus private swap, per-execution budgets, cancellation checks, and the one-second timer delay. A five-second adaptive interval was omitted because a previously low-memory tree can become a runaway immediately. No config, cache, native dependency, or heap-tuning workaround was added.
Proposed diff against main: +56 production lines (100 added / 44 removed), +106 test lines, +282 benchmark lines. None is landing. The production growth carries the byte parser and shared watch lifecycle; the older timer/string/regex/split path is replaced rather than retained alongside it.
Validation, CI, and gaps
44/44 focused sampler/supervisor tests passed (Vitest 4.08 s; wrapper 7.22 s); changed-file formatting/lint and independent review were clean. The independent-tree test was then run against the earlier serialized source and failed at the expected missing limit callback; the final source was restored byte-for-byte and the checkout is clean. The original shared-timer regression also failed on the original per-tree timer implementation. Earlier targeted core typecheck and export/source-closure checks passed; no broad local suites or Testbox leases were used.
Independent subagent review was used under the authorized fallback because the configured autoreview route refused startup; no model/provider configuration was changed.
An earlier raw-Buffer revision passed a real Linux supervisor probe:
memory-limit,SIGKILL, visible 1,002 MiB observed / 512 MiB limit diagnostic, and all three captured process IDs absent after owned cleanup. This is earlier-revision evidence, not a final-head functional pass; the final-head probe was stopped after the calibrated performance rejection.CI run 40075997403 on the preceding synchronous-parser head failed the Linux/Bun launch-authority test with
service child cleanup identity lost: write EPIPE. Scheduled main shows the same file/failure signature and stack on byte-identical test, relay, control sender, and supervisor files. Main's failing parameterization wasretained=true; the PR's wasretained=false. Both fail during construction before memory-watch registration. This is recorded as pre-existing same-signature evidence with the parameter difference preserved, not a claimed repair. Final-head CI run 40077435535 passed on624230a47907f902720785ec395b592907d0c0e6. No CI rerun was used to chase green; new runs followed actual source changes. Passing CI does not waive the measured GC rejection and does not establish a fix for the earlier relay failure.All 36 completed measurement pairs are retained and valid; no capture was guard-aborted, trimmed, or excluded. Guard pauses happened before captures. One earlier traced window saw a temporary Dirty-threshold warning without a guard abort and retained its 125.465 ms traced pause; it was not an untraced gate. No captures overlap the declared 04:04–04:20 UTC external-deployment exclusion. Two already-started traced controls completed after the rejection decision; future pairs were stopped, not partially discarded.
The motivating pre-change live profile attributed 79.68 MiB / 30 s to
readTreeMemoryand its childreadFileself-allocation (90.69 MiB inclusive forreadTreeMemory). That is pre-change live evidence; no candidate deployment or live before/after comparison was performed. External Buffer allocation and full-Gateway allocation effects were not measured. Production was not modified.Related: #182111, #182163.
The requested adaptive-interval-only follow-up is #182452. This PR remains closed on the rejected implementation; its rejection and measurements are unchanged.