Skip to content

Worker: soft memory enforcement against the reservation, and a disk guard before inputs are fetched - #2812

Merged
amankrx merged 10 commits into
TraceMachina:mainfrom
amankrx:pr/memory-enforcement
Sep 29, 2026
Merged

amankrx merged 10 commits into
TraceMachina:mainfrom
amankrx:pr/memory-enforcement

Conversation

@amankrx

@amankrx amankrx commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

What and why

An action that grew past the memory the scheduler placed it by was killed by the pod's cgroup limit, and on cgroup v2 with memory.oom.group that kill takes the worker and every action on it. With resource_enforcement.memory: soft the worker samples the action's process group every 250 ms and kills it once two consecutive samples exceed the reservation plus headroom (default 20 percent), or one sample exceeds twice it, failing only that action with FAILED_PRECONDITION naming the reservation and the peak. disk: guard refuses an action whose disk reservation exceeds the free space under the work directory before any input is fetched, as RESOURCE_EXHAUSTED, which the scheduler requeues untried. The sample is the group's proportional set size, so a parent's pages shared with its forked children count once. The guard counts what the admitted actions already reserved, so four actions dispatched into the same free space are not all admitted. Either axis works alone. With enforcement on, the worker reads the properties from the scheduler's StartExecute.platform rather than the client's request, so the reservation enforced is the one the ledger charged. Actions run through a persistent worker are not covered by the ceiling, and the docs say so.

How was this verified?

running_actions_manager_test: an action that allocates past its reservation is killed with FailedPrecondition naming the figures (Linux only, like the sampler), an action reserving more disk than is free is refused before its inputs are fetched, a second action is refused while a first holds nearly all the free space and admitted once it has cleaned up, each config axis is honoured alone, Pss is parsed out of smaps_rollup, and the scheduler's properties reach an action's environment only with enforcement on. On a test cluster, eight actions ramping to 20 GiB with a 4 GiB reservation were each killed by the worker at 5.5 GiB with the pod still running and the client told the reservation and the peak within 40 seconds; before, the pod was OOM-killed and all eight were lost.

Risk

Off unless resource_enforcement is configured, and Linux only; the setting is accepted and ignored elsewhere. Samples are 250 ms apart, so an action allocating faster than the pod's whole limit in half a second can still reach the cgroup limit first. With enforcement off, the worker reads the client's properties as before, so an upgrade alone changes no action's environment.

AI assistance

An agent drafted the change and I reviewed every line.


This change is Reviewable

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nativelink Ready Ready Preview Sep 29, 2026 3:09pm UTC
nativelink-aidm Ready Ready Preview Sep 29, 2026 3:09pm UTC

Request Review

… pod's cgroup limit does

(cherry picked from commit 1006713c993859abadfe7a343bbe6380c5a07355)
(cherry picked from commit 9b564e17ed0e52402ab9561dd9475f8153446774)
… action

(cherry picked from commit 8de19068ec6d050a4c347766c4ceac83e71db635)
…e before fetching its inputs

(cherry picked from commit 3ae49eb55474465358ed67af4aa56c3057ec419f)
Comment thread nativelink-worker/src/local_worker.rs Resolved
…, overlay properties only with enforcement on
@amankrx
amankrx merged commit fcdccc8 into TraceMachina:main Sep 29, 2026
47 of 49 checks passed

This branch was successfully deployed

2 active deployments
Preview – nativelink — 7c9c2406 Deployed Sep 29, 2026 by vercel[bot]
Preview – nativelink-aidm — 7c9c2406 Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants