You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory sizing reads /proc/meminfo and ignores cgroup limits (containers, CI runners, systemd scopes) #3072
LightCraft sizes its memory use from /proc/meminfo (and the macOS / Windows equivalents) and never looks at cgroup limits. Inside a container, a Flatpak or systemd scope with MemoryMax, or a CI runner with a memory limit, the process may get far less than the machine has:
The engine sizes its budgets for the whole machine.
Merge plans for 75 % of physical RAM.
cargo xtask ci picks build jobs and test threads for memory it can't use.
A run that thinks it has room then gets killed when it hits the limit.
xtask/src/main.rs:160:available_ram_mb() reads MemAvailable: and feeds ci_jobs (:149).
No cgroup reading anywhere: a search for memory.max or /sys/fs/cgroup in crates, apps and xtask finds nothing.
Proposed fix
Limit (Linux, std only, never panics):
effective_total() = min(MemTotal, cgroup v2 memory.max), with the cgroup found through /proc/self/cgroup.
Return None / no limit when either value is absent or max.
Available memory:available() = min(MemAvailable, memory.max − memory.current).
Callers: use them in engine::memory, merge, export and xtask.
Where the code lives:lightcraft-sysmem today only hands freed memory back to the allocator. Either widen its role, or keep one copy in engine and one in xtask.
Yes for Linux: honouring cgroup v2 memory.max / memory.current is a real fix for Flatpak, systemd scopes and CI runners, and std-only with a fallback to today's behaviour when there's no limit sounds right.
For Windows job-object limits: fine in principle, and crates/sysmem is the right home for the unsafe, but please land the Linux part first and keep the Win32 calls in their own small PR so they can be reviewed separately.
@FredApps thanks. #3118 is the Linux part: std only, no new dependencies. It reads cgroup v2 memory.max / memory.current (and v1 memory.limit_in_bytes / memory.usage_in_bytes where a host still mounts v1) for the process's cgroup and every ancestor up to the mount root, and takes the tightest. With no limit, or nothing readable, it returns today's numbers (MemTotal / MemAvailable). It is rebased onto main and ready for review.
The Win32 calls stay in #3654, which follows once #3118 merges. Its own diff is the win32 module in crates/sysmem (two read-only calls, GlobalMemoryStatusEx and QueryInformationJobObject, each with a // SAFETY: comment), the safe code that interprets the job limit, and a one-line switch in the engine. xtask's Windows sizing (#3705) stays separate in #3710, after that. Both stay draft until their parent merges.
The Windows CI leg didn't test lightcraft-sysmem or xtask, so the job-object tests had never run in CI. #4582 adds both to it. I have run them natively on Windows on #3654's and #3710's heads, and they pass.
Activity
ticket-craft commentedon Oct 26, 2026
Thanks! This ticket describes several separate problems:
It helps a lot if each one has its own ticket, so they can be tracked and fixed separately.
Possibly related: #3057, #3059 and #3066.
feat(sysmem): storytold#3072 read the memory the process may use, cgr…
fix(engine): storytold#3072 size the memory budget, merge and export …
fix(xtask): storytold#3072 size ci build jobs and test threads from t…
fix(sysmem): storytold#3072 read only the cgroup limits for the total…
fix(sysmem): storytold#3072 find the memory controller through mounti…
fix(sysmem): storytold#3072 read an ancestor's limit through every mo…
fix(testkit): storytold#3066 count a test binary's --test-threads; th…
feat(sysmem): storytold#3072 read the memory the process may use, cgr…
fix(engine): storytold#3072 size the memory budget, merge and export …
fix(xtask): storytold#3072 size ci build jobs and test threads from t…
fix(sysmem): storytold#3072 read only the cgroup limits for the total…
52 remaining items
FredApps commentedon Nov 18, 2026
Yes for Linux: honouring cgroup v2
memory.max/memory.currentis a real fix for Flatpak, systemd scopes and CI runners, and std-only with a fallback to today's behaviour when there's no limit sounds right.For Windows job-object limits: fine in principle, and
crates/sysmemis the right home for theunsafe, but please land the Linux part first and keep the Win32 calls in their own small PR so they can be reviewed separately.feat(sysmem): storytold#3072 read the memory the process may use, cgr…
fix(engine): storytold#3072 size the memory budget, merge and export …
fix(xtask): storytold#3072 size ci build jobs and test threads from t…
fix(sysmem): storytold#3072 read only the cgroup limits for the total…
fix(sysmem): storytold#3072 find the memory controller through mounti…
fix(sysmem): storytold#3072 read an ancestor's limit through every mo…
fix(engine): storytold#3072 keep the default budget within a small cg…
fix(engine): storytold#3072 app.memoryBudget {mb: 0} goes back to the…
test(engine): storytold#3072 keep the 4 GiB budget cases off 32-bit t…
Issue storytold#3072: the Settings test expects the automatic budget …
Issue storytold#3072: app.memoryBudget's help and error say the unit,…
fix(sysmem): storytold#3072 read the deepest cgroup levels when a pat…
THEtheChad commentedon Nov 20, 2026
@FredApps thanks. #3118 is the Linux part: std only, no new dependencies. It reads cgroup v2
memory.max/memory.current(and v1memory.limit_in_bytes/memory.usage_in_byteswhere a host still mounts v1) for the process's cgroup and every ancestor up to the mount root, and takes the tightest. With no limit, or nothing readable, it returns today's numbers (MemTotal/MemAvailable). It is rebased onto main and ready for review.The Win32 calls stay in #3654, which follows once #3118 merges. Its own diff is the
win32module incrates/sysmem(two read-only calls,GlobalMemoryStatusExandQueryInformationJobObject, each with a// SAFETY:comment), the safe code that interprets the job limit, and a one-line switch in the engine. xtask's Windows sizing (#3705) stays separate in #3710, after that. Both stay draft until their parent merges.The Windows CI leg didn't test
lightcraft-sysmemorxtask, so the job-object tests had never run in CI. #4582 adds both to it. I have run them natively on Windows on #3654's and #3710's heads, and they pass.docs(sysmem): storytold#3072 describe the 64-level cgroup ancestor wa…