Repository navigation
Memory pressure sheds against the host's deficit (compressor + swap), not RAM past a fraction - #5971
Merged
joelteply merged 2 commits intoNov 13, 2026
Conversation
…sed and swapped, not RAM past a fraction On the M5 on 2026-11-13 the box had 60 MB free, ~34 GB in the compressor and swap at 8.6 of 10 GB, prefill ran at half speed, and nothing was shed: the only shed amount was RAM "used" past a fixed fraction of total, which a compressing host keeps under every gate. - continuum-host::host_memory: one host reading (free, reclaimable cache, compressor, cumulative swap in/out, the kernel's own free target). macOS: host_statistics64 + vm.vm_page_free_target; Linux: /proc/meminfo, /proc/vmstat, min_free_kbytes. The two formats convert in pure functions tested on every host. - memory_pressure::host_deficit: deficit = (compressed + swap_used - baseline at the last clean poll) + max(0, free_target - (free + reclaimable)); clean = no shortfall, no swap-out, compressor not grown. A positive deficit is at least Warning, and the shed path runs every poll while it lasts. deficit_at(priority) = max(RAM overrun past the gate, deficit minus what lower priorities hold); Realtime never sheds for it. - ShedLru and mind_results shed their share of the deficit (share_of_deficit). - The swap axis reads the same host reading: swap_activity's own cfg'd reader and mach_ffi::read_swap_traffic_bytes are deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…life, not past a fixed 0.90 The self_sized ratchet holds a touched file to no sized literal; SWAP_FULL_FRACTION was one. The swap axis already measures the paging rate, so "nowhere left to page" is now free swap against what that rate moves in one SWAP_RATE_HALF_LIFE. A full but idle swap file reads Normal (inert pages cost nothing; the host deficit counts what the OS displaced). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Nov 13, 2026
… boot plan, a settle gate, and one retirement for a floor-sized engine (card 8569b03d) (#5976) The M5, 2026-11-13: at 19:36Z the boot plan read 16 GB usable while the stopped engine's memory was still coming back, launched -c 2045, and the plan 15 s later (2 x 134,690 at 25 GB) was never applied; at 22:16Z an engine launched at 49,408 for 5 sequences and did not grow in 10 minutes. Every mind needed 68-110k and was dark until the engine was killed by hand. - cognition: WorkingSetRegistry::remembered_residents, the newest minds a held turn measured. - serving demand: before the persona registry exists, the requirements are the remembered residents', so the boot plan goes through the allocator and the launch floor (seated needs, capped at the proven pool on a gap reading) holds them. - settle: the host's compressor shrinking between readings (continuum_host::host_memory, #5971) holds a launch below the seated needs until the host stops returning memory; read before every reconcile, off the runtime. No reading never waits. - floor_sized: a ready engine whose pool holds fewer seated minds' needs than a launch at the live budget would is retired once (per engine process); the next reconcile launches the grown pool. The fork has no live pool resize route (checked cd2e16d87 tools/server/server.cpp routes). - dyno 9 (boot during memory settle) before/after; dyno 10 (leased-in mind) known-red on the grid seam (MissingSeam::LeasedInRequirement). Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves the minds on the M5: when the OS compresses and swaps, every mind's prefill and decode slows. This is slice 1 of "one control for memory": one measured host pressure, and the existing shed path driven by it. Plan line: path step 1 (Fast), goal 7/9 (one budget, one control).
The incident (M5, 2026-11-13)
60 MB free, ~34 GB in the OS compressor, swap 8.6 / 10 GB, prefill at half speed, and nothing shed. The only shed amount was
PressureSnapshot::over_gate, which is RAM "used" past a fixed fraction of total. A host that is compressing reads "used" under every gate, so the amount was 0.mind_results_reporter.rssaid so in its own doc ("swap activity alone ... sheds nothing here").What changed
continuum-host::host_memory(new, the OS seam): oneHostMemoryReadingholding free, reclaimable (file cache + purgeable), compressor-occupied bytes, cumulative swap in/out, and the kernel's own free target.host_statistics64(HOST_VM_INFO64)+sysctl vm.vm_page_free_target. The accounting matches Activity Monitor: free = free − speculative, cached = external + purgeable./proc/meminfo(MemFree, MemAvailable, Zswap),/proc/vmstat(pswpin/pswpout),/proc/sys/vm/min_free_kbytes.MachVmCounts::reading,from_proc_text). These compile and are tested on every host.macos.rs/linux.rs/other.rshold only the calls.memory_pressure::host_deficit(new): the one shed quantity.deficit_at(priority) = max(RAM overrun past the gate, deficit − bytes held by lower priorities). Batch gives back first, then Background, then Interactive. Realtime never sheds for the deficit.shed_duecalls the shedders on every poll while the deficit lasts (after the 2-poll hysteresis), and each poll recomputes the shares from what is still held.ShedLruandmind_resultsnow shed theirshare_of_deficitinstead ofshare_of_overrun. TheMemoryReporterinterface is unchanged.swap_activity::read_swap_traffic(with itscfgbranches) andmach_ffi::read_swap_traffic_bytesare deleted.parse_proc_vmstatmoved into the host adapter, and its test moved with it.PressureSnapshotgainscompressed_bytesanddeficit_bytes. The TS binding was updated by hand to match ts-rs output.memory.pressureprobe gainscompressed_mb,host_available_mb,free_target_mbanddeficit_mb. A newmemory.pressure.shedprobe fires on each shed fan-out.memory.shed_lru.shedandwm.results.shedalready report the bytes freed.unwrap_ors in the touched monitor file are fixed: one becametotal_cmp, the other got a justification.Tests (in the new files' single test mods)
the_m5_incident_has_a_deficit_and_the_reporters_shed: free 60 MB, compressor 34 GB, swap 8.6 GB, RAM used 75% (under the 0.80 gate). The deficit is positive both after a clean baseline and after a restart straight into the pressure. The level is Warning, the shed path runs on every poll, and mind_results' share is ≥ everything it holds. The old RAM-only figure is 0.a_clean_box_has_no_deficit_and_sheds_nothing: a small, steady compressor, inert swap and free memory above target give deficit 0, Normal level and no shed.lower_priorities_give_back_firstandone_deficit_is_shared_across_a_priority_not_repeated(moved from shed_lru).mach_counts_and_proc_text_convert_to_the_same_reading: one host state written as Mach page counts and as /proc text gives an identical reading.an_m5_vm_stat_reads_as_activity_monitor_accounts_ituses the fixture from this M5'svm_staton 2026-11-13.proc_text_is_read_in_bytes_and_a_missing_counter_is_no_reading.a_live_mac_reads_and_the_count_matches_the_structchecks the struct-size count and makes a live call.continuum-engine/src/capacity/dynohas no host-memory scenario library (its scenarios cover serving batches and knees), so the incident lives as the kernel test above.Not compiled locally
The M5 is serving live minds, so no cargo build, check, test or clippy was run. CI is the compiler for this PR.
Not in this slice (later slices)
open_connection;GpuMemoryManager; the ResourceDaemon/Consumer authority; the broker'ssys-memorypool, which still frees 0 bytes.mach_ffi::read_system_free_bytes(the Metal monitor's unified free bytes, free + speculative + inactive) still has its ownvm_statistics64copy. Moving it ontohost_memorychanges the GPU governor's free figure on the serving node, so it gets its own change and live read. Follow-up owner: Fable.vm.swapusageon macOS. The monitor already made that read, so no second probe was added.Live receipt to take after deploy (M5, 15 minutes, compared against canary)
From
memory.pressureprobes:avail_mb,host_available_mb,compressed_mb,swap_mb,swap_rate_kib_s,deficit_mb,level. Frommemory.pressure.shed,memory.shed_lru.shed(freed) andwm.results.shed(before/after): bytes shed per tick. Prefill and decode tok/s from the engine. Expected:deficit_mbis 0 on a clean box. Under compression or swap growth it goes positive, the shedders free bytes, and it returns to 0 at the next clean poll. Worse than canary means the node goes back to canary.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo