d3d12: keep a minimum of the game in memory on PCs with little RAM (D3D12-MIN-WORKING-SET) #3198

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "github-pr/3198:github-pr/3198"
git switch "github-pr/3198"
Open
leonida/mandy
pranjalprateek6 wants to merge 5 commits from github-pr/3198 into main

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

Conversation
Reviewers 0 approvals
  • No reviewers
Details

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

  • d3d12/docs/findings.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'github-pr/3198:github-pr/3198'
git switch 'github-pr/3198'
pranjalprateek6 commented 2026-12-02 18:27:33 +00:00

Claimed in the coordination issue as: D3D12-MIN-WORKING-SET (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7354390440)

Related claim, no pull request yet: D3D12-WORKING-SET-TRIM (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7330366858) trims the working set under pressure. Both are opt-in; with both on, this minimum is a floor under any trim. Also related: #3332 (D3D12-ROLLING-TRIM), which lets go of pages nobody touches.

What and why

The problem. On a 16 GB laptop the game holds about 21 GB of private memory a minute into the world, and Windows keeps about 5 GB of it in memory; the PC reads pages in at about 110 MB/s. Walking, the frame stalls in bursts that follow the scene: in them the submitting thread runs 10 to 17 % of the time it records preludes. A Windows Performance Recorder capture of 78 s shows page-ins as part of it:

  • 18.7 GB of hard-fault reads on the PC, 7.4 GB of them the game's. 83 % of the bytes came from one file on which 419 processes faulted (the capture has no file names; that it is the page file is an inference).
  • 15,500 hard faults on the submitting thread.
  • In a burst, a page-in of that thread took 1.1 ms on average against 0.2 ms before it (medians 0.19 and 0.14 ms); its page-ins took 16 % of the burst's time against 6 %. What else it waited for there is not known (the context switches could not be decoded).

The details are in the new section of d3d12/docs/findings.md.

The change. LEONIDA_MIN_WORKING_SET_MB (unset or 0: off, as before) asks Windows once, when the host device is made (host()), for a hard minimum working set: SetProcessWorkingSetSizeEx with QUOTA_LIMITS_HARDWS_MIN_ENABLE (residency::keep_working_set_minimum).

  • At most half of physical memory is asked for.
  • Only the minimum changes (since the review of 2 December). The limits are read first with GetProcessWorkingSetSizeEx; the maximum, and whether it is enforced, stay as they are.
    • A soft maximum without 64 KiB of room above the minimum (a process starts with 1.4 MB) rises to just that: Windows refuses a maximum 0 to 6 pages above the minimum.
    • A minimum that does not fit under an enforced maximum is declined with a warning: a call that asks for a larger enforced maximum raises it without an error.
    • An enforced minimum that is already as large is left.
  • The limits are read back after the call, and a minimum that is not in force is a warning.
  • A value that is not a number is a warning, and so is a refusal; neither changes anything.
  • It only keeps the pages that are in memory from being taken out: nothing is read in or locked.
  • The cost, documented on the function: while the game runs that memory is not other programs', and the PC's free memory is lower, so residency::pressured comes sooner (it limits texture prefetch).

Not changed. No launcher default. To try it: -More @{LEONIDA_MIN_WORKING_SET_MB='6144'}.

d3d12/docs/findings.md gets the measurements, and d3d12/docs/switches.md is regenerated with tools/d3d12_switches.py.

Tested

The in-game numbers below were taken with the first form of the call, which also set the maximum to the PC's physical memory, not enforced. With the maximum kept they have not been taken again, so they do not show the effect of the minimum alone (findings.md and the function's comment say so too). The runs of others in the comments were made on 80a627bb1, before this change.

In game, on the hardware below: the diag build with DLSS, Series S, no frame generation, the same scripted walk in a circle from one save, a web browser closed.

Within one run. By turns of 15 s (LEONIDA_AB, 49 phases), using a scratch switch around the same call, since the setting itself is read once:

Change 90 % interval
The submitting thread's work a frame -1.8 ms -3.4 to -0.7
The card idle a frame -3.2 ms -5.8 to -0.8
The phases' median frame -1.1 ms -2.1 to +0.6

The submitting thread and the card show it; the frame's median does not clear 0 within the run. The phases without the minimum keep what the phases with it kept in memory, which narrows the difference.

Across separate starts (medians of the frame lines' 5 s windows):

Median frame 95th percentile Game in memory PC free
Without (2 runs) 62.4 and 62.7 ms 115 and 126 ms 5.0 GB about 600 MB
6144 MB kept (2 runs, the second by the setting itself) 55.0 and 55.4 ms 86 and 87 ms 6.1 GB about 220 MB

Pages read in on the PC (Memory\Pages Input/sec, medians over minutes 2 to 6 of the walk, one run each): 105 MB/s without it, 94 with it flipped every 15 s, 81 with it throughout.

No errors in any run. The setting's log line showed the value applied (6,144 MB, not cut).

  • Unit test. residency::tests::a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory pins: nothing asked, a size below the cap, exactly half (not cut), cut to half, huge values (no wrap), and a memory too small to keep anything.
    • Shown to fail without its rules: with the cap removed, with a zero size returned, or with a multiply that wraps (the source changed one at a time), it fails; restored, it passes.
  • Unit tests of the limits. a_minimum_keeps_the_maximum_and_its_enforcement and a_minimum_is_in_force_when_windows_holds_at_least_that_hard (the decisions, without Windows) and windows_takes_a_minimum_and_keeps_the_maximum (against Windows, on a command prompt started for the test, so the test process's own limits stay; it passed without any privilege enabled).
    • Each of these ten changes of the source, one at a time, makes at least one of the four tests fail: the old call (the maximum at the PC's memory, not enforced), no check against an enforced maximum, no room above the minimum, the maximum's enforcement dropped, a soft maximum raised further than needed, a held minimum asked for again, no reading back, a soft minimum or one a page short counted as held, the half not in whole 64 KiB. Restored, all pass.
  • cargo test -p leonida-gpu --locked on this branch with main 09273248c merged: 733 passed, 0 failed, 59 ignored.
  • cargo clippy -p leonida-gpu --all-targets --locked: nothing in residency.rs. Clippy with -D warnings already fails on main, per .github/workflows/d3d12.yml.
  • python -I scripts/check_no_game_data.py on the four files: clean.
  • python -I tests/test_d3d12_switches.py: OK.
  • python -m unittest discover -s tests -p "test_docs_*.py": 59 tests OK.
  • finding: texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers is flaky under the parallel test runner on unchanged code (it failed 1 of 3 full cargo test -p leonida-gpu --features diagnostics --lib runs on a252854a2, and passes alone). No game files are needed to see it; seen on the hardware below.

GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU 8 GB, driver 621.40, Windows 11 Home 26300 (Intel Core Ultra 7 255HX, 16 GB RAM)

AI-assisted: yes (AI coding assistant). A separate, read-only AI reviewer checked the diff before opening; the findings section and the code comment were rewritten after that check. Two more such reviews, on 3 December, checked the rewritten text with main merged, and the corrections they asked for are in this version. The change that keeps the maximum was checked by another one before it was pushed, and again after its findings were worked in.

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)
Claimed in the coordination issue as: D3D12-MIN-WORKING-SET (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7354390440) Related claim, no pull request yet: D3D12-WORKING-SET-TRIM (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7330366858) trims the working set under pressure. Both are opt-in; with both on, this minimum is a floor under any trim. Also related: #3332 (D3D12-ROLLING-TRIM), which lets go of pages nobody touches. ### What and why **The problem.** On a 16 GB laptop the game holds about 21 GB of private memory a minute into the world, and Windows keeps about 5 GB of it in memory; the PC reads pages in at about 110 MB/s. Walking, the frame stalls in bursts that follow the scene: in them the submitting thread runs 10 to 17 % of the time it records preludes. A Windows Performance Recorder capture of 78 s shows page-ins as part of it: - 18.7 GB of hard-fault reads on the PC, 7.4 GB of them the game's. 83 % of the bytes came from one file on which 419 processes faulted (the capture has no file names; that it is the page file is an inference). - 15,500 hard faults on the submitting thread. - In a burst, a page-in of that thread took 1.1 ms on average against 0.2 ms before it (medians 0.19 and 0.14 ms); its page-ins took 16 % of the burst's time against 6 %. What else it waited for there is not known (the context switches could not be decoded). The details are in the new section of `d3d12/docs/findings.md`. **The change.** `LEONIDA_MIN_WORKING_SET_MB` (unset or 0: off, as before) asks Windows once, when the host device is made (`host()`), for a hard minimum working set: `SetProcessWorkingSetSizeEx` with `QUOTA_LIMITS_HARDWS_MIN_ENABLE` (`residency::keep_working_set_minimum`). - At most half of physical memory is asked for. - Only the minimum changes (since the review of 2 December). The limits are read first with `GetProcessWorkingSetSizeEx`; the maximum, and whether it is enforced, stay as they are. - A soft maximum without 64 KiB of room above the minimum (a process starts with 1.4 MB) rises to just that: Windows refuses a maximum 0 to 6 pages above the minimum. - A minimum that does not fit under an enforced maximum is declined with a warning: a call that asks for a larger enforced maximum raises it without an error. - An enforced minimum that is already as large is left. - The limits are read back after the call, and a minimum that is not in force is a warning. - A value that is not a number is a warning, and so is a refusal; neither changes anything. - It only keeps the pages that are in memory from being taken out: nothing is read in or locked. - The cost, documented on the function: while the game runs that memory is not other programs', and the PC's free memory is lower, so `residency::pressured` comes sooner (it limits texture prefetch). **Not changed.** No launcher default. To try it: `-More @{LEONIDA_MIN_WORKING_SET_MB='6144'}`. `d3d12/docs/findings.md` gets the measurements, and `d3d12/docs/switches.md` is regenerated with `tools/d3d12_switches.py`. ### Tested **The in-game numbers below were taken with the first form of the call**, which also set the maximum to the PC's physical memory, not enforced. With the maximum kept they have not been taken again, so they do not show the effect of the minimum alone (`findings.md` and the function's comment say so too). The runs of others in the comments were made on `80a627bb1`, before this change. In game, on the hardware below: the diag build with DLSS, Series S, no frame generation, the same scripted walk in a circle from one save, a web browser closed. **Within one run.** By turns of 15 s (`LEONIDA_AB`, 49 phases), using a scratch switch around the same call, since the setting itself is read once: | | Change | 90 % interval | |---|---|---| | The submitting thread's work a frame | -1.8 ms | -3.4 to -0.7 | | The card idle a frame | -3.2 ms | -5.8 to -0.8 | | The phases' median frame | -1.1 ms | -2.1 to +0.6 | The submitting thread and the card show it; the frame's median does not clear 0 within the run. The phases without the minimum keep what the phases with it kept in memory, which narrows the difference. **Across separate starts** (medians of the frame lines' 5 s windows): | | Median frame | 95th percentile | Game in memory | PC free | |---|---|---|---|---| | Without (2 runs) | 62.4 and 62.7 ms | 115 and 126 ms | 5.0 GB | about 600 MB | | 6144 MB kept (2 runs, the second by the setting itself) | 55.0 and 55.4 ms | 86 and 87 ms | 6.1 GB | about 220 MB | Pages read in on the PC (`Memory\Pages Input/sec`, medians over minutes 2 to 6 of the walk, one run each): 105 MB/s without it, 94 with it flipped every 15 s, 81 with it throughout. No errors in any run. The setting's log line showed the value applied (6,144 MB, not cut). - **Unit test.** `residency::tests::a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory` pins: nothing asked, a size below the cap, exactly half (not cut), cut to half, huge values (no wrap), and a memory too small to keep anything. - Shown to fail without its rules: with the cap removed, with a zero size returned, or with a multiply that wraps (the source changed one at a time), it fails; restored, it passes. - **Unit tests of the limits.** `a_minimum_keeps_the_maximum_and_its_enforcement` and `a_minimum_is_in_force_when_windows_holds_at_least_that_hard` (the decisions, without Windows) and `windows_takes_a_minimum_and_keeps_the_maximum` (against Windows, on a command prompt started for the test, so the test process's own limits stay; it passed without any privilege enabled). - Each of these ten changes of the source, one at a time, makes at least one of the four tests fail: the old call (the maximum at the PC's memory, not enforced), no check against an enforced maximum, no room above the minimum, the maximum's enforcement dropped, a soft maximum raised further than needed, a held minimum asked for again, no reading back, a soft minimum or one a page short counted as held, the half not in whole 64 KiB. Restored, all pass. - `cargo test -p leonida-gpu --locked` on this branch with `main` `09273248c` merged: 733 passed, 0 failed, 59 ignored. - `cargo clippy -p leonida-gpu --all-targets --locked`: nothing in `residency.rs`. Clippy with `-D warnings` already fails on `main`, per `.github/workflows/d3d12.yml`. - `python -I scripts/check_no_game_data.py` on the four files: clean. - `python -I tests/test_d3d12_switches.py`: OK. - `python -m unittest discover -s tests -p "test_docs_*.py"`: 59 tests OK. - finding: `texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers` is flaky under the parallel test runner on unchanged code (it failed 1 of 3 full `cargo test -p leonida-gpu --features diagnostics --lib` runs on `a252854a2`, and passes alone). No game files are needed to see it; seen on the hardware below. GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU 8 GB, driver 621.40, Windows 11 Home 26300 (Intel Core Ultra 7 255HX, 16 GB RAM) AI-assisted: yes (AI coding assistant). A separate, read-only AI reviewer checked the diff before opening; the findings section and the code comment were rewritten after that check. Two more such reviews, on 3 December, checked the rewritten text with `main` merged, and the corrections they asked for are in this version. The change that keeps the maximum was checked by another one before it was pushed, and again after its findings were worked in. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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)
lixonik commented 2026-12-02 20:26:06 +00:00

RUN (in game) -- unit tests + 300 s render-path verification for PR #3198:

  • PR head SHA: 80a627bb1
  • Merged onto main SHA: f1a559851 (git merge --no-ff, clean merge)
  • Clean-room & switch-table checks:
    • python -I scripts/check_no_game_data.py PASS
    • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md PASS
  • Unit tests (Windows 10 x64, Rust 1.98.1): cargo test -p leonida-gpu --features diagnostics --lib --locked residency:: -- 4 passed, 0 failed (including a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory)
  • Build & switch: diag profile (diagnostics,dlss,mimalloc), Series S profile, DLSS on, Frame Gen off, LEONIDA_MIN_WORKING_SET_MB=4096, same restored save snapshot
  • Observed working-set log: 
  • GPU / Driver / OS: NVIDIA GeForce RTX 5070 (12 GB), driver 595.79, Windows 10 x64
Run Time in world World samples Device lost / crashes / errors Median rendered FPS (ms) Slowest / fastest tenth (fps) Median draws
PR #3198 (80a627bb1 on f1a559851, MIN_WORKING_SET_MB=4096) 315 s (440.0 s total) 64 0 / 0 / 0 26.9 fps (37.1 ms) 21.7 / 27.5 4,410
main alone (f1a559851) 303.2 s (480.0 s total) 62 0 / 0 / 0 27.2 fps (36.8 ms) 21.8 / 28.7 4,385

Loaded cleanly into the world with LEONIDA_MIN_WORKING_SET_MB=4096, stayed up past 300 s in-world with 0 device lost / 0 crashes / 0 ERROR lines, and closed cleanly. Rendered FPS matches main (26.9 vs 27.2 fps).

Verdict: PASS.

AI-assisted: yes (Antigravity).

RUN (in game) -- unit tests + 300 s render-path verification for PR #3198: - **PR head SHA:** `80a627bb1` - **Merged onto `main` SHA:** `f1a559851` (`git merge --no-ff`, clean merge) - **Clean-room & switch-table checks:** - `python -I scripts/check_no_game_data.py` PASS - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` PASS - **Unit tests (Windows 10 x64, Rust 1.98.1):** `cargo test -p leonida-gpu --features diagnostics --lib --locked residency::` -- **4 passed, 0 failed** (including `a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory`) - **Build & switch:** `diag` profile (`diagnostics,dlss,mimalloc`), Series S profile, DLSS on, Frame Gen off, **`LEONIDA_MIN_WORKING_SET_MB=4096`**, same restored save snapshot - **Observed working-set log:** `` - **GPU / Driver / OS:** NVIDIA GeForce RTX 5070 (12 GB), driver 595.79, Windows 10 x64 | Run | Time in world | World samples | Device lost / crashes / errors | Median rendered FPS (ms) | Slowest / fastest tenth (fps) | Median draws | | --- | ---: | ---: | --- | ---: | ---: | ---: | | **PR #3198 (`80a627bb1` on `f1a559851`, `MIN_WORKING_SET_MB=4096`)** | 315 s (440.0 s total) | 64 | **0 / 0 / 0** | **26.9 fps** (37.1 ms) | 21.7 / 27.5 | 4,410 | | **`main` alone (`f1a559851`)** | 303.2 s (480.0 s total) | 62 | **0 / 0 / 0** | **27.2 fps** (36.8 ms) | 21.8 / 28.7 | 4,385 | Loaded cleanly into the world with `LEONIDA_MIN_WORKING_SET_MB=4096`, stayed up past 300 s in-world with 0 device lost / 0 crashes / 0 `ERROR` lines, and closed cleanly. Rendered FPS matches `main` (`26.9` vs `27.2` fps). Verdict: **PASS**. AI-assisted: yes (Antigravity).
merzleckeier reviewed 2026-12-02 20:31:05 +00:00
merzleckeier left a comment
No description provided.
Source review on `80a627bb`. This also changes the maximum working-set policy. `residency.rs:301–302` always sets the maximum to physical RAM and disables hard maximum enforcement. Microsoft documents that the soft maximum still guides trimming when memory is scarce, and a hard maximum can already be configured. Thus the current call can relax another limit and the on/off measurement changes both settings. Could you read the current limits and flags with `GetProcessWorkingSetSizeEx`, preserve the maximum and its enforcement where possible, and document or decline a request above an existing hard maximum? If a soft maximum must rise to accommodate the minimum, raising it only that far would isolate the change. [Set API](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-setprocessworkingsetsizeex) · [Get API](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsizeex). Source review only; I did not repeat the Windows workload. AI-assisted.
EdenBendheim commented 2026-12-02 21:01:16 +00:00

RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head 80a627bb19421c51a5c04ab3caaf675b12a07554.

  • Base & build: Merged cleanly via git merge --no-ff onto main b41763227 (diagnostics,dlss,mimalloc, exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit 0; workspace test targets compiled).
  • Batch heads (14 PRs): #3200 d1a91afd1, #3198 80a627bb1, #3191 93b47ac9d, #3189 c182fc392, #3176 ae0075d9a, #3168 337388052, #3164 1065952da, #3146 ebc0253ff, #3124 64600ef0c, #3069 311d33a40, #3031 8df1bfce7, #3029 e49404808, #3054 ff53fd8b9, #3010 d645712a3.
  • Hardware & setup: Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Series X profile, 2560x1440, -NoFrameGen, scripts/game-gate.ps1 (301.3 s in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (GATE CONTROL moved=2.51 m, max_from_ctrl=5,053.9 m).
Metric 14-PR Batch (c47eeb717f761d9d) main b41763227 baseline (cf499737bf684f6a)
Gate verdict / exit PASS (clean, 0 reasons, 0 warnings) PASS (clean, 0 reasons, 0 warnings)
World time 301.3 s (4,504 frames) 305.6 s
Device lost / crashes / missed pipeline waits 0 / 0 / 0 0 / 0 / 0
Rendered FPS (median) / p95 frame time 20.10 FPS / 69.76 ms 19.13 FPS / 74.01 ms
Median draws/frame / longest present gap 8,048 / 5.222 s 7,983 / 2.358 s
Peak private commit / peak VRAM 35,619 MB / 15,251 MB 37,803 MB / 16,220 MB

Verdict: PASS for the 300 s in-game stability gate on 80a627bb1. (Single combined-batch stability check on a 32 GB RAM host, not a low-RAM/single-PR isolated measurement; if the head changes, this run no longer covers it.)

(AI-assisted verification: gemini-4-neon + gpt-6.2-astra.)

**RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch)** — **PASS** covering exact head `80a627bb19421c51a5c04ab3caaf675b12a07554`. - **Base & build:** Merged cleanly via `git merge --no-ff` onto `main` `b41763227` (`diagnostics,dlss,mimalloc`, `exe_sha16 = c47eeb717f761d9d`; changed-file clean-room scan exit `0`; workspace test targets compiled). - **Batch heads (`14` PRs):** `#3200` `d1a91afd1`, `#3198` `80a627bb1`, `#3191` `93b47ac9d`, `#3189` `c182fc392`, `#3176` `ae0075d9a`, `#3168` `337388052`, `#3164` `1065952da`, `#3146` `ebc0253ff`, `#3124` `64600ef0c`, `#3069` `311d33a40`, `#3031` `8df1bfce7`, `#3029` `e49404808`, `#3054` `ff53fd8b9`, `#3010` `d645712a3`. - **Hardware & setup:** Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver `610.88`, Series X profile, `2560x1440`, `-NoFrameGen`, `scripts/game-gate.ps1` (`301.3 s` in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (`GATE CONTROL moved=2.51 m`, `max_from_ctrl=5,053.9 m`). | Metric | 14-PR Batch (`c47eeb717f761d9d`) | `main` `b41763227` baseline (`cf499737bf684f6a`) | |---|---:|---:| | Gate verdict / exit | **PASS** (`clean`, `0` reasons, `0` warnings) | **PASS** (`clean`, `0` reasons, `0` warnings) | | World time | `301.3 s` (`4,504` frames) | `305.6 s` | | Device lost / crashes / missed pipeline waits | `0` / `0` / `0` | `0` / `0` / `0` | | Rendered FPS (median) / p95 frame time | `20.10 FPS` / `69.76 ms` | `19.13 FPS` / `74.01 ms` | | Median draws/frame / longest present gap | `8,048` / `5.222 s` | `7,983` / `2.358 s` | | Peak private commit / peak VRAM | `35,619 MB` / `15,251 MB` | `37,803 MB` / `16,220 MB` | **Verdict:** **PASS** for the 300 s in-game stability gate on `80a627bb1`. *(Single combined-batch stability check on a 32 GB RAM host, not a low-RAM/single-PR isolated measurement; if the head changes, this run no longer covers it.)* *(AI-assisted verification: `gemini-4-neon` + `gpt-6.2-astra`.)*
fiestorra commented 2026-12-02 21:02:26 +00:00

VERIFY-3198 — Windows nativo: el test nuevo muerde y la suite sigue igual

Head (this PR)
Merge base b41763227 = current main
Merged onto main — clean

Ran

cargo test -p leonida-gpu --lib working_set     a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory ... ok
cargo test -p leonida-gpu --lib                 703 passed; 1 failed; 59 ignored

The one failure is this machine's, unchanged all day: descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in (the iGPU artefact of D3D12CreateDevice(None, ..) that #2995 addresses).

Negative control (synthetic, the test ships with the change): I removed the half-memory cap in a copy (let bytes = asked), rebuilt and ran → FAILED: a_working_set_minimum_..., assertion left == right failed: cut to half. The test bites, and it covers the edges I would want: 0 = none, exactly half is not cut, over half is cut, u64::MAX does not wrap, and a 1-byte PC asks for nothing.

The design reads safely: LEONIDA_MIN_WORKING_SET_MB is opt-in (unset or 0 → as before), parsed with a warning on a non-number, capped at half of ullTotalPhys, asked for once when the host device is made, QUOTA_LIMITS_HARDWS_MIN_ENABLE | QUOTA_LIMITS_HARDWS_MAX_DISABLE (a hard minimum, a soft maximum), and a refusal is a tracing::warn! that changes nothing. The docs are the honest kind: findings.md has the 16 GB laptop case (RTX 5060, WARP capture, hard faults) and names the cost — that memory is not other programs' while the game runs, so pressured comes sooner.

What I could not test

  • The effect itself: it needs a memory-pressured machine (16 GB and a title) and a run; here there is 62.9 GB and no run.
  • The SetProcessWorkingSetSizeEx call on a real device: the test covers the arithmetic, not the API's acceptance on this machine (it would need LEONIDA_MIN_WORKING_SET_MB set at start and a device — not exercised).

Written with an AI assistant.

## VERIFY-3198 — Windows nativo: el test nuevo muerde y la suite sigue igual | | | |---|---| | Head | `(this PR)` | | Merge base | `b41763227` = current `main` | | Merged onto | `main` — clean | **Ran** ``` cargo test -p leonida-gpu --lib working_set a_working_set_minimum_is_what_is_asked_and_at_most_half_the_memory ... ok cargo test -p leonida-gpu --lib 703 passed; 1 failed; 59 ignored ``` **The one failure is this machine's**, unchanged all day: `descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in` (the iGPU artefact of `D3D12CreateDevice(None, ..)` that #2995 addresses). **Negative control (synthetic, the test ships with the change)**: I removed the half-memory cap in a copy (`let bytes = asked`), rebuilt and ran → `FAILED: a_working_set_minimum_...`, `assertion left == right failed: cut to half`. **The test bites**, and it covers the edges I would want: 0 = none, exactly half is not cut, over half is cut, `u64::MAX` does not wrap, and a 1-byte PC asks for nothing. **The design reads safely**: `LEONIDA_MIN_WORKING_SET_MB` is **opt-in** (unset or 0 → as before), parsed with a warning on a non-number, capped at half of `ullTotalPhys`, asked for **once** when the host device is made, `QUOTA_LIMITS_HARDWS_MIN_ENABLE | QUOTA_LIMITS_HARDWS_MAX_DISABLE` (a hard minimum, a soft maximum), and a refusal is a `tracing::warn!` that changes nothing. The docs are the honest kind: `findings.md` has the 16 GB laptop case (RTX 5060, WARP capture, hard faults) and **names the cost** — that memory is not other programs' while the game runs, so `pressured` comes sooner. ## What I could not test - **The effect itself**: it needs a memory-pressured machine (16 GB and a title) and a run; here there is 62.9 GB and no run. - **The `SetProcessWorkingSetSizeEx` call on a real device**: the test covers the arithmetic, not the API's acceptance on this machine (it would need `LEONIDA_MIN_WORKING_SET_MB` set at start and a device — not exercised). Written with an AI assistant.
MoonEyes commented 2026-12-03 07:01:31 +00:00

This pull request has a merge conflict with current main (d9b618f10), so it can't be run in game or merged as it is. Could you merge the latest main into it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.

AI-assisted (Claude Code).

This pull request has a merge conflict with current `main` (`d9b618f10`), so it can't be run in game or merged as it is. Could you merge the latest `main` into it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head. AI-assisted (Claude Code).
fiestorra commented 2026-12-03 09:32:40 +00:00

#3198 rebasada y empujada: pr-3198-rebased = 8903c6967 — y las dos secciones de findings.md que chocaban eran distintas, así que van las dos

Es el primer conflicto de esta serie que no era una sola línea, y por eso lo resuelvo de otra forma y lo digo:

d3d12/docs/switches.md   la línea del recuento  → recalculada: 685 names; 645 have a sentence
d3d12/docs/findings.md   DOS secciones distintas:
     HEAD  ## Table constant buffers filled once per list (2026-12-01)
     suyo  ## Memory on a 16 GB laptop: the game paged out, and a minimum kept in…
         → mismo título: False, así que se quedan las dos

Y la decisión de findings.md no es una estrategia, es una lectura: findings.md es un registro cronológico de medidas — cada sección es una medición con su fecha, su tarjeta y su driver — y dos entradas distintas no se pisan: se suman. Si hubieran sido el mismo título, habría tenido que leer cuál manda.

Los números:

rebase sobre d9b618f10      exit 0
marcadores en el commit     0
diff                        4 files changed, +158/−5
pytest test_d3d12_switches  20 passed
cargo test -p leonida-gpu   716 passed; 1 failed (la iGPU de siempre)

Y 716 contra los 715 de main: un test nuevo, en los 2 ficheros .rs que toca.

Rama pr-3198-rebased en el fork, y con esta van trece de los 22.

Lo que me queda por delante, y es lo honesto: los cinco que chocan en código Rust de verdad (#2567, #2856, #3115, #3197, #3205) y los cinco de varios commits con código (#2580, #3124, #3130, #3209, #3214) — esos no los toco con un script, y decir que «se rebasan» sin haberlos mirado sería exactamente el error de esta noche.

## `#3198` rebasada y empujada: `pr-3198-rebased` = `8903c6967` — **y las dos secciones de `findings.md` que chocaban eran distintas, así que van las dos** **Es el primer conflicto de esta serie que no era una sola línea**, **y por eso lo resuelvo de otra forma y lo digo**: ``` d3d12/docs/switches.md la línea del recuento → recalculada: 685 names; 645 have a sentence d3d12/docs/findings.md DOS secciones distintas: HEAD ## Table constant buffers filled once per list (2026-12-01) suyo ## Memory on a 16 GB laptop: the game paged out, and a minimum kept in… → mismo título: False, así que se quedan las dos ``` **Y la decisión de `findings.md` no es una estrategia, es una lectura**: **`findings.md` es un registro cronológico de medidas** — **cada sección es una medición con su fecha, su tarjeta y su driver** — **y dos entradas distintas no se pisan: se suman.** **Si hubieran sido el mismo título, habría tenido que leer cuál manda.** **Los números**: ``` rebase sobre d9b618f10 exit 0 marcadores en el commit 0 diff 4 files changed, +158/−5 pytest test_d3d12_switches 20 passed cargo test -p leonida-gpu 716 passed; 1 failed (la iGPU de siempre) ``` **Y `716` contra los `715` de `main`**: **un test nuevo, en los 2 ficheros `.rs` que toca.** **Rama `pr-3198-rebased` en el fork**, **y con esta van trece de los 22.** **Lo que me queda por delante, y es lo honesto**: **los cinco que chocan en código Rust de verdad** (`#2567`, `#2856`, `#3115`, `#3197`, `#3205`) **y los cinco de varios commits con código** (`#2580`, `#3124`, `#3130`, `#3209`, `#3214`) — **esos no los toco con un script, y decir que «se rebasan» sin haberlos mirado sería exactamente el error de esta noche.**
Lanworm commented 2026-12-03 17:47:00 +00:00

RUN (in game, 8 alternating runs A B B A A B B A, 32 GB desktop): no gain here. Windows already keeps about 28 GB of the game in memory, and the tool's verdict is "B slower" by 0.4 ms (1 %), at the edge of the noise.

  • Build: one diag build (diagnostics,dlss,mimalloc, d3d12/scripts/build-nvidia.ps1) of main f99e479f with this PR's head 80a627bb merged. The only conflict was in d3d12/docs/switches.md, which was taken from main. The code merged cleanly.
  • Sides: the same exe for both. A runs without the setting; B runs with LEONIDA_MIN_WORKING_SET_MB=12288, the same share of RAM as your 6,144 of 16 GB. Every B log has the line at least this much of the game is kept in the PC's memory ... mb=12288 cut_to_half_the_memory=false.
  • Machine: NVIDIA GeForce RTX 5060 Ti 16 GB, Intel i5-12400F (6 cores), 32 GB RAM, Windows 11 Pro 26200.
  • Setup:
    • Series X from the F1 menu: the title's own upscaler from a render scale of 0.6667, no DLSS, -NoFrameGen.
    • The same save each time; the player stood still with the title's idle camera going round its views, 330 s in the world per run.
    • Unattended: the menus were passed with A through LEONIDA_KEYS_FILE, and each run was closed with WM_SYSCOMMAND/SC_CLOSE, as scripts/game-gate.ps1 does.
    • Every run reached the world and ended cleanly. This is not your walking route.

python -I tools/d3d12_ab_compare.py abba, world median frame time:

run 1 A 2 B 3 B 4 A 5 A 6 B 7 B 8 A
median, ms 39.60 40.20 40.30 40.20 41.90 42.30 43.05 42.50
  • mean A 41.05 ms, mean B 41.46 ms
  • B − A: +0.41 ms (+1.0 %), standard error 0.11, 95 % [+0.05, +0.77], 4 pairs, 4 of 4 agree in sign
  • verdict: B slower

Memory, sampled every ~5 s in the world. Each figure is a run's median, given as the range over that side's 4 runs:

game working set PC free Memory\Pages Input/sec
A 27.4 to 29.6 GB 0.76 to 1.29 GB 0 MB/s
B 27.9 to 29.4 GB 0.86 to 1.06 GB 0 to 1 MB/s

residency reported the PC's memory as under pressure in 98 % of its one-second looks on both sides (248 to 261 of 252 to 266 per run), with no difference between A and B.

What this says:

  • On a 32 GB PC the setting has nothing to keep. Windows already holds about 28 GB of the game in memory, well above the 12 GB asked for, and there is almost no paging. The 110 MB/s of page-ins that this PR addresses on 16 GB does not happen here.
  • The +0.41 ms is small, and the cause your doc names for a cost is not seen: residency reports pressure equally often on both sides. The frame time also rose through the series (39.6 → 42.5 ms), and the ABBA order only removes a straight-line drift. So I read it as "no gain, at most about 1 % lost" rather than as a measured cost.
  • This says nothing about 16 GB PCs, where your numbers show the gain. It only suggests the setting is not worth turning on by default for PCs with 32 GB.

Only numbers are quoted here: no logs, captures or game data.

AI-assisted: yes (Claude Code, Claude Opus 5.5). The runs were driven and analysed by the assistant on the submitter's machine.

**RUN (in game, 8 alternating runs A B B A A B B A, 32 GB desktop): no gain here. Windows already keeps about 28 GB of the game in memory, and the tool's verdict is "B slower" by 0.4 ms (1 %), at the edge of the noise.** - **Build:** one `diag` build (`diagnostics,dlss,mimalloc`, `d3d12/scripts/build-nvidia.ps1`) of `main` `f99e479f` with this PR's head `80a627bb` merged. The only conflict was in `d3d12/docs/switches.md`, which was taken from `main`. The code merged cleanly. - **Sides:** the same exe for both. A runs without the setting; B runs with `LEONIDA_MIN_WORKING_SET_MB=12288`, the same share of RAM as your 6,144 of 16 GB. Every B log has the line `at least this much of the game is kept in the PC's memory ... mb=12288 cut_to_half_the_memory=false`. - **Machine:** NVIDIA GeForce RTX 5060 Ti 16 GB, Intel i5-12400F (6 cores), 32 GB RAM, Windows 11 Pro 26200. - **Setup:** - Series X from the F1 menu: the title's own upscaler from a render scale of 0.6667, no DLSS, `-NoFrameGen`. - The same save each time; the player stood still with the title's idle camera going round its views, 330 s in the world per run. - Unattended: the menus were passed with A through `LEONIDA_KEYS_FILE`, and each run was closed with `WM_SYSCOMMAND`/`SC_CLOSE`, as `scripts/game-gate.ps1` does. - Every run reached the world and ended cleanly. This is not your walking route. `python -I tools/d3d12_ab_compare.py abba`, world median frame time: | run | 1 A | 2 B | 3 B | 4 A | 5 A | 6 B | 7 B | 8 A | |---|---|---|---|---|---|---|---|---| | median, ms | 39.60 | 40.20 | 40.30 | 40.20 | 41.90 | 42.30 | 43.05 | 42.50 | - mean A 41.05 ms, mean B 41.46 ms - B − A: **+0.41 ms** (+1.0 %), standard error 0.11, 95 % [+0.05, +0.77], 4 pairs, 4 of 4 agree in sign - verdict: **B slower** Memory, sampled every ~5 s in the world. Each figure is a run's median, given as the range over that side's 4 runs: | | game working set | PC free | `Memory\Pages Input/sec` | |---|---|---|---| | A | 27.4 to 29.6 GB | 0.76 to 1.29 GB | 0 MB/s | | B | 27.9 to 29.4 GB | 0.86 to 1.06 GB | 0 to 1 MB/s | `residency` reported the PC's memory as under pressure in 98 % of its one-second looks on both sides (248 to 261 of 252 to 266 per run), with no difference between A and B. **What this says:** - On a 32 GB PC the setting has nothing to keep. Windows already holds about 28 GB of the game in memory, well above the 12 GB asked for, and there is almost no paging. The 110 MB/s of page-ins that this PR addresses on 16 GB does not happen here. - The +0.41 ms is small, and the cause your doc names for a cost is not seen: `residency` reports pressure equally often on both sides. The frame time also rose through the series (39.6 → 42.5 ms), and the ABBA order only removes a straight-line drift. So I read it as "no gain, at most about 1 % lost" rather than as a measured cost. - This says nothing about 16 GB PCs, where your numbers show the gain. It only suggests the setting is not worth turning on by default for PCs with 32 GB. Only numbers are quoted here: no logs, captures or game data. AI-assisted: yes (Claude Code, Claude Opus 5.5). The runs were driven and analysed by the assistant on the submitter's machine.
pranjalprateek6 commented 2026-12-03 17:54:01 +00:00

Done in d17b595b6, thank you. The limits are read first with GetProcessWorkingSetSizeEx, and only the minimum changes:

  • The maximum, and whether it is enforced, stay as they are. A soft maximum without 64 KiB of room above the minimum is raised to just that (Windows 11 26300 refuses 0 to 6 pages above the minimum and takes 7), and stays soft.
  • A minimum that does not fit under an enforced maximum is declined with a warning: a call that asks for a larger enforced maximum raises it without an error, so the runtime checks.
  • An enforced minimum that is already as large is left, and the limits are read back after the call.

Three new unit tests, one of them against Windows on a process of its own. The old call fails two of them; the third covers the read-back.

You are right that the measurements changed two settings: they were taken with the first form of the call and have not been taken again. The description, findings.md and the function's comment say so. main (09273248c) is merged.

AI-assisted: yes (AI coding assistant).

Done in d17b595b6, thank you. The limits are read first with `GetProcessWorkingSetSizeEx`, and only the minimum changes: - The maximum, and whether it is enforced, stay as they are. A soft maximum without 64 KiB of room above the minimum is raised to just that (Windows 11 26300 refuses 0 to 6 pages above the minimum and takes 7), and stays soft. - A minimum that does not fit under an enforced maximum is declined with a warning: a call that asks for a larger enforced maximum raises it without an error, so the runtime checks. - An enforced minimum that is already as large is left, and the limits are read back after the call. Three new unit tests, one of them against Windows on a process of its own. The old call fails two of them; the third covers the read-back. You are right that the measurements changed two settings: they were taken with the first form of the call and have not been taken again. The description, `findings.md` and the function's comment say so. `main` (09273248c) is merged. AI-assisted: yes (AI coding assistant).
First-time contributor

TAKEN | Otavmacedo | ETA 2026-12-04 07:00 UTC | AI-assisted: Claude Code (Claude Opus 5.5)

The 16 GB desktop this was written for and the A/B above lacked (it ran on 32 GB, where Windows already kept about 28 GB of the game in memory): NVIDIA RTX 3070 8 GB, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file (commit limit 40.9 GB), Windows 11, driver 621.47. Here the game runs at about 23 GB private with 12 GB of it in memory.

  • BUILD: same executable for A and B: main 4d9e4d05d + this PR's head c176e9716 (clean merge), diagnostics,dlss,mimalloc.
  • RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30): on this PC it kept the device in 2 of 2 runs tonight, where the DLSS recipe lost it in 5 of 6 (#2821), so the arms are not cut short by that. Gate runs from one save, mods/gate_driver idle, 600 s in the world, memory stops widened (private 32000, commit left 1500, video memory 900 s).
  • VARIABLE: LEONIDA_MIN_WORKING_SET_MB | A = 0 | B = 6144 (your value for 16 GB). A discarded warm-up, then A B B A.
  • SEND BACK: per run, frame median and p5, longest gap, the game's in-memory peak and private peak, least commit left, and whether the minimum line says it is in force.
TAKEN | Otavmacedo | ETA 2026-12-04 07:00 UTC | AI-assisted: Claude Code (Claude Opus 5.5) The 16 GB desktop this was written for and the A/B above lacked (it ran on 32 GB, where Windows already kept about 28 GB of the game in memory): NVIDIA RTX 3070 8 GB, Ryzen 7 5700X, **16 GB RAM**, fixed 24 GB page file (commit limit 40.9 GB), Windows 11, driver 621.47. Here the game runs at about 23 GB private with 12 GB of it in memory. - BUILD: same executable for A and B: `main` 4d9e4d05d + this PR's head c176e9716 (clean merge), `diagnostics,dlss,mimalloc`. - RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`): on this PC it kept the device in 2 of 2 runs tonight, where the DLSS recipe lost it in 5 of 6 (#2821), so the arms are not cut short by that. Gate runs from one save, `mods/gate_driver` idle, 600 s in the world, memory stops widened (private 32000, commit left 1500, video memory 900 s). - VARIABLE: `LEONIDA_MIN_WORKING_SET_MB` | A = 0 | B = 6144 (your value for 16 GB). A discarded warm-up, then A B B A. - SEND BACK: per run, frame median and p5, longest gap, the game's in-memory peak and private peak, least commit left, and whether the minimum line says it is in force.
First-time contributor

DONE | the A/B taken above | AI-assisted: Claude Code (Claude Opus 5.5)

Short: on this 16 GB desktop with an 8 GB card, LEONIDA_MIN_WORKING_SET_MB=6144 lost the device in 3 of 3 runs, at 303-356 s in the world; the same executable without it reached 600 s in 3 of 3. It did not raise how much of the game Windows kept in memory either (about 12.6-12.9 GB with and without, one B run 14.8 GB): here the game already holds about twice the minimum. I would not make it a default for 16 GB PCs on this evidence. PROVISIONAL (n=3 per arm).

  • BUILD: same executable for A and B: main 4d9e4d05d + this PR's head c176e9716 (clean merge), diagnostics,dlss,mimalloc.
  • MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file (commit limit 39.9 GB). Profile M.
  • RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30); gate runs from one save, mods/gate_driver idle (LEONIDA_GAME_ACTIONS=1), -WorldSeconds 600, memory stops widened (private 32000 MB, commit left 1500 MB, video memory over budget 900 s). Order: a discarded warm-up (B, 300 s), then A B B A, then B A. Caches warm.
  • The minimum's line, in every B run: at least this much of the game is kept in the PC's memory (LEONIDA_MIN_WORKING_SET_MB) mb=6144 cut_to_half_the_memory=false maximum_mb=6144 … maximum_enforced=false; no such line in the A runs.
Run Minimum End In the world fps median / p5 Frame p95 Longest gap In-memory peak Private peak Least commit left Video memory peak / budget Over budget Shared peak
warm-up 6144 time limit (300 s), PASS 301 s 24.0 / 11.4 87.8 ms 5.9 s 12,890 MB 22,506 MB 5,680 MB 7,091 / 7,220 MB 0.0 s 5,146 MB
A1 0 target, PASS 604 s 22.7 / 12.2 82.2 ms 8.4 s 12,888 MB 23,440 MB 4,758 MB 7,236 / 7,181 MB 69.4 s 5,819 MB
B1 6144 device lost 303 s 26.2 / 11.8 85.0 ms 1.3 s 12,653 MB 23,453 MB 4,813 MB 7,356 / 7,181 MB 21.1 s 5,559 MB
B2 6144 device lost 356 s 26.2 / 11.9 84.4 ms 2.8 s 14,784 MB 23,307 MB 4,979 MB 7,469 / 7,168 MB 68.4 s 5,681 MB
A2 0 target, PASS 606 s 25.5 / 14.7 68.0 ms 2.0 s 12,592 MB 23,163 MB 5,077 MB 7,367 / 7,168 MB 313.0 s 5,804 MB
B3 6144 device lost 328 s 27.6 / 12.0 83.4 ms 1.1 s 12,881 MB 23,525 MB 4,711 MB 7,550 / 7,176 MB 41.7 s 5,837 MB
A3 0 target, PASS 609 s 25.4 / 14.1 70.8 ms 1.5 s 12,565 MB 23,190 MB 5,010 MB 7,411 / 7,212 MB 328.7 s 5,875 MB

(fps from presents after 60 s in the world, as summary.json gives them. tools/d3d12_ab_compare.py abba leaves the B runs out because their gate failed, so there is no verdict from the tool; these are the per-run values.)

What the runs say, each tagged:

  • MEASURED (n=3 per arm): B lost the device (0x887A0005) every time, at 303, 356 and 328 s in the world; A never did, each past 600 s. Before this A/B the same recipe on plain main reached 600 s in 2 of 2 runs (#2821), so without the minimum it is 0 losses in 5.
  • MEASURED (n=3 losses): device-removed data (faults) none; nothing in Windows' System log within a minute of any of the three. The first signs: a mesh pipeline refused while being made (B1), in leonida_gpu::draw while textures picked by index were made ready (B2), and a small buffer that could not be placed (B3). This build does not have #3385, so the reason (REMOVED, HUNG, RESET) is not named.
  • MEASURED: the losses fall in the window where, from this save, the title moves the player between placements before a story scene (minutes 4-6 in the world); 4 of the 5 device losses with DLSS on #2821 fell in the same window (the fifth at about 8 minutes, inside the scene). The A runs went through it.
  • MEASURED: the video memory over-budget time does not separate the arms: A2 and A3 spent 313 and 329 s over the budget and kept the device; the B runs 21-68 s.
  • MEASURED: the in-memory peak is about the same in both arms (B 12,653 / 14,784 / 12,881 MB; A 12,888 / 12,592 / 12,565 MB), and the least commit left too (4.7-5.1 GB): the minimum did not change how much of the game stayed in memory here.
  • ASSUMED: why a hard minimum below what the game already holds would cost the device is not shown. One reading to test: the minimum is a hard one (READ IN CODE: residency.rs:418, QUOTA_LIMITS_HARDWS_MIN_ENABLE), which makes 6 GB of the process unavailable to trim while the card's spilled memory (5.6-5.8 GB shared at the peaks of the B runs) also needs the PC's physical pages; on 16 GB that leaves the video memory manager little to move. A run with a smaller value (2048) would say whether it scales.

Not watched: the screen (no one looked during these runs). The A runs past the story transition show the stuck-scene signature reported in #3434; that happens on plain main too (2 of 5 runs there), and with the minimum at 0 this PR does nothing (READ IN CODE: residency.rs:290 returns before any call).

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.

The figures were recomputed from the run records by a separate read-only agent before posting.

DONE | the A/B taken above | AI-assisted: Claude Code (Claude Opus 5.5) **Short: on this 16 GB desktop with an 8 GB card, `LEONIDA_MIN_WORKING_SET_MB=6144` lost the device in 3 of 3 runs, at 303-356 s in the world; the same executable without it reached 600 s in 3 of 3.** It did not raise how much of the game Windows kept in memory either (about 12.6-12.9 GB with and without, one B run 14.8 GB): here the game already holds about twice the minimum. I would not make it a default for 16 GB PCs on this evidence. PROVISIONAL (n=3 per arm). - BUILD: same executable for A and B: `main` 4d9e4d05d + this PR's head c176e9716 (clean merge), `diagnostics,dlss,mimalloc`. - MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file (commit limit 39.9 GB). Profile M. - RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`); gate runs from one save, `mods/gate_driver` idle (`LEONIDA_GAME_ACTIONS=1`), `-WorldSeconds 600`, memory stops widened (private 32000 MB, commit left 1500 MB, video memory over budget 900 s). Order: a discarded warm-up (B, 300 s), then A B B A, then B A. Caches warm. - The minimum's line, in every B run: `at least this much of the game is kept in the PC's memory (LEONIDA_MIN_WORKING_SET_MB) mb=6144 cut_to_half_the_memory=false maximum_mb=6144 … maximum_enforced=false`; no such line in the A runs. | Run | Minimum | End | In the world | fps median / p5 | Frame p95 | Longest gap | In-memory peak | Private peak | Least commit left | Video memory peak / budget | Over budget | Shared peak | |---|---|---|---|---|---|---|---|---|---|---|---|---| | warm-up | 6144 | time limit (300 s), PASS | 301 s | 24.0 / 11.4 | 87.8 ms | 5.9 s | 12,890 MB | 22,506 MB | 5,680 MB | 7,091 / 7,220 MB | 0.0 s | 5,146 MB | | A1 | 0 | target, PASS | 604 s | 22.7 / 12.2 | 82.2 ms | 8.4 s | 12,888 MB | 23,440 MB | 4,758 MB | 7,236 / 7,181 MB | 69.4 s | 5,819 MB | | B1 | 6144 | device lost | 303 s | 26.2 / 11.8 | 85.0 ms | 1.3 s | 12,653 MB | 23,453 MB | 4,813 MB | 7,356 / 7,181 MB | 21.1 s | 5,559 MB | | B2 | 6144 | device lost | 356 s | 26.2 / 11.9 | 84.4 ms | 2.8 s | 14,784 MB | 23,307 MB | 4,979 MB | 7,469 / 7,168 MB | 68.4 s | 5,681 MB | | A2 | 0 | target, PASS | 606 s | 25.5 / 14.7 | 68.0 ms | 2.0 s | 12,592 MB | 23,163 MB | 5,077 MB | 7,367 / 7,168 MB | 313.0 s | 5,804 MB | | B3 | 6144 | device lost | 328 s | 27.6 / 12.0 | 83.4 ms | 1.1 s | 12,881 MB | 23,525 MB | 4,711 MB | 7,550 / 7,176 MB | 41.7 s | 5,837 MB | | A3 | 0 | target, PASS | 609 s | 25.4 / 14.1 | 70.8 ms | 1.5 s | 12,565 MB | 23,190 MB | 5,010 MB | 7,411 / 7,212 MB | 328.7 s | 5,875 MB | (fps from presents after 60 s in the world, as `summary.json` gives them. `tools/d3d12_ab_compare.py abba` leaves the B runs out because their gate failed, so there is no verdict from the tool; these are the per-run values.) What the runs say, each tagged: - MEASURED (n=3 per arm): B lost the device (0x887A0005) every time, at 303, 356 and 328 s in the world; A never did, each past 600 s. Before this A/B the same recipe on plain `main` reached 600 s in 2 of 2 runs (#2821), so without the minimum it is 0 losses in 5. - MEASURED (n=3 losses): device-removed data (faults) none; nothing in Windows' System log within a minute of any of the three. The first signs: a mesh pipeline refused while being made (B1), in `leonida_gpu::draw` while textures picked by index were made ready (B2), and a small buffer that could not be placed (B3). This build does not have #3385, so the reason (REMOVED, HUNG, RESET) is not named. - MEASURED: the losses fall in the window where, from this save, the title moves the player between placements before a story scene (minutes 4-6 in the world); 4 of the 5 device losses with DLSS on #2821 fell in the same window (the fifth at about 8 minutes, inside the scene). The A runs went through it. - MEASURED: the video memory over-budget time does not separate the arms: A2 and A3 spent 313 and 329 s over the budget and kept the device; the B runs 21-68 s. - MEASURED: the in-memory peak is about the same in both arms (B 12,653 / 14,784 / 12,881 MB; A 12,888 / 12,592 / 12,565 MB), and the least commit left too (4.7-5.1 GB): the minimum did not change how much of the game stayed in memory here. - ASSUMED: why a hard minimum below what the game already holds would cost the device is not shown. One reading to test: the minimum is a hard one (READ IN CODE: `residency.rs:418`, `QUOTA_LIMITS_HARDWS_MIN_ENABLE`), which makes 6 GB of the process unavailable to trim while the card's spilled memory (5.6-5.8 GB shared at the peaks of the B runs) also needs the PC's physical pages; on 16 GB that leaves the video memory manager little to move. A run with a smaller value (2048) would say whether it scales. Not watched: the screen (no one looked during these runs). The A runs past the story transition show the stuck-scene signature reported in #3434; that happens on plain `main` too (2 of 5 runs there), and with the minimum at 0 this PR does nothing (READ IN CODE: `residency.rs:290` returns before any call). GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M. The figures were recomputed from the run records by a separate read-only agent before posting.
First-time contributor

Note on my DONE above (comment 25302) | AI-assisted: Claude Code (Claude Opus 5.5)

Later runs on this PC showed that the device loss rate depends on the folder the game runs from (same executable bytes: 2 of 2 lost from a worktree made that night, 2 of 2 kept from my main checkout; #2821, comment 25546). Both arms here ran the same executable from one worktree, so A against B is still a fair comparison: with the minimum 3 of 3 lost, without it 3 of 3 kept (p = 0.05, one-sided Fisher). But the "0 losses in 5 without the minimum" I added from the plain main runs mixed folders, and across all the no-variable runs of the night 10 of 22 lost the device, so read the result as a lead to repeat (ideally the same bytes from a second folder, and the 2048 value), not as settled.

Note on my DONE above (comment 25302) | AI-assisted: Claude Code (Claude Opus 5.5) Later runs on this PC showed that the device loss rate depends on the folder the game runs from (same executable bytes: 2 of 2 lost from a worktree made that night, 2 of 2 kept from my main checkout; #2821, comment 25546). Both arms here ran the same executable from one worktree, so A against B is still a fair comparison: with the minimum 3 of 3 lost, without it 3 of 3 kept (p = 0.05, one-sided Fisher). But the "0 losses in 5 without the minimum" I added from the plain `main` runs mixed folders, and across all the no-variable runs of the night 10 of 22 lost the device, so read the result as a lead to repeat (ideally the same bytes from a second folder, and the 2048 value), not as settled.
First-time contributor

CORRECTION to my DONE above (comment 25302) and my note (comment 25552) | AI-assisted: Claude Code (Claude Opus 5.5)

The device losses I reported for LEONIDA_MIN_WORKING_SET_MB=6144 came from the folder, not the minimum: the same A/B, same executable, run from the folder where the device holds here, kept the device in all six runs, with and without it. I withdraw "I would not make it a default for 16 GB PCs on this evidence": on this PC the minimum shows no measurable effect either way.

Same executable as the first A/B (main 4d9e4d05d + this PR's head c176e9716, exe_sha16 6a581c…), copied into my main checkout's folder for these runs (why: #2821, comment 25546); same recipe (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30, gate from one save, mods/gate_driver idle, 600 s); a discarded warm-up (B), then A B B A B A. The minimum's line (at least this much of the game is kept in the PC's memory … mb=6144) is in every B run.

Run Minimum End In the world fps median / p5 Longest gap In-memory peak Private peak Least commit left Video memory peak / budget Over budget
warm-up 6144 target (300 s), PASS 306 s 28.2 / 12.2 1.1 s 12,264 MB 23,346 MB 4,831 MB 7,319 / 7,176 MB 20.9 s
A1 0 target, PASS 604 s 25.4 / 14.3 1.0 s 12,929 MB 23,148 MB 5,000 MB 7,292 / 7,168 MB 57.4 s
B1 6144 target, PASS 602 s 25.4 / 14.2 1.2 s 13,103 MB 23,231 MB 4,938 MB 7,399 / 7,168 MB 313.7 s
B2 6144 target, PASS 603 s 25.6 / 14.2 1.1 s 12,671 MB 23,244 MB 4,894 MB 7,274 / 7,195 MB 312.8 s
A2 0 target, PASS 605 s 25.6 / 14.2 1.2 s 13,561 MB 23,414 MB 4,746 MB 7,423 / 7,168 MB 318.0 s
B3 6144 target, PASS 605 s 25.3 / 14.3 1.7 s 13,123 MB 23,444 MB 4,718 MB 7,258 / 7,164 MB 302.2 s
A3 0 target, PASS 608 s 25.5 / 14.4 2.3 s 12,859 MB 23,119 MB 5,045 MB 7,345 / 7,176 MB 83.1 s
  • MEASURED (n=3 per arm, from the checkout's folder): B kept the device 3 of 3, A 3 of 3. In the first A/B, from the worktree, B lost it 3 of 3 and A kept it 3 of 3; the same bytes kept the device from one folder and lost it from the other, as in #2821. Why, in that worktree, the losses fell on the three B runs and not on the A runs between them is not explained (with three a side, chance is not ruled out: p = 0.05).
  • MEASURED: the minimum changes nothing else measured here either: in-memory peak 13,103 / 12,671 / 13,123 against 12,929 / 13,561 / 12,859 MB, private peak 23,231 / 23,244 / 23,444 against 23,148 / 23,414 / 23,119 MB, fps median 25.3-25.6 overall.
  • ASSUMED: the PR's case (Windows paging the game out when the PC runs short) may simply not arise on this PC at this recipe: the game holds about 12.7-13.6 GB in memory here, about twice the minimum. So this says nothing against the minimum on PCs that do page the game out; it only takes back my device-loss result.

Apologies for the noise on this PR.

CORRECTION to my DONE above (comment 25302) and my note (comment 25552) | AI-assisted: Claude Code (Claude Opus 5.5) **The device losses I reported for `LEONIDA_MIN_WORKING_SET_MB=6144` came from the folder, not the minimum: the same A/B, same executable, run from the folder where the device holds here, kept the device in all six runs, with and without it.** I withdraw "I would not make it a default for 16 GB PCs on this evidence": on this PC the minimum shows no measurable effect either way. Same executable as the first A/B (`main` 4d9e4d05d + this PR's head c176e9716, `exe_sha16` 6a581c…), copied into my main checkout's folder for these runs (why: #2821, comment 25546); same recipe (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`, gate from one save, `mods/gate_driver` idle, 600 s); a discarded warm-up (B), then A B B A B A. The minimum's line (`at least this much of the game is kept in the PC's memory … mb=6144`) is in every B run. | Run | Minimum | End | In the world | fps median / p5 | Longest gap | In-memory peak | Private peak | Least commit left | Video memory peak / budget | Over budget | |---|---|---|---|---|---|---|---|---|---|---| | warm-up | 6144 | target (300 s), PASS | 306 s | 28.2 / 12.2 | 1.1 s | 12,264 MB | 23,346 MB | 4,831 MB | 7,319 / 7,176 MB | 20.9 s | | A1 | 0 | target, PASS | 604 s | 25.4 / 14.3 | 1.0 s | 12,929 MB | 23,148 MB | 5,000 MB | 7,292 / 7,168 MB | 57.4 s | | B1 | 6144 | target, PASS | 602 s | 25.4 / 14.2 | 1.2 s | 13,103 MB | 23,231 MB | 4,938 MB | 7,399 / 7,168 MB | 313.7 s | | B2 | 6144 | target, PASS | 603 s | 25.6 / 14.2 | 1.1 s | 12,671 MB | 23,244 MB | 4,894 MB | 7,274 / 7,195 MB | 312.8 s | | A2 | 0 | target, PASS | 605 s | 25.6 / 14.2 | 1.2 s | 13,561 MB | 23,414 MB | 4,746 MB | 7,423 / 7,168 MB | 318.0 s | | B3 | 6144 | target, PASS | 605 s | 25.3 / 14.3 | 1.7 s | 13,123 MB | 23,444 MB | 4,718 MB | 7,258 / 7,164 MB | 302.2 s | | A3 | 0 | target, PASS | 608 s | 25.5 / 14.4 | 2.3 s | 12,859 MB | 23,119 MB | 5,045 MB | 7,345 / 7,176 MB | 83.1 s | - MEASURED (n=3 per arm, from the checkout's folder): B kept the device 3 of 3, A 3 of 3. In the first A/B, from the worktree, B lost it 3 of 3 and A kept it 3 of 3; the same bytes kept the device from one folder and lost it from the other, as in #2821. Why, in that worktree, the losses fell on the three B runs and not on the A runs between them is not explained (with three a side, chance is not ruled out: p = 0.05). - MEASURED: the minimum changes nothing else measured here either: in-memory peak 13,103 / 12,671 / 13,123 against 12,929 / 13,561 / 12,859 MB, private peak 23,231 / 23,244 / 23,444 against 23,148 / 23,414 / 23,119 MB, fps median 25.3-25.6 overall. - ASSUMED: the PR's case (Windows paging the game out when the PC runs short) may simply not arise on this PC at this recipe: the game holds about 12.7-13.6 GB in memory here, about twice the minimum. So this says nothing against the minimum on PCs that do page the game out; it only takes back my device-loss result. Apologies for the noise on this PR.
Sign in to join this conversation.
No description provided.