Repository navigation
fix: pause optional Gateway work under parent memory pressure - #206041
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: passed. What this changesThis PR pauses optional Gateway work when a visible parent cgroup reaches 80% of its finite memory allowance. Example: A Linux Gateway has 419–423 MiB available in its 512 MiB leaf while its parent's working set reaches 86% of its allowance.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs an ancestor-memory-pressure blind spot still present on main, has no actionable introduced defects, and its exact-head CI gate passes. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared host-memory owner reads process, host, and Linux cgroup facts and returns a pressure decision consumed by optional maintenance and prewarming. flowchart TD
A[Process and host memory] --> D[Shared pressure decision]
B[Cgroup membership and mount information] --> C[Visible ancestor working sets]
C --> D
D --> E[Optional Gateway schedulers]
E --> F[Schedule or defer work]
Technical reviewBest possible solution: Keep ancestor-pressure detection in the shared memory owner while preserving existing budget readers and caller-owned retry behavior. Do we have a high-confidence way to reproduce the issue? Current-main source and Node's pinned implementation establish the ancestor-charge blind spot; the author supplies a controlled real-cgroup reproduction, which this read-only review did not rerun. Is this the best way to solve the issue? The patch repairs the existing admission owner, compares each ancestor's own working set with its own limits, and preserves separate profile and worker-budget contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4038ca354cc9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +108, Tests +161. Total +269 across 2 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 26, 2026, 12:25 PM ET / 17:25 UTC (Revision 2). |
|
@clawsweeper re-review Please review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#206041) * fix: pause optional Gateway work under parent memory pressure * fix: resolve visible cgroup controllers from their mounted subtree * fix: retain visible memory limits above covered controllers * fix: honor controller masks on the visible mount only * fix: keep existing cgroup budget readers independent of admission * refactor: name parsed cgroup mount fields
* fix: pause optional Gateway work under parent memory pressure * fix: resolve visible cgroup controllers from their mounted subtree * fix: retain visible memory limits above covered controllers * fix: honor controller masks on the visible mount only * fix: keep existing cgroup budget readers independent of admission * refactor: name parsed cgroup mount fields (cherry picked from commit 589a70a) Backport adaptation: Cherry-pick applies cleanly after the release optional-work pressure backport; no cgroup code or fixtures needed adaptation. Co-authored-by: RomneyDa <[email protected]>
* fix(runtime): defer optional work under host memory pressure * style(infra): format memory pressure admission * style(gateway): format the deferred prewarm check (cherry picked from commit 9f50802) Companion audit: #207993 selected later for publication fixture isolation. #206779 required if the new Cron host-memory fixture spoofs platform: preserve native SQLite namespace. #206041/#206230/#206308/#206746 are separate cgroup detection and optimization changes; #206322 is service-aware cron run budget, #206483 forks chat and #206384 changes a main-only warmer. Release adaptation: Extend the stable optional-memory owner and its existing callers only. Preserve cgroup/Bun/macOS behavior and upstream threshold cases; omit main-only prompt warmer, cgroup diagnosis, and Cron platform-spoof changes. Co-authored-by: RomneyDa <[email protected]>
* fix: pause optional Gateway work under parent memory pressure * fix: resolve visible cgroup controllers from their mounted subtree * fix: retain visible memory limits above covered controllers * fix: honor controller masks on the visible mount only * fix: keep existing cgroup budget readers independent of admission * refactor: name parsed cgroup mount fields (cherry picked from commit 589a70a) Release adaptation: take the pressure-owner slices of #206230 (verified mount mapping), #206308 (delegated leaf), and #206746 (mount discovery reused per membership). Do not import resource sizing, diagnostics or #206322 cron scheduling APIs; none are needed by stable optional callers. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A Linux Gateway can see ample headroom in its own cgroup and on the host while a sibling consumes most of their shared parent allowance. The Gateway still schedules optional startup and cache work in that state.
User Impact
On Linux with Node.js and cgroup v2, optional work pauses when a visible ancestor's working set reaches 80% of its finite reclaim or hard memory limit. It resumes as soon as a fresh check finds headroom.
Why This Change Was Made
Node 24 reads the current cgroup's limits. The Gateway also needs to check each visible ancestor's charge against its own
memory.highandmemory.max. The new check deducts inactive file cache. It uses the root of the mounted cgroup controller to avoid a similarly named sibling and can skip an unknown view. Existing process, host, profile and worker-budget checks keep their policies. Node's cgroup reader · Linux mount informationEvidence
The Linux x64 fixture called the production Gateway prewarm scheduler with a recording queue. An ordinary sibling shared a finite parent. The Gateway's leaf still had 419–423 MiB available out of 512 MiB. Linux proof run
A second fixture used a real read-only delegated bind. When only the unrelated sibling was pressured, the Gateway scheduled two jobs. It scheduled zero when the real parent was pressured and two once pressure cleared. All scoped max and OOM counters stayed at zero.
On this runner, 160 fresh helper calls per phase gave p50/p95 times in microseconds of 18/22, 18/21 and 18/21 on stock, and 82/110, 52/61 and 78/133 on the Linux-tested repair (
9f28bd16). These are measurements of the admission check.All 62 focused host-memory, Gateway resource-profile and child-memory tests passed on Node 24.22.1 at
9f28bd16. The final lint-only change (3be0695d) names the five fields parsed from mountinfo and uses a local traversal cursor. All 26 host-memory tests passed on its actual merge objectac35920f, including the delegated mount control. Final CI job Both original threshold cases failed on stock. The hard-limit case retains a 512 MiB cap with unreadable mount information and with an identity-preserving bind. The final committed-range review, pinned formatter, 259-rule scoped lint andgit diff --checkpassed.