mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1601] [CLOSED] memory guard: parking and session save/restore check the container's real RAM (--memory-limit-mib) #3557
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3557
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1601
Author: @noon-at-cgn
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:pr/memory-guard📝 Commits (2)
2a2f4e9memory guard: parking and session save/restore read the RAM the engine really has (--memory-limit-mib)dcb9fdddocs: replace the evidence placeholder in the memory guard section with the measured result📊 Changes
8 files changed (+806 additions, -34 deletions)
View changed files
📝
CMakeLists.txt(+9 -0)📝
docs/DETAILS.md(+81 -4)📝
include/strata/core/conversation_memory.hpp(+58 -3)📝
src/core/conversation_memory.cpp(+246 -8)📝
src/core/conversation_memory_test.cpp(+1 -1)📝
src/program/generate.cpp(+68 -14)📝
sycl/src/program/generate.cpp(+4 -4)➕
tests/core/memory_guard_test.cpp(+339 -0)📄 Description
Title
Issue: Related: #1250 (host OOM while page-locking the expert copy; its
STRATA_PIN_GUARDcovers the start-up copy), #1572 / #1573 (SAVE admission, open draft).Summary
Why it matters: parking a conversation (about 240 MB to 750 MB per park) and saving or restoring a session file decide with
MemAvailablealone. Inside a container that figure ignores the container's own limit, so the engine can start a copy it has no room for. In our log from a bad day,MemAvailableread 21.8, 25.4 and 3.7 GiB just before three kills while the container's cgroup was at 98.6, 94.9 and 96.6 GiB of a ~100 GiB limit.available_host_bytes()now returns the smallest ofMemAvailable, the room under every cgroup limit above the engine, and an operator cap (--memory-limit-mib N, the total RAM the container may use). With no cgroup limit and no flag it isMemAvailable, as before. Those kills were host-wide OOMs (the host was over-committed), so the PR does not claim to prevent them; it makes the engine's own admission decisions use the real headroom.--memory-limit-mib 101376--memory-limit-mib 78000parked N tokens in ... msskip parking (... 0 MiB available, source flag)The engine held 89.7-89.9 GiB, above a 76.2 GiB cap, so headroom is 0: the intended refusal, and the request goes on.
What changed
conversation_memory.hpp/.cpp:conversation_available_memory()becomesavailable_host_bytes()/sample_host_memory(). The cgroup term readsmemory.maxandmemory.high(v2) ormemory.limit_in_bytes(v1) of the process's group and each visible ancestor; clean inactive file cache is credited. An unparsable cgroup file makes the sample unknown, and unknown refuses.src/program/generate.cpp: flag and variable, one start-up line (limit, source, usage, credit); parking (before and after capture), save and restore read the new figure; a refusal says how much was available and from which source. The eviction loop is unchanged.sycl/src/program/generate.cpp: four callers renamed.tests/core/memory_guard_test.cpp(new, CPU, fixture directories for/proc/meminfoand the cgroup tree) +CMakeLists.txt;docs/DETAILS.md.Extra Notes
Measured on engine 0.1.40.3 (
d5ea713) plus this change; the branch itself is cut from mainfb58e0d.Relation to #1250: not duplicated, not touched.
STRATA_PIN_GUARDdecides at start whether to page-lock in steps; this covers parking, SAVE and RESTORE after the start. Both read cgroup limits, in separate code (conversation_memory.cppalso builds standalone for the conversation tests); a shared reader can follow if you prefer one. #1573 edits the same SAVE lines, so one of the two needs a rebase.Machine: 2x RTX 3080, 90 GiB container, UD-Q4_K_XL. Checked:
memory_guard_test(130 checks; an existing binary, the rebuild was blocked by the build lock) andconversation_memory_test, CUDA build. Not built: HIP, SYCL, Windows. Not measured: a cap between 78000 and 101376, any run without the flag, any throughput effect.Context: this change is part of the setup measured in the community benchmark #1640.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.