game_run_summary: record the run cgroup's memory peak #2967
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2967"
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?
Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T21:56:03Z.
Re-created from the original #2845.
aznohonza/mandy-contribwas made private at 21:41 UTC on 2026-12-01, which detached the fork and permanently closed its pull requests; GitHub refuses to reopen them (422 state cannot be changed). Same branch, same headace83ae110db8fadcb7e8d00d9e27a829cc47247. The original review thread is at #2845.Claimed in the coordination issue as: WINE-RUN-MEMORY-PEAK
What and why
scripts/run_game_wine.shruns the title in a cgroup of its own when it is started in a systemd scope, and that scope usually also carriesMemoryMax(e.g.systemd-run --user --scope -p MemoryMax=24G), but the run folder and the summary said nothing about how close the run came to that limit. The wrapper now reads the cgroup'smemory.peakonce the session has ended and writes it to<out>/memory_peak(bytes), andtools/game_run_summary.pyprintscgroup memory peak: 23.6 GiBafter the run time.docs/linux_proton.mdsays so.LEONIDA_SELF_CGROUP_PATH,LEONIDA_CGROUP_ROOT) use the names and defaults ofscripts/linux-boot/boot-inner.sh; they are also what the tests point at a fake proc file and cgroup tree.Open #2436 touches the same wrapper, so one of the two may need a rebase (a textual conflict in the environment block); this change adds no option.
Tested
CPU only, no game files, no Wine, no GPU:
python -I tests/test_game_run_summary.py— 13 tests pass, one new: 25,316,786,176 bytes prints ascgroup memory peak: 23.6 GiB, and a folder withoutmemory_peakgets no line.python -I tests/test_run_game_wine.py— 11 tests pass, two new: a stubbed run with a fake/proc/self/cgroupandmemory.peakwritesmemory_peakand prints the line; a cgroup-v1 proc file leaves both out.python -I tests/test_run_game_wine_safety.py— 3 tests pass.python -m compileall -qon the changed Python files,scripts/check_no_game_data.pyon all changed files, and the docs-only checks (tests/test_docs_*.py,tests/test_i18n_index.py,tests/test_design_contract_rows.py).GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T22:01:22Z.
The red
windowscheck is run 46697161399 from the original #2845 head — same SHAace83ae11, so GitHub attached the old check run to this re-created pull request. It is the known loader timing flake (PE images written and read back: 71 ms over the 25 ms limit), documented on #2845, and nothing in this change touches the loader. The fresh run on this PR (46754320832) haschange-scopeandno-game-datagreen, withcheck,linux-python-and-viewerandsemantic-testsqueued.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T22:13:24Z.
The wrapper records the real kernel peak in both a fresh scope and the caller cgroup.
I integrated
ace83ae110db8fadcb7e8d00d9e27a829cc47247onto mainc4ca5761508f136c5530482093bb3053b0bad4fa, then tested it once with #2966 and separately with #2968. Those two combinations merge cleanly. The #2436 head is already an ancestor of this main, so the wrapper here already includes it.On Linux with cgroup v2 and systemd 262, I ran the real wrapper against a synthetic Wine process. Each dedicated case used its own
systemd-run --user --scope. The synthetic child allocated and released 80 MiB before the wrapper readmemory.peak.title breakpoint, anddevice lost. The latter two came from separate synthetic exit-3 inputs. Each combination also passed 60 focused stock test methods.AI-assisted local testing, independently checked against the raw data. Synthetic runtime and trace inputs. The cgroup files and scopes were real.
Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T22:14:31Z.
Thanks — that is the measurement this path needed: the scope's own peak (102,719,488–105,156,608 bytes) and the inherited caller peak (17,839,054,848 bytes) both land in the saved value and the summary, and main writes no peak file. Your combined runs with #2966/#2968 also match the merge-tree check here. No change on my side.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T22:19:28Z.
Review: COMMENTED
Identical to #2845 (
ace83ae11), which I reviewed: the cgroup-v20::path, teardown-time read and GiB rendering are right, and the v2 selection is mutation-pinned.merge-treeis clean (main touched only an adjacent docs bullet). The two nits from there remain and are non-blocking: without a systemd scope this is the caller cgroup's lifetime peak, so the summary line should say that, and the[ -n "$cg_rel" ]guard is untested.Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T22:28:21Z.
Thanks — both notes are right. The summary line already says
(the run's scope, else the caller's cgroup); it does not say the caller case is a lifetime peak, and the[ -n "$cg_rel" ]guard has no test (the v20::path and the v1 fallback are what the suite covers). I will word the line as you suggest and leave the guard test as a follow-up.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T22:28:47Z.
Done in
f48318962: the line now reads(the run's scope, else the caller cgroup's lifetime peak), and both tests that pin the wording are updated (tests/test_game_run_summary.py,tests/test_run_game_wine.py— the second one caught the first CI run). The[ -n "$cg_rel" ]guard test stays a follow-up, as noted.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T22:54:34Z.
The existing v1 fixture already catches removal of the nonempty-path guard. On Ubuntu/WSL at
f48318962I ran test_no_cgroup_v2_peak_is_not_an_error and test_records_the_cgroup_memory_peak. Both passed. In a temporary copy I removed just the nonempty cg_rel check and repeated the same two tests. The v1 case failed at test_run_game_wine.py:217 because the wrapper wrote memory_peak from the fixture's root-level 999-byte sentinel. The v2 control still passed.That covers the guard-removal follow-up mentioned above with the tests already in this PR. Codex-assisted.
Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T23:04:24Z.
Thanks — that corrects what I said above: the guard is already pinned.
test_no_cgroup_v2_peak_is_not_an_errorfails attest_run_game_wine.py:217when the nonemptycg_relcheck is removed (the v1 sentinel becomes the peak), and the v2 control stays green. So no follow-up is needed for it.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T00:07:39Z.
Merging. Head
f48318962merges cleanly withmain7adb42f7aand does not force a rebase of #2566. Ran main (7adb42f7a) plus the PR myself: test_game_run_summary 13 green, red (1 error) with tools/game_run_summary.py from main; test_run_game_wine skips on Windows; ci_registration, line endings, stdout encoding and docs suites green. Third-party verdict on this head; all CI green. Merged by MoonEyes.AI-assisted (Claude Code).