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 7 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-gate-memory-series
Open

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

Conversation

@TheGeogeo

@TheGeogeo TheGeogeo commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Depends on: #2812 (this branch holds its commits and will be rebased on main once it is 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, and a folder summarized again without them loses an older one. Each row takes the video and census lines within 2 s of its memory line (empty cells when there are none). The file is LF only.
  • 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 from the world's start to the stop request, in MB a minute (null with fewer than 3 lines there). On a short run the slope is the loading's climb; on a long one, a pile-up's.
    • series, the file's name, or null when the file could not be written (for example open in another program): the summary is written all the same.
  • The census strings join the contract test (one key spans the part the parser reads, after D3D12-REAPER-BOUNDED-QUEUE: bound the reaper's line (LEONIDA_REAPER_LIMIT) #2826 lengthened that sentence). docs/game_gate.md describes the file, its header, how its columns are picked, the new fields, and that the summary's video memory peak counts every video memory line (the swap chain's and the budget changes' too), so it can come from a line with no CSV row.

Tested

On Windows 11 Pro 10.0, rebased on main 8422def:

  • tests/test_game_gate.py: 35 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, and writes no file;
    • since the review: an older memory.csv is removed when the log has no memory lines; the summary is written when memory.csv cannot be; the CSV has no CR; the 2 s window and empty cells; the slope stops at the stop request.
  • 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. Claude Code (Claude Fable 5.2 and Claude Opus 5.5); a separate Claude Opus 5.5 agent reviewed the diff before this push.

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)

@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
Contributor

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
…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.
…ested at 20 s (review)

A run that reached -WorldSeconds at the same poll as a memory limit was reported FAIL `memory_stop`.
It is a measurement, and its memory peaks are in the summary all the same, so the supervisor now
checks the target first. The poll's order is one function, Get-StopReason, which the test takes out
of the script and puts to PowerShell 7 with synthetic polls. The commit floor's boundary is now
tested at exactly 20 s, and the docs say what `stop.memory_why` holds: the gate's whole sentence.
…full (review)

A negative -StopOverBudgetSeconds stopped every run at its first video memory line: 0 s over the budget
passed a negative limit. Every limit is now off at 0 or less, with a test for each, and a line at
exactly the private limit is tested not to stop. The poll test gets a memory limit at the time limit
(memory wins), and the script text test checks the target and time limits the loop passes and that the
memory stop's sentence reaches the stop event. The docs give the poll's whole order (a STOP file and the
world time at the same check give `target`), say that `world_time_short` and `world_not_reached` are
not added to `memory_stop`, and name `memory.stop_limits`.
…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.
…view)

`write_series` returned before an older memory.csv was touched, so a folder summarized again from a log
without memory lines kept old rows beside `series: null`: it now removes that file. Two tests go through
`main()`: no memory lines writes no file, and an older file goes. The docs list the CSV header, how its
video memory and census columns are picked (the nearest line within 2 s), `reaper_queue_max_at_s` and
`waiting_objects_max`, and that the summary's video memory peak counts every video memory line, the
swap chain's too, so it can come from a line with no row in the CSV. "Not in this version" no longer
lists the time series and the VRAM and RAM peaks. The census line's fixture is the runtime's sentence
as it is now, with the reaper's bound (LEONIDA_REAPER_LIMIT) at its end; the part the parser reads did
not change.
…p to the stop (review)

`summary` wrote memory.csv before summary.json, so a memory.csv open in another program left no
summary and exit 1. A file it cannot write or remove is now said on stderr, `series` is null and
summary.json is written. The private bytes' slope counted the memory lines written while the title
ends after the stop request; it now covers the world up to the stop, as the frame rates do. New tests:
the 2 s window and the empty cells of memory.csv, its LF line ends, the slope with lines after the
stop and with fewer than 3 lines in the world, and a memory.csv that cannot be written. The census
sentence's contract is one key over the whole part WAITS reads, the ", " between its two numbers too.
The docs name every video memory line the peak counts (the swap chain made, its buffers made again,
a budget change of 256 MB or more) and when the slope and `series` are null.
@TheGeogeo
TheGeogeo force-pushed the d3d12-gate-memory-series branch from c67a2b6 to 0e5ebd0 Compare December 2, 2026 03:44
@TheGeogeo

Copy link
Copy Markdown
Contributor Author

Rebased on main 8422def, on top of #2812's new head (head 0e5ebd0). @KelboLive's points are fixed here rather than in a follow-up, since the merge has not happened:

  1. "Not in this version" no longer lists the time series or the VRAM and RAM peaks.
  2. The docs say the summary's video memory peak counts every video memory line, including those around the swap chain, its buffers made again and a budget change of 256 MB or more. So the peak can come from a line with no CSV row.
  3. write_series removes an older memory.csv when the log has no memory lines. Two tests go through main(); with the old early return they fail.
  4. The docs list the CSV header, how its video and census columns are picked (within 2 s, an empty cell otherwise), reaper_queue_max_at_s and waiting_objects_max.

Also from a second review:

  • summary.json is written even when memory.csv cannot be (for example, open in another program). In that case series is null and stderr says why.
  • The CSV is asserted LF only.
  • The 2 s window and its empty cells are tested.
  • The slope stops at the stop request.
  • The census contract is one key spanning the part the parser reads, after D3D12-REAPER-BOUNDED-QUEUE: bound the reaper's line (LEONIDA_REAPER_LIMIT) #2826 lengthened that sentence.

tests/test_game_gate.py: 35 OK.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5; a separate Claude Opus 5.5 agent reviewed the diff before this push).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants