Repository navigation
fix(exec): reduce memory-watch allocation for thread-heavy processes - #196416
Conversation
Reuse the supported readFile buffer API for procfs walks while preserving the faster native Node reader and complete oversized records. Keep per-thread discovery and runaway enforcement unchanged.
|
🦞👀 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 Summary: ✅ CompletedThis 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 reuses small kernel-read buffers on affected Node versions while preserving complete oversized records and newer native readers. Example: Monitoring 280 Linux processes with 6,720 threads on Node 24.22.1.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses verified allocation waste in the existing memory watcher, and review found no actionable defects. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherHost exec memory protection reads process ancestry, RSS, swap, and durable cgroup usage, then asks existing cancellation owners to terminate workloads exceeding the shared budget. flowchart TD
A[Host exec callers] --> B[Shared memory watcher]
B --> C[Runtime-selected kernel reader]
C --> D[Procfs and cgroup files]
D --> E[Parsed usage and descendants]
E --> B
B --> F[Existing cancellation owner]
Technical reviewBest possible solution: Keep the existing sampling owner and use Node-managed buffer reuse only where measurements justify it, retaining unrestricted overflow reads and existing enforcement. Do we have a high-confidence way to reproduce the issue? Current main uses Node's unrestricted reader for zero-size procfs records, whose implementation allocates unknown-size chunks; the PR supplies matched real-procfs measurements, but this review ran no target code. Is this the best way to solve the issue? The change fixes allocation at the existing reader owner, preserves complete discovery and accounting, and avoids a custom descriptor lifecycle or cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 66c2b325e049. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +28, Tests +36, Other +254. Total +318 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 10:55 PM ET / November 10, 2026, 03:55 UTC (Revision 2). |
|
The final evidence is now complete on unchanged head
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#196416) Reuse the supported readFile buffer API for procfs walks while preserving the faster native Node reader and complete oversized records. Keep per-thread discovery and runaway enforcement unchanged.
#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.
#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack. (cherry picked from commit 644ff7d)
…esults (#196266) * improve(tool-search): show input signatures for MCP tools in search results tool_search rendered input "unknown" for every MCP tool, so models called tool_describe before almost every MCP call. Render the same bounded, structure-only signature used for OpenClaw tools from the MCP input schema. Client tools keep "unknown" because Code Mode lists them in its system prompt from the same compact entries. Remote schemas can carry huge literals, so string literals longer than the hint budget are rejected before serialization. Code Mode prompt construction skips MCP entries before compaction; it never listed them. Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> * improve(tool-search): show input signatures for MCP tools in search results Worked on by: - @jalehman - @GrahamMcBain Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e * fix(test): restore the main test-line budget after warm reload changes (#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack. (cherry picked from commit 644ff7d) * test(agents): align host-denial proof with immediate failure settlement --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
openclaw#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for openclaw#196385 and correct openclaw#196416 from 33 to its actual 36 test lines. openclaw#196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main openclaw#196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.
…esults (openclaw#196266) * improve(tool-search): show input signatures for MCP tools in search results tool_search rendered input "unknown" for every MCP tool, so models called tool_describe before almost every MCP call. Render the same bounded, structure-only signature used for OpenClaw tools from the MCP input schema. Client tools keep "unknown" because Code Mode lists them in its system prompt from the same compact entries. Remote schemas can carry huge literals, so string literals longer than the hint budget are rejected before serialization. Code Mode prompt construction skips MCP entries before compaction; it never listed them. Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> * improve(tool-search): show input signatures for MCP tools in search results Worked on by: - @jalehman - @GrahamMcBain Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e * fix(test): restore the main test-line budget after warm reload changes (openclaw#196432) * fix(test): reconcile warm reload and procfs test-line debt Allocate nine missing lines for openclaw#196385 and correct openclaw#196416 from 33 to its actual 36 test lines. openclaw#196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar. * fix(test): account for the latest main test-line offset Main openclaw#196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack. (cherry picked from commit b67d29e) * test(agents): align host-denial proof with immediate failure settlement --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jalehman <[email protected]> Co-authored-by: GrahamMcBain <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes excessive allocation and CPU use by host exec memory protection when watched commands have many threads on Node's older
readFileimplementation.User Impact
Thread-heavy command trees remain fully protected while their memory scans allocate less temporary Buffer storage. Descendants spawned by non-main threads, oversized procfs records, shared budgets and runaway termination retain their existing behavior. No configuration or migration is required.
Why This Change Was Made
Procfs reports zero file sizes, causing the JavaScript
readFilepath to allocate at least 64 KiB per read, even for an empty thread children file. Use the supported caller-buffer API with a 4 KiB buffer reused within each PID's thread walk. Oversized records fall back to an unrestricted read. Node owns descriptor cleanup and EOF handling.Apply this on Node 24.19+ and 26.4–26.7. Preserve Node 26.8+'s faster native one-job reader and Bun's reader. An unchanged thread start time cannot establish that its children are unchanged, so the complete per-thread discovery remains. Production code grows by 28 lines for runtime selection and complete-record fallback; a hand-written open/read/close loop was measured and rejected.
Evidence
Isolated Linux, Node 24.22.1: 280 processes / 6,720 threads, including 260 descendants spawned by non-main threads. Five interleaved A/B pairs plus A/A; 10-second warmup and 60-second uninstrumented timing captures. Separate 15-second allocation captures use the same watch cadence.
Every CPU pair improved. A/A main CPU varied +4.63%, process CPU +7.34%, and GC +0.00284 s/min. Allocation results were identical across all five pairs: 21,000 procfs reads per capture in both arms, with 64 KiB allocation chunks eliminated in the candidate. These are synthetic owner measurements, not a full Gateway GC projection. Saturated local-host timing was rejected as acceptance evidence.
Node 26.12.1 preservation: five pairs plus A/A, mean main CPU 5.505 → 5.251 ms/s and process CPU 12.166 → 11.689 ms/s. Treat this as preservation, not a speedup: A/A main CPU varied -10.56%, and one of five pairs was adverse (+15.89% main CPU); the other four improved. The native reader remains selected.
Final real runaway proof watched 20 disjoint three-process trees: baseline 114 ms, candidate 1,122 ms, both below the six-second acceptance bound. Different tick phases mean these prove the bound, not relative speed. A separate single sampled V8 heap pair (excluding external Buffer storage) was 3.921 → 3.042 MB/s overall and 2.657 → 2.422 MB/s attributed to the owner; supporting evidence only.
Exact-head CI run passed for
00ce454652f170b059d70098a1306a6633a8b7eb.Focused Node tests: 81 passed (child-memory, process supervisor and Linux exec cgroup); Bun owner/supervisor tests: 55 passed; durable systemd integration: passed. Extended existing coverage for non-main-thread children and RSS/swap records beyond 4 KiB. The Buffer allocation budget fails on the baseline and passes on the candidate. Codex review: no actionable findings.
pnpm check:changed: typechecks, core/scripts lint, format, import-cycle checks and every other selected guard passed; the dead-export scan remains red with exactly the same 21 findings reproduced on parenteaa8aebfb69368a748f4aaf39166a8bf339f70ec. No new findings. No Control UI importer of the changed owner was found.Inherited dead-export regressions, reproduced and traced
These are existing main regressions requiring follow-up, not passing checks:
f63e5cd0f6d3); the preceding parent has zero provider findings.cf1ae7bb6a72).replyWithBillingRouteWarnings: fix(config): config writes switch models to API-key billing without a warning #191326 (56617cd00086).BROWSER_PAIR_CODE_LENGTH: feat(pairing): pair a browser with a short code approved on the host #191513 (d85ebfe8daad).authorDisplayName: Dashboards gallery: Display menu with list view, ordering and grouping #194455 (cde34f111b4d) removed its last production consumer.isLaunchctlNotLoaded: fix(daemon): preserve structured command termination outcomes #130634 (b4262689db5d).resolveLaunchAgentPlistPath: fix: report stale Gateway service policy in Doctor and update status #151777 (5e5912058286).parseLaunchAgentEnabled: fix(update): prevent Gateway respawn during package replacement #103537 (7713e8fb749e); redundant barrel retained by refactor(daemon): split launchd into concept modules #121929 (3d707a9b963b).