Skip to content

gate: memory.csv and a pile-up's numbers beside the summary (D3D12-GATE-MEMORY-SERIES) - #2813

Open
TheGeogeo wants to merge 4 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-gate-memory-series
Open

TheGeogeo wants to merge 4 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-gate-memory-series

Conversation

@TheGeogeo

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-GATE-MEMORY-SERIES (#2570 (comment))

Depends on: #2810, #2812 (this branch holds their commits and will be rebased on main once they are merged)

What and why

Testers read a memory pile-up by its slope and by the reaper's queue. The peaks of #2810 show neither, so they kept a sampler of their own beside each run. This is the third of the three memory PRs for the gate.

  • tools/game_gate.py also reads the runtime's census line. The runtime writes it with each memory line, every 5 s, in builds with diagnostics. It carries the objects let go that wait for their submissions, and the objects handed to the reaper thread and not let go yet: the reaper's queue.
  • summary writes memory.csv beside summary.json, one row per memory line. Each row has: time, private bytes, those in physical memory, the PC's memory free and left to commit, the card's video memory budget and in use, the shared memory in use, and the two queues. A run without memory lines writes no file.
  • The summary's memory block gets:
    • the reaper queue at its longest, and when;
    • the most objects waiting for their submissions;
    • the least-squares slope of the private bytes in the world, in MB a minute. On a short run the slope is the loading's climb; on a long one, a pile-up's.
    • series, the file's name.
  • The census strings join the contract test. docs/game_gate.md describes the file and the new fields.

Tested

On Windows 11 Pro 10.0:

  • tests/test_game_gate.py: 27 tests OK. The new ones fail with gate: a memory stop ends a run before memory runs out (D3D12-GATE-MEMORY-STOP) #2812's parser. They cover:
    • a synthetic run whose private bytes grow 10 MB every 5 s in the world gives a slope of exactly 120 MB a minute;
    • the reaper queue's peak and its time;
    • summary writes 76 rows with the right columns and last values;
    • a build without memory lines gives no series and nulls.
  • The docs tests, test_tool_stdout_encoding.py and scripts/check_no_game_data.py on the changed files are clean.
  • On a real run, I re-summarized a copy of a 124 s gate run (RTX 3080 10 GB, driver 32.0.16.2140, Series S profile). The result:
    • 37 rows, every column filled;
    • the reaper queue at most 1,018 (at 108 s), then 0;
    • the objects waiting for their submissions at most 6,991;
    • private bytes from 8,511 to 23,687 MB, a slope of 450 MB a minute in the world, which is the loading's climb on a run this short;
    • the PC had down to 477 MB left to commit.

GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

Testers could not use the gate daily without memory figures, and a memory pile-up took a 3090's Windows
down twice. The parser now reads the runtime's memory line and video memory line (every 5 s in builds with
diagnostics) and writes a memory block: the private bytes at their most and when, the most of them in
physical memory, the least the PC had left to commit and when, the card's video memory in use at its most
and when with the budget then, the seconds over that budget, and the most shared memory in use. The video
memory is what the system counts for the process, so it works on any card. The five runtime strings it reads
join the contract test.
…ORY-STOP)

A memory pile-up has taken a PC's whole Windows down, not only the device, and a fixed 80 GB cap never
triggers on a PC with a 40 GB commit limit. The supervisor now asks `game_gate.py state` for a memory stop,
read from the runtime's latest memory lines: the game's private bytes past -StopPrivateMB (default 90 % of
this PC's commit limit), the PC under -StopCommitLeftMB left to commit for 20 s (default the larger of
128 MB and 0.25 % of the limit), or video memory over the system's budget for -StopOverBudgetSeconds (60).
0 turns one off. The run then stops the same clean way, with the reason `memory`; the limits go into
run.json and the summary, the limit passed into `stop.memory_why`, and the verdict is FAIL `memory_stop`.
`start` forwards the limits to the detached run.
With a large page file the commit limit is far above what a PC survives: two Windows crashes (0x10E)
came at about 100 GB private on a PC with 64 GB of memory and a 175 GB limit, where 90 % of the limit
is 158 GB. The default is now the lower of 90 % of the commit limit and 1.25 x the physical memory
(80 GB there, 36 GB here); the video memory stop stays on by default.
…TE-MEMORY-SERIES)

Testers read a pile-up by its slope and by the reaper's queue, which the summary's peaks do not show. The
parser now also reads the runtime's census line written with each memory line (objects let go that wait for
their submissions, and the reaper thread's queue) and writes memory.csv beside summary.json: one row per
memory line with the private bytes, the PC's memory free and left to commit, the card's video memory budget
and in use, the shared memory in use and the two queues. The summary's memory block gets the reaper queue
at its longest and when, the most objects waiting, and the least-squares slope of the private bytes in the
world (MB a minute). The census strings join the contract test.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head c67a2b69f, main d920d850d. CPU only, no game. This branch contains #2812 5323dfa69 (and #2810), so red is #2812 + this PR's tests.

MEASURED

READ IN CODE

  • The census phrase the new WAITS regex reads exists on main where SOURCES says: memory, what waits to be let go: {waiting} objects … (LEONIDA_BURY_LAG), {handed} retired objects, landed host lists and lists' fronts handed to the thread that lets them go at leonida-gpu/src/census.rs:343-344, logged from copystat.rs:757 (crate::census::log();).
  • memory.csv joins each memory line with the video and census lines within 2 s (near()). slope_per_min is an ordinary least-squares slope, None under 3 points or with no time spread.
  • Heads-up: enlighted's reaper branch (54dc3209f, not a PR yet) edits census.rs around that same line (it adds the LEONIDA_REAPER_LIMIT part). If that changes this sentence, your contract test will catch it, which is what it's there for; whichever lands second adjusts.

ASSUMED

  • Your RTX 3080 run (37 rows, reaper queue max 1,018 at 108 s) is not reproduced here.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified on Windows with the control: the suite fails when tools/game_gate.py is put back to main.

Cherry-picked onto main d920d850d, Python 3.13.14, no GPU and no game data:

python -m pytest tests/test_game_gate.py -q with this pull request: 27 passed in 3.85 s with tools/game_gate.py from main: 5 failed, 22 passed

So the new cases are tied to the new code and not to fixtures the file already had. They add to the same suite that #2805, #2804 and #2810 touch, and all five together are consistent - I have now run every one of them.

It applies on main on its own and on top of #2812, so either order works; #2812 then #2813 needs no rebase.

What I could not test: the PowerShell side (scripts/game-gate.ps1, 28 lines changed here). That path drives a real run folder, and this machine has the game but not the gate harness the reports describe - the Python parser and its summary are what the tests cover, and they are green.

AI-assisted: yes - DeepSeek v4.1 (flash), applied and ran both arms on the machine above.

Written with an AI assistant.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows / Python 3.12; python -I tests/test_game_gate.py is 27 tests, OK. A synthetic 8-sample run gives one row per memory line with the documented header (70.0,1000,500,15000,4000,8000,7000,500,0,0), LF only and no BOM, every column equal to the log's integer MB with no rescale, and the summary's private_max, reaper_queue_max / _at_s, waiting_objects_max, vram_in_use_max all equal the CSV maxima; the slope recomputes from the CSV (600.0 vs 600.0 on mine). A one-sample run gives one row and slope: null with no division, and a run without memory lines writes no memory.csv.

Two things before merge, both documentation-truth:

  1. docs/game_gate.md:105 still lists "A time series beside the summary (memory, census, reaping queue)" under ## Not in this version, which is exactly what this PR adds; :107 ("VRAM and RAM peaks") is stale from #2810. No test reads that list, so CI will not catch it.
  2. summary.memory.vram_in_use_max_mb counts every video line (tools/game_gate.py:457), including the swap-chain ones (host.rs:13100, :13485, :13607), while memory.csv samples only the video line nearest each memory row (:410). A verifier can see a peak in summary.json with no matching row — I reproduced it (CSV cell empty, summary 7777). Document the distinction or emit the peak's sample row.

Minor: write_series (:419-423) returns before unlinking an existing memory.csv, so re-summarizing a folder whose log lost its memory lines leaves series: null beside stale rows; and the test at tests/test_game_gate.py:322-328 only asserts the summary side of "no memory lines gives no series", never that no file is written (it calls summary(), not main()). Docs also omit reaper_queue_max_at_s / waiting_objects_max from the field table and never list the CSV header.

Merge picture: this branch already contains #2810 and #2812, and every order of the three merges cleanly on 86c30fcea with identical final trees and additive summary.json keys. Landing order I would use is #2810 -> #2812 -> #2813.

@TheGeogeo

Copy link
Copy Markdown
Contributor Author

Thanks @KelboLive. Confirmed: write_series (tools/game_gate.py:419-423) returns before touching an existing memory.csv, so a folder summarized again after its log lost its memory lines keeps stale rows beside series: null.

To keep this verified head unchanged, I will fix it in a follow-up pull request after the merge: remove the old file when there are no rows, with a test for that case.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants