Problem
When ram_budget_bytes == 0, WASTE currently caps its automatic choice at 7/8 of installed physical RAM. On Linux, that can be larger than the memory the process can safely allocate when the host already has resident workloads or a cgroup-v2 ancestor imposes a lower limit.
This is the Linux/open-time counterpart to the paging cliff already documented in docs/LEARNED.md §16: the physical cap remains useful, but it is not sufficient when current host pressure or a finite cgroup is tighter.
This came out of the GN100/K3 investigation, with one important correction: the original 80.64 GiB paging sample was caused by a second WASTE model open after budget selection. Clean 80.64 GiB replays were safe. This proposal protects against pressure already present when waste_open begins; it cannot predict a workload that starts later.
Proposed policy
For automatic budgets only, bound the ceiling by the minimum of:
- the existing 7/8 physical-RAM cap;
- Linux
MemAvailable minus a 1/8 host-RAM reserve; and
- finite cgroup-v2 ancestor headroom (
memory.max - memory.current) minus 1/8 of that group effective capacity.
The cgroup reserve is based on min(memory.max, physical RAM), rather than host RAM alone. Otherwise an 8 GiB group on a 128 GiB host incorrectly loses a 16 GiB reserve. The reader walks ancestors so an unlimited leaf cannot hide a finite parent.
If a known live/cgroup ceiling cannot hold the model floor, the candidate fails before model-sized allocation. This deliberately differs from the current behavior of running at the floor and warning, so I would value guidance on that choice.
Explicit nonzero budgets remain caller policy: they are not silently clamped, but receive a warning above the current safe ceiling. Missing or malformed Linux telemetry falls back safely, non-Linux behavior remains unchanged, and cgroup v1 is deliberately out of scope.
Tested candidate
I have this isolated against current main in candidate commit 5e4147f.
Validation completed:
- policy and synthetic proc/cgroup tests cover malformed telemetry, exhausted limits, an 8 GiB child, an unlimited child under a finite parent, ancestor traversal, whole-working-set selection, and floor refusal;
- macOS portable suite: 29 passed, 0 failed, 12 skipped; Python server: 168 passed;
- ASan/UBSan: 28 passed, 0 failed, 13 skipped;
- GN100 Linux ARM64: 27 passed, 0 failed, 13 skipped;
- a real K3 automatic open on an otherwise idle GN100 retained the full recommended 86,583,021,568-byte budget, including a 55,780,900,864-byte expert cache, and completed normally in 24.1 seconds.
This is a safety change, not a throughput claim.
Before I open a PR, do these policy boundaries look right? In particular, should explicit budgets remain authoritative, should auto-open refuse when the current ceiling is below the floor, and is the proposed public waste_memory_ceiling() query plus JSON reporting useful? I can narrow or reshape the patch before opening it.
Problem
When
ram_budget_bytes == 0, WASTE currently caps its automatic choice at 7/8 of installed physical RAM. On Linux, that can be larger than the memory the process can safely allocate when the host already has resident workloads or a cgroup-v2 ancestor imposes a lower limit.This is the Linux/open-time counterpart to the paging cliff already documented in docs/LEARNED.md §16: the physical cap remains useful, but it is not sufficient when current host pressure or a finite cgroup is tighter.
This came out of the GN100/K3 investigation, with one important correction: the original 80.64 GiB paging sample was caused by a second WASTE model open after budget selection. Clean 80.64 GiB replays were safe. This proposal protects against pressure already present when
waste_openbegins; it cannot predict a workload that starts later.Proposed policy
For automatic budgets only, bound the ceiling by the minimum of:
MemAvailableminus a 1/8 host-RAM reserve; andmemory.max - memory.current) minus 1/8 of that group effective capacity.The cgroup reserve is based on
min(memory.max, physical RAM), rather than host RAM alone. Otherwise an 8 GiB group on a 128 GiB host incorrectly loses a 16 GiB reserve. The reader walks ancestors so an unlimited leaf cannot hide a finite parent.If a known live/cgroup ceiling cannot hold the model floor, the candidate fails before model-sized allocation. This deliberately differs from the current behavior of running at the floor and warning, so I would value guidance on that choice.
Explicit nonzero budgets remain caller policy: they are not silently clamped, but receive a warning above the current safe ceiling. Missing or malformed Linux telemetry falls back safely, non-Linux behavior remains unchanged, and cgroup v1 is deliberately out of scope.
Tested candidate
I have this isolated against current
mainin candidate commit 5e4147f.Validation completed:
This is a safety change, not a throughput claim.
Before I open a PR, do these policy boundaries look right? In particular, should explicit budgets remain authoritative, should auto-open refuse when the current ceiling is below the floor, and is the proposed public
waste_memory_ceiling()query plus JSON reporting useful? I can narrow or reshape the patch before opening it.