mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
detail::host_available_memory read a cgroup v1 limit as memory.limit_in_bytes - memory.usage_in_bytes. v1's usage_in_bytes charges the whole page cache, and the kernel evicts that cache before it fails an allocation at the limit, so a container that had read its model through the file cache sat at its limit with its RAM to spare. The v2 branch credits the group's clean file pages (and the conversation memory guard and the setup's Python probe credit them on v1 too); this branch did not. Every figure built on it was short: the default CPU prompt share was "not armed by default: only 0.1 GiB of RAM is free" (the share needs 3.3 GiB), and the arena verdicts, the resident-budget clamp and the file tier's room read the same number. Measured on the rented RTX 5090 box (Vast 61335444: Docker, cgroup v1 hybrid, 171 GiB limit, 104 GB model, EPYC 9B14): limit - usage = 2.57 GiB with 99.9 GB of clean file pages (total_inactive_file + total_active_file) in the group. arena_cgroup_room_v1 (conversation_memory.cpp): room = limit - (usage - credit), credit = total_inactive_file + total_active_file - total_dirty - total_writeback, never more than the usage, less min(credit / 2, limit / 64): the rule of the v2 container branch (arena_cgroup_room). shmem (in total_cache, on the anon lists) and mlocked pages are not on the file lists, so they stay charged. A memory.stat without total_inactive_file or no memory.stat: no credit (limit - usage, as before). STRATA_MEM_CREDIT_INACTIVE=1 credits total_inactive_file alone. The v2 branches are unchanged. Test: file_expert_source_test (test_host_memory) has the box's memory.stat / usage / limit (2026-11-19 19:01:37 UTC) in the hybrid fixture: the room was 2.57 GiB before and is 92.9 GiB now; memory_guard_test has the pure arena_cgroup_room_v1 cases (shmem, dirty, writeback, bound by the usage, no stat, inactive only).