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

Open
pranjalprateek6 wants to merge 5 commits from upstream-pr/3198 into main
pranjalprateek6 commented 2026-12-02 18:27:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by pranjalprateek6 on 2026-12-02T18:27:33Z.


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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5612393124 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198). Originally posted by [pranjalprateek6](https://github.com/pranjalprateek6) on 2026-12-02T18:27:33Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T20:26:06Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7357731115 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7357731115). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T20:26:06Z. --- 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 commented 2026-12-02 20:31:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:31:05Z.

Review: COMMENTED


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 · Get API. Source review only; I did not repeat the Windows workload. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6158434358 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#pullrequestreview-6158434358). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T20:31:05Z. **Review:** COMMENTED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-12-02T21:01:16Z.


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.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358673096 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7358673096). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-12-02T21:01:16Z. --- **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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:02:26Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358701535 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7358701535). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T21:02:26Z. --- ## 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T07:01:31Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370505921 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7370505921). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T07:01:31Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T09:32:40Z.


#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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7373827596 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7373827596). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T09:32:40Z. --- ## `#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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Lanworm on 2026-12-03T17:47:00Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387053635 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7387053635). Originally posted by [Lanworm](https://github.com/Lanworm) on 2026-12-03T17:47:00Z. --- **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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by pranjalprateek6 on 2026-12-03T17:54:01Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387251260 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3198#issuecomment-7387251260). Originally posted by [pranjalprateek6](https://github.com/pranjalprateek6) on 2026-12-03T17:54:01Z. --- 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).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3198:upstream-pr/3198'
git switch 'upstream-pr/3198'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3198'
git switch 'upstream-pr/3198'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3198'
git switch 'upstream-pr/3198'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3198'
git switch 'main'
git merge --squash 'upstream-pr/3198'
git switch 'main'
git merge --ff-only 'upstream-pr/3198'
git switch 'main'
git merge 'upstream-pr/3198'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3198
No description provided.