d3d12/gpu: make texture pool commit-aware and default LEONIDA_COMMIT_FLOOR on (D3D12-TEXTURE-POOL-COMMIT-FLOOR) #3201

Open
Jyx0208 wants to merge 1 commit from upstream-pr/3201 into main
Jyx0208 commented 2026-12-02 18:38:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Jyx0208 on 2026-12-02T18:38:13Z.


Claimed in the coordination issue as: D3D12-TEXTURE-POOL-COMMIT-FLOOR (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7353942933)

What and why

Refs: #2821

Under Windows WDDM, every D3D12_HEAP_TYPE_DEFAULT 64 MiB texture heap (pool.rs) is charged 1:1 to process private bytes and system commit charge. On high-VRAM GPUs (or any host whose Windows commit headroom tightens before local VRAM reaches 88% of budget):

  1. resource::let_go_idle() kept idle textures for 10 minutes because LEONIDA_COMMIT_FLOOR was off by default, allowing pool.rs to sprawl up to 244+ 64 MiB texture blocks (15.6+ GiB of VRAM and system commit) and pin them via fragmentation before commit pressure triggered cleanup.
  2. pool::room() scaled STAGING and small block spares down to 1 under commit pressure and 0 under critical_commit(), but never applied commit headroom or critical_commit() to TEXTURES spares (which could keep up to SPARE_KEPT = 64 empty 64 MiB blocks = 4 GiB while VRAM < 85%, and kept SPARE = 2 even when commit was critical), nor did pool::texture_with_cast() guard new 64 MiB heap creation against critical_commit() (unlike pool::small::block()).

This change:

  • Commit-aware texture pool (d3d12/crates/leonida-gpu/src/pool.rs):
    • pool::room() now computes texture_spares(limit, keep, avail_commit, critical): returns 0 under critical_commit() (also stopping Ripe::now() from pre-allocating ahead blocks), caps to 1 below the 4 GiB commit floor, and scales SPARE_KEPT linearly by half of remaining commit headroom above 4 GiB so large-VRAM GPUs do not hoard up to 4 GiB of empty heaps as commit tightens.
    • pool::texture_with_cast() returns None when residency::critical_commit() is true instead of committing a fresh 64 MiB heap (matching pool::small::block(), falling back cleanly to per-texture allocation).
  • Default LEONIDA_COMMIT_FLOOR on (d3d12/crates/leonida-gpu/src/resource.rs, d3d12/docs/switches.md):
    • Enables LEONIDA_COMMIT_FLOOR by default (=0 disables it; LEONIDA_AB still overrides it), so idle textures out of use for >= 2.5 s and >= 60 frames are swept once available commit drops below LEONIDA_COMMIT_FLOOR_MB (default 4096 MiB) before hundreds of 64 MiB blocks fragment and lock system commit.
    • Updates d3d12/docs/switches.md via tools/d3d12_switches.py --out.

Tested

  • Official red/green check (python -I scripts/red_green.py feat/texture-pool-commit-floor --no-fetch): exit 0 (verdict: red then green) — both new hermetic child-process tests (pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit and resource::tests::commit_floor_defaults_on_and_zero_disables_it) fail on origin/main (45dc41f9) and pass on this branch (703 pass on both).
  • Full leonida-gpu unit suite (cargo test --locked -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws): 704 passed, 0 failed.
  • Replay test (cargo test --locked -p leonida-gpu --features diagnostics --test replay): 1 passed, 0 failed.
  • Hygiene checks: python -I scripts/check_no_game_data.py and python -I tools/d3d12_switches.py --check d3d12/docs/switches.md both pass (exit 0).
  • In-world comparison on RTX 4090 D 48 GB / 64 GB RAM + 32 GB pagefile (Series X, -Resolution 1440, Frame Gen 2x):
    • Baseline (a917c54d, LEONIDA_COMMIT_FLOOR off): pool.rs texture blocks grew to 15,616 MB (244 blocks; 269 made), local VRAM peaked at 22,703 MB, process private bytes reached 49,917 MB, available commit dropped from 43,568 MB to 2,212 MB (hitting commit critical 7 times before 0x887A0005 at 79.5 min).
    • Patched (8.5 min fast verification with LEONIDA_COMMIT_FLOOR_MB=20000 to exercise the floor early on 64 GB RAM): 376 commit-floor sweeps recycled 330,946 idle textures (20,578 MB) inside the initial 5,056 MB (79 blocks) with zero new 64 MiB texture blocks created over the remaining 7 minutes; local VRAM stabilized at 11,207 MB, private bytes at 37,001 MB, available commit stayed 15.4–17.2 GB (0 pressure warnings, 0 errors), frame rate 23–29 fps (unchanged), texture refresh 1.6 ms/frame (vs 2.8 ms/frame baseline).

GPUs tested: NVIDIA GeForce RTX 4090 D 48 GB (driver 616.92, Windows 11 10.0.26200).

AI-assisted: yes (Antigravity using Gemini 4 Neon for analysis, implementation, and tests; separate read-only reviewer agent using Gemini 4 Neon audited the diff, edge cases, red/green tests, and clean-room rules).

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 rules changed)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5612536096 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201). Originally posted by [Jyx0208](https://github.com/Jyx0208) on 2026-12-02T18:38:13Z. --- Claimed in the coordination issue as: D3D12-TEXTURE-POOL-COMMIT-FLOOR (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7353942933) ### What and why Refs: #2821 Under Windows WDDM, every `D3D12_HEAP_TYPE_DEFAULT` 64 MiB texture heap (`pool.rs`) is charged 1:1 to process private bytes and system commit charge. On high-VRAM GPUs (or any host whose Windows commit headroom tightens before local VRAM reaches 88% of budget): 1. `resource::let_go_idle()` kept idle textures for 10 minutes because `LEONIDA_COMMIT_FLOOR` was off by default, allowing `pool.rs` to sprawl up to 244+ 64 MiB texture blocks (`15.6+ GiB` of VRAM and system commit) and pin them via fragmentation before commit pressure triggered cleanup. 2. `pool::room()` scaled `STAGING` and `small` block spares down to `1` under commit pressure and `0` under `critical_commit()`, but never applied commit headroom or `critical_commit()` to `TEXTURES` spares (which could keep up to `SPARE_KEPT = 64` empty 64 MiB blocks = `4 GiB` while VRAM < 85%, and kept `SPARE = 2` even when commit was critical), nor did `pool::texture_with_cast()` guard new 64 MiB heap creation against `critical_commit()` (unlike `pool::small::block()`). This change: - **Commit-aware texture pool (`d3d12/crates/leonida-gpu/src/pool.rs`)**: - `pool::room()` now computes `texture_spares(limit, keep, avail_commit, critical)`: returns `0` under `critical_commit()` (also stopping `Ripe::now()` from pre-allocating ahead blocks), caps to `1` below the 4 GiB commit floor, and scales `SPARE_KEPT` linearly by half of remaining commit headroom above 4 GiB so large-VRAM GPUs do not hoard up to 4 GiB of empty heaps as commit tightens. - `pool::texture_with_cast()` returns `None` when `residency::critical_commit()` is true instead of committing a fresh 64 MiB heap (matching `pool::small::block()`, falling back cleanly to per-texture allocation). - **Default `LEONIDA_COMMIT_FLOOR` on (`d3d12/crates/leonida-gpu/src/resource.rs`, `d3d12/docs/switches.md`)**: - Enables `LEONIDA_COMMIT_FLOOR` by default (`=0` disables it; `LEONIDA_AB` still overrides it), so idle textures out of use for >= 2.5 s and >= 60 frames are swept once available commit drops below `LEONIDA_COMMIT_FLOOR_MB` (default `4096 MiB`) before hundreds of 64 MiB blocks fragment and lock system commit. - Updates `d3d12/docs/switches.md` via `tools/d3d12_switches.py --out`. ### Tested - Official red/green check (`python -I scripts/red_green.py feat/texture-pool-commit-floor --no-fetch`): **exit 0 (`verdict: red then green`)** — both new hermetic child-process tests (`pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit` and `resource::tests::commit_floor_defaults_on_and_zero_disables_it`) fail on `origin/main` (`45dc41f9`) and pass on this branch (`703` pass on both). - Full `leonida-gpu` unit suite (`cargo test --locked -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws`): **704 passed, 0 failed**. - Replay test (`cargo test --locked -p leonida-gpu --features diagnostics --test replay`): **1 passed, 0 failed**. - Hygiene checks: `python -I scripts/check_no_game_data.py` and `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` both pass (exit 0). - In-world comparison on RTX 4090 D 48 GB / 64 GB RAM + 32 GB pagefile (Series X, `-Resolution 1440`, Frame Gen 2x): - **Baseline (`a917c54d`, `LEONIDA_COMMIT_FLOOR` off):** `pool.rs` texture blocks grew to `15,616 MB` (`244` blocks; `269` made), local VRAM peaked at `22,703 MB`, process private bytes reached `49,917 MB`, available commit dropped from `43,568 MB` to `2,212 MB` (hitting `commit critical` 7 times before `0x887A0005` at 79.5 min). - **Patched (8.5 min fast verification with `LEONIDA_COMMIT_FLOOR_MB=20000` to exercise the floor early on 64 GB RAM):** `376` commit-floor sweeps recycled `330,946` idle textures (`20,578 MB`) inside the initial **`5,056 MB` (`79` blocks)** with **zero** new 64 MiB texture blocks created over the remaining 7 minutes; local VRAM stabilized at `11,207 MB`, private bytes at `37,001 MB`, available commit stayed `15.4–17.2 GB` (`0` pressure warnings, `0` errors), frame rate `23–29 fps` (unchanged), texture refresh `1.6 ms/frame` (vs `2.8 ms/frame` baseline). GPUs tested: NVIDIA GeForce RTX 4090 D 48 GB (driver 616.92, Windows 11 10.0.26200). AI-assisted: yes (Antigravity using Gemini 4 Neon for analysis, implementation, and tests; separate read-only reviewer agent using Gemini 4 Neon audited the diff, edge cases, red/green tests, and clean-room rules). ### 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 rules changed)
x2Tweek commented 2026-12-02 19:34:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-02T19:34:15Z.


Game-run test of this PR on a high-VRAM card: the textures are let go, but their 64 MiB blocks are not given back.

Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Series X profile, 3840x2160
output, LEONIDA_RENDER_SCALE=0.6667, the title's upscaler, -HardwareRT -SmoothMotion -PrecompileAll -Log,
LEONIDA_REAPER=0. Base: upstream main 0d7a451ab (2026-12-02) plus #3113 and #3182, diag build. Candidate:
the same plus this PR at c7d0c9627. Two runs of about 5.5 minutes each: same save, then city driving. The
numbers come from the runtime's own copystat memory lines and the census line.

After ~5.5 min base with #3201
private bytes 43.4 GB 45.0 GB
commit left (Windows) 5.2 GB 3.5 GB
host textures alive 163,784 / 13.9 GB 26,746 / 5.1 GB
pool.rs textures in blocks 162,550 / 10.9 GB 24,946 / 2.1 GB
pool.rs 64 MiB texture blocks 183 / 11.7 GB 192 / 12.3 GB
card memory in use 20.7 GB 21.6 GB

What happens: with this PR, idle textures are let go once commit headroom falls. Here that was at about
4.5 GB left: the texture count fell from 184k to 24k within 30 s. But the 64 MiB DEFAULT heaps holding them stay
allocated. 192 blocks hold 2.1 GB of live textures, so about 10 GB is empty but still charged. As a result, private
bytes and commit kept their trend, and the card's memory did not drop either.

What would help: a pass that releases (or compacts into) empty or nearly empty texture blocks once their
textures are gone, or a cap on block count driven by the same commit floor. Without it, on a 32 GB card the floor
frees texture objects but not the memory this PR targets.

The runs were not the same route, so I do not compare frame rates between them (27.8 vs 19.4 fps median; the
second drive was busier).

Logs (scrubbed of paths) available on request.

AI-assisted: the measurements and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the
runtime's own log lines from the runs above.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7356383613 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7356383613). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-12-02T19:34:15Z. --- Game-run test of this PR on a high-VRAM card: the textures are let go, but their 64 MiB blocks are not given back. **Setup:** RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Series X profile, 3840x2160 output, `LEONIDA_RENDER_SCALE=0.6667`, the title's upscaler, `-HardwareRT -SmoothMotion -PrecompileAll -Log`, `LEONIDA_REAPER=0`. Base: upstream main `0d7a451ab` (2026-12-02) plus #3113 and #3182, diag build. Candidate: the same plus this PR at `c7d0c9627`. Two runs of about 5.5 minutes each: same save, then city driving. The numbers come from the runtime's own `copystat` memory lines and the `census` line. | After ~5.5 min | base | with #3201 | |---|---|---| | private bytes | 43.4 GB | 45.0 GB | | commit left (Windows) | 5.2 GB | 3.5 GB | | host textures alive | 163,784 / 13.9 GB | **26,746 / 5.1 GB** | | `pool.rs` textures in blocks | 162,550 / 10.9 GB | **24,946 / 2.1 GB** | | `pool.rs` 64 MiB texture blocks | 183 / 11.7 GB | **192 / 12.3 GB** | | card memory in use | 20.7 GB | 21.6 GB | **What happens:** with this PR, idle textures are let go once commit headroom falls. Here that was at about 4.5 GB left: the texture count fell from 184k to 24k within 30 s. But the 64 MiB `DEFAULT` heaps holding them stay allocated. 192 blocks hold 2.1 GB of live textures, so about 10 GB is empty but still charged. As a result, private bytes and commit kept their trend, and the card's memory did not drop either. **What would help:** a pass that releases (or compacts into) empty or nearly empty texture blocks once their textures are gone, or a cap on block count driven by the same commit floor. Without it, on a 32 GB card the floor frees texture objects but not the memory this PR targets. The runs were not the same route, so I do not compare frame rates between them (27.8 vs 19.4 fps median; the second drive was busier). Logs (scrubbed of paths) available on request. AI-assisted: the measurements and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines from the runs above.
merzleckeier commented 2026-12-02 20:26:08 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Source check on c7d0c9627 for the retained-heap observation. At 3.5 GiB available commit the new policy allows at most one fully free spare when room samples that value. That does not cap total blocks: Pool::reclaim only drops free.whole(BLOCK) blocks and waits for returned ranges to become reusable. I verified the exact allocator and policy code in an isolated CPU harness: with three blocks and 64 KiB live in each of two, a zero-spare sweep drops only the wholly free block. The other two drop when their final ranges finish resting. The reported aggregate (2.1 GiB live in 192 blocks) therefore does not show how many whole heaps were releasable. For the next measurement, could you record the wholly free block count next to total blocks, ideally after room runs? That would distinguish fragmentation from a reclaim problem. Synthetic allocator test only; I did not repeat the GPU run. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6158355887 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#pullrequestreview-6158355887). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T20:26:08Z. **Review:** COMMENTED --- Source check on `c7d0c9627` for the retained-heap observation. At 3.5 GiB available commit the new policy allows at most one fully free spare when `room` samples that value. That does not cap total blocks: `Pool::reclaim` only drops `free.whole(BLOCK)` blocks and waits for returned ranges to become reusable. I verified the exact allocator and policy code in an isolated CPU harness: with three blocks and 64 KiB live in each of two, a zero-spare sweep drops only the wholly free block. The other two drop when their final ranges finish resting. The reported aggregate (2.1 GiB live in 192 blocks) therefore does not show how many whole heaps were releasable. For the next measurement, could you record the wholly free block count next to total blocks, ideally after `room` runs? That would distinguish fragmentation from a reclaim problem. Synthetic allocator test only; I did not repeat the GPU run. AI-assisted.
icdmkg2 commented 2026-12-02 20:36:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by icdmkg2 on 2026-12-02T20:36:51Z.


Third-party Windows verification of #3201 (D3D12-TEXTURE-POOL-COMMIT-FLOOR) on head c7d0c9627

  • Head / base: c7d0c962728c70551567bb9f9907d5f23253d986 merged cleanly (git merge --no-ff) onto origin/main b41763227.
  • Machine: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver 621.24 (32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 10.0.26300.9974, rustc 1.98.1.
  • Scope: synthetic / red-green + mutation + D3D12 debug-layer unit tests (no retail title run; complements the RTX 4090 D and RTX 5090 live runs above).

Results (MEASURED)

Check Result
python -I scripts/check_no_game_data.py (all 3 touched files) exit 0
python -I tools/d3d12_switches.py --check d3d12/docs/switches.md exit 0
LEONIDA_ADAPTER=5060 python -I scripts/red_green.py 3201 --mutate exit 0 (verdict: red then green) — both new child-process tests (pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit, resource::tests::commit_floor_defaults_on_and_zero_disables_it) went red → green; 702 pass on both, 1 only on green (ok), 0 failures. --mutate: pool.rs:902 (critical_commit() guard in texture_with_cast) and resource.rs:2840 (commit_floor_enabled default-on) caught; pool.rs:48, :93, resource.rs:2831 does not build; pool.rs:58, :62, :74 (and doc comments :41, resource.rs:2816) not caught.
LEONIDA_ADAPTER=5060 + LEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --features diagnostics --locked --lib -- pool:: resource::tests::commit_floor --test-threads=1 23 passed, 0 failed (note: running pool:: with parallel threads can trip a pre-existing global TEXTURES.resting race in a_texture_gives_its_piece_back_when_it_goes; --test-threads=1 passes cleanly)

Review notes (READ IN CODE)

  • Coverage note (non-blocking): texture_spares's linear scaling above the 4 GiB commit floor ((avail_commit - COMMIT_FLOOR) / (2 * BLOCK)) and the < 4 GiB cap-to-1 branch have no direct pure-function unit test (--mutate only exercises the critical_commit() → 0 path). Adding a small unit test directly on texture_spares(...) would lock down all four branches.
  • Note on #3201 live behavior: as @x2Tweek noted above, sweeping idle textures frees texture objects but leaves 64 MiB DEFAULT blocks pinned whenever at least one live texture remains in a block; that's worth keeping in mind alongside this commit-floor change (even if compaction/reclaim stays a follow-up).

AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358025161 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7358025161). Originally posted by [icdmkg2](https://github.com/icdmkg2) on 2026-12-02T20:36:51Z. --- **Third-party Windows verification of #3201 (`D3D12-TEXTURE-POOL-COMMIT-FLOOR`) on head `c7d0c9627`** - **Head / base:** `c7d0c962728c70551567bb9f9907d5f23253d986` merged cleanly (`git merge --no-ff`) onto `origin/main` `b41763227`. - **Machine:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver `621.24` (`32.0.16.2124`), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 `10.0.26300.9974`, `rustc 1.98.1`. - **Scope:** synthetic / red-green + mutation + D3D12 debug-layer unit tests (no retail title run; complements the RTX 4090 D and RTX 5090 live runs above). ### Results (MEASURED) | Check | Result | |---|---| | `python -I scripts/check_no_game_data.py` (all 3 touched files) | exit `0` | | `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` | exit `0` | | `LEONIDA_ADAPTER=5060` `python -I scripts/red_green.py 3201 --mutate` | **exit `0` (`verdict: red then green`)** — both new child-process tests (`pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit`, `resource::tests::commit_floor_defaults_on_and_zero_disables_it`) went red → green; `702` pass on both, `1` only on green (`ok`), `0` failures. `--mutate`: `pool.rs:902` (`critical_commit()` guard in `texture_with_cast`) and `resource.rs:2840` (`commit_floor_enabled` default-on) **caught**; `pool.rs:48`, `:93`, `resource.rs:2831` `does not build`; `pool.rs:58`, `:62`, `:74` (and doc comments `:41`, `resource.rs:2816`) `not caught`. | | `LEONIDA_ADAPTER=5060` + `LEONIDA_D3D12_DEBUG=1` `cargo test -p leonida-gpu --features diagnostics --locked --lib -- pool:: resource::tests::commit_floor --test-threads=1` | `23 passed, 0 failed` (note: running `pool::` with parallel threads can trip a pre-existing global `TEXTURES.resting` race in `a_texture_gives_its_piece_back_when_it_goes`; `--test-threads=1` passes cleanly) | ### Review notes (READ IN CODE) - **Coverage note (non-blocking):** `texture_spares`'s linear scaling above the 4 GiB commit floor (`(avail_commit - COMMIT_FLOOR) / (2 * BLOCK)`) and the `< 4 GiB` cap-to-`1` branch have no direct pure-function unit test (`--mutate` only exercises the `critical_commit()` → `0` path). Adding a small unit test directly on `texture_spares(...)` would lock down all four branches. - **Note on #3201 live behavior:** as @x2Tweek noted above, sweeping idle textures frees texture objects but leaves 64 MiB `DEFAULT` blocks pinned whenever at least one live texture remains in a block; that's worth keeping in mind alongside this commit-floor change (even if compaction/reclaim stays a follow-up). AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
fiestorra commented 2026-12-02 20:57:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T20:57:01Z.


VERIFY-3201 — Windows nativo: suite sin regresiones, control sintético, y una pregunta sobre el cambio de defecto

Head (this PR)
Merge base 45dc41f95 (behind main b41763227)
Merged onto main — merge-tree clean, git merge --no-ff clean (switches.md auto-merged)

Ran

cargo test -p leonida-gpu --lib     704 passed; 1 failed; 59 ignored    (16.0s)
  pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit ... ok
  resource::tests::commit_floor_defaults_on_and_zero_disables_it ... ok

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

A note for whoever runs this: three lines in the output read test result: ok. 1 passed; … 763 filtered — those are the child processes a couple of tests spawn, not the suite. The suite's own line is the 704 passed; 1 failed; 59 ignored one.

The PR ships its own tests in the same files, so the red side had to be built synthetically: in a copy I made commit_floor() return false under a test variable, rebuilt, and ran — FAILED: resource::tests::commit_floor_defaults_on_and_zero_disables_it. The test bites.

What I would want answered

  • This flips a default: LEONIDA_COMMIT_FLOOR goes from off to on for every user, so idle texture copies are dropped sooner (10 minutes → whatever the floor allows) unless =0 or LEONIDA_AB. A commit-floor-on-by-default is a real behaviour change, and the body's evidence is a red/green run that skips depth_bounds_pipeline_loads_and_filters_…. Is that skip because the test is slow/flaky on the author's machine, and was the default flip measured with LEONIDA_AB (the body mentions it as an override, not as a measurement)? Without that, the default is being changed on reasoning alone.
  • The pool side reads right: texture_spares(limit, keep, avail_commit, critical) returns 0 under critical_commit(), and texture_with_cast() refuses a fresh 64 MiB block rather than committing it — that is the path the #2821 report is about.

What I could not test

  • The memory behaviour itself: no WDDM private-bytes measurement, no game run; the tests are unit-level around the spares arithmetic and the default.
  • critical_commit() on a real machine: the tests drive it directly rather than through a pressured card.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358570919 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7358570919). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T20:57:01Z. --- ## VERIFY-3201 — Windows nativo: suite sin regresiones, control sintético, y una pregunta sobre el cambio de defecto | | | |---|---| | Head | `(this PR)` | | Merge base | `45dc41f95` (behind `main` `b41763227`) | | Merged onto | `main` — `merge-tree` clean, `git merge --no-ff` clean (`switches.md` auto-merged) | **Ran** ``` cargo test -p leonida-gpu --lib 704 passed; 1 failed; 59 ignored (16.0s) pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit ... ok resource::tests::commit_floor_defaults_on_and_zero_disables_it ... ok ``` **The one failure is this machine's**, unchanged all day: `descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in` fails identically on clean `main` (the iGPU artefact of `D3D12CreateDevice(None, ..)` that #2995 addresses). *A note for whoever runs this: three lines in the output read `test result: ok. 1 passed; … 763 filtered` — those are the **child processes** a couple of tests spawn, not the suite. The suite's own line is the `704 passed; 1 failed; 59 ignored` one.* **The PR ships its own tests in the same files, so the red side had to be built synthetically**: in a copy I made `commit_floor()` return `false` under a test variable, rebuilt, and ran — `FAILED: resource::tests::commit_floor_defaults_on_and_zero_disables_it`. The test bites. ## What I would want answered - **This flips a default**: `LEONIDA_COMMIT_FLOOR` goes from off to **on** for every user, so idle texture copies are dropped sooner (10 minutes → whatever the floor allows) unless `=0` or `LEONIDA_AB`. **A commit-floor-on-by-default is a real behaviour change**, and the body's evidence is a red/green run that **skips** `depth_bounds_pipeline_loads_and_filters_…`. Is that skip because the test is slow/flaky on the author's machine, and was the default flip measured with `LEONIDA_AB` (the body mentions it as an override, not as a measurement)? Without that, the default is being changed on reasoning alone. - The pool side reads right: `texture_spares(limit, keep, avail_commit, critical)` returns 0 under `critical_commit()`, and `texture_with_cast()` refuses a fresh 64 MiB block rather than committing it — that is the path the `#2821` report is about. ## What I could not test - **The memory behaviour itself**: no WDDM private-bytes measurement, no game run; the tests are unit-level around the spares arithmetic and the default. - **`critical_commit()` on a real machine**: the tests drive it directly rather than through a pressured card. Written with an AI assistant.
MoonEyes commented 2026-12-02 22:00:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:35Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360094619 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7360094619). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:00:35Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
lixonik commented 2026-12-02 22:25:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:25:04Z.


RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS on head c7d0c9627 (merged cleanly via git merge --no-ff onto main 8877be372).

Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)

  • python -I scripts/check_no_game_data.py -> PASS
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md -> PASS
  • cargo test -p leonida-gpu --lib --locked pool:: -> 22 passed, 0 failed
  • cargo test -p leonida-gpu --lib --locked resource:: -> 30 passed, 0 failed
  • cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked -> PASS

Live In-Game Gate (-SeriesS -NoFrameGen, default env -- LEONIDA_COMMIT_FLOOR on by default)

Run Time in world (total) World samples (max draws) Errors / Device lost Median FPS (ms) Slowest / fastest tenth (fps)
PR #3201 (c7d0c9627 on 8877be372) 315 s (443.9 s) 64 (5,611) 0 / 0 27.0 fps (37.0 ms) 21.5 / 28.2
Matched main (8877be372) 315 s (441.9 s) 63 (4,338) 0 / 0 27.9 fps (35.8 ms) 26.1 / 29.6
  • Telemetry note: LEONIDA_COMMIT_FLOOR was active by default in the residency logs with 0 failed allocations and 0 sweeps under the floor (this host had > 40 GiB commit headroom, so the low-commit eviction path itself was not forced during the run; commit-pressure behavior is covered by the unit tests and this run confirms clean steady-state behavior and zero regressions with default-on LEONIDA_COMMIT_FLOOR).

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360663780 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7360663780). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T22:25:04Z. --- **RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS** on head `c7d0c9627` (merged cleanly via `git merge --no-ff` onto `main` `8877be372`). ### Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79) - `python -I scripts/check_no_game_data.py` -> **PASS** - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` -> **PASS** - `cargo test -p leonida-gpu --lib --locked pool::` -> **22 passed, 0 failed** - `cargo test -p leonida-gpu --lib --locked resource::` -> **30 passed, 0 failed** - `cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked` -> **PASS** ### Live In-Game Gate (`-SeriesS -NoFrameGen`, default env -- `LEONIDA_COMMIT_FLOOR` on by default) | Run | Time in world (total) | World samples (max draws) | Errors / Device lost | Median FPS (ms) | Slowest / fastest tenth (fps) | | --- | ---: | ---: | ---: | ---: | ---: | | **PR #3201 (`c7d0c9627` on `8877be372`)** | `315 s` (`443.9 s`) | `64` (`5,611`) | **`0` / `0`** | **`27.0 fps`** (`37.0 ms`) | `21.5` / `28.2` | | **Matched `main` (`8877be372`)** | `315 s` (`441.9 s`) | `63` (`4,338`) | **`0` / `0`** | **`27.9 fps`** (`35.8 ms`) | `26.1` / `29.6` | - **Telemetry note:** `LEONIDA_COMMIT_FLOOR` was active by default in the residency logs with `0` failed allocations and `0` sweeps under the floor (this host had `> 40 GiB` commit headroom, so the low-commit eviction path itself was not forced during the run; commit-pressure behavior is covered by the unit tests and this run confirms clean steady-state behavior and zero regressions with default-on `LEONIDA_COMMIT_FLOOR`). AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Jyx0208 commented 2026-12-03 03:10:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Jyx0208 on 2026-12-03T03:10:21Z.


Thanks everyone for the thorough reviews, third-party verification, and live runs! Keeping head unchanged at c7d0c9627 so the passing in-game gate run stays valid.

  • @MoonEyes (300 s in-game gate): @lixonik posted a passing 315 s in-world run on current head c7d0c9627 merged onto main 8877be372 (0 errors, 0 device lost, 27.0 fps vs 27.9 fps on main): https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7360663780
  • @fiestorra:
    • The --skip depth_bounds_pipeline_loads_and_filters_draws flag in the PR description came from the canonical AGENTS.md command (cargo test --workspace --exclude xtask --locked -- --skip depth_bounds_pipeline_loads_and_filters_draws), not from a failure on this GPU.
    • On flipping LEONIDA_COMMIT_FLOOR to default-on: while available commit is above 4 GiB, commit_floor() short-circuits (0 sweeps, 0 eviction overhead — confirmed by @lixonik's 315 s run). It only activates once commit drops below 4 GiB (the same threshold where residency enters commit pressure), and LEONIDA_COMMIT_FLOOR=0 (or LEONIDA_AB) can still disable or A/B it.
  • @x2Tweek & @merzleckeier: That matches what we saw in the 80-minute RTX 4090 D baseline too — once ~190–244 64 MiB blocks have already sprawled before commit hits 4 GiB, Pool::reclaim can only free free.whole(BLOCK) heaps, so scattered long-lived textures keep partially-empty blocks pinned (whereas triggering before sprawl kept our 4090 D run flat at 79 blocks / 5.05 GB). Logging wholly-free vs total texture blocks and addressing block fragmentation / compaction belong in a focused follow-up PR per CONTRIBUTING.md (one topic per PR).
  • @icdmkg2: Thanks for running scripts/red_green.py --mutate and LEONIDA_D3D12_DEBUG=1! We intentionally tested via pool::room() using existing origin/main symbols rather than calling the newly introduced texture_spares(...) directly so scripts/red_green.py cleanly evaluates verdict: red then green instead of red does not build.

AI-assisted: yes (Antigravity using Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7366278713 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7366278713). Originally posted by [Jyx0208](https://github.com/Jyx0208) on 2026-12-03T03:10:21Z. --- Thanks everyone for the thorough reviews, third-party verification, and live runs! Keeping head unchanged at `c7d0c9627` so the passing in-game gate run stays valid. - **@MoonEyes (300 s in-game gate):** @lixonik posted a passing 315 s in-world run on current head `c7d0c9627` merged onto `main` `8877be372` (`0` errors, `0` device lost, `27.0 fps` vs `27.9 fps` on `main`): https://github.com/ProjectLeonida/mandy/pull/3201#issuecomment-7360663780 - **@fiestorra:** - The `--skip depth_bounds_pipeline_loads_and_filters_draws` flag in the PR description came from the canonical `AGENTS.md` command (`cargo test --workspace --exclude xtask --locked -- --skip depth_bounds_pipeline_loads_and_filters_draws`), not from a failure on this GPU. - On flipping `LEONIDA_COMMIT_FLOOR` to default-on: while available commit is above `4 GiB`, `commit_floor()` short-circuits (`0` sweeps, `0` eviction overhead — confirmed by @lixonik's 315 s run). It only activates once commit drops below `4 GiB` (the same threshold where `residency` enters commit pressure), and `LEONIDA_COMMIT_FLOOR=0` (or `LEONIDA_AB`) can still disable or A/B it. - **@x2Tweek & @merzleckeier:** That matches what we saw in the 80-minute RTX 4090 D baseline too — once ~190–244 64 MiB blocks have already sprawled before commit hits `4 GiB`, `Pool::reclaim` can only free `free.whole(BLOCK)` heaps, so scattered long-lived textures keep partially-empty blocks pinned (whereas triggering before sprawl kept our 4090 D run flat at `79` blocks / `5.05 GB`). Logging wholly-free vs total texture blocks and addressing block fragmentation / compaction belong in a focused follow-up PR per `CONTRIBUTING.md` (one topic per PR). - **@icdmkg2:** Thanks for running `scripts/red_green.py --mutate` and `LEONIDA_D3D12_DEBUG=1`! We intentionally tested via `pool::room()` using existing `origin/main` symbols rather than calling the newly introduced `texture_spares(...)` directly so `scripts/red_green.py` cleanly evaluates `verdict: red then green` instead of `red does not build`. AI-assisted: yes (Antigravity using Gemini 4 Neon).
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/3201:upstream-pr/3201'
git switch 'upstream-pr/3201'

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/3201'
git switch 'upstream-pr/3201'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3201'
git switch 'upstream-pr/3201'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3201'
git switch 'main'
git merge --squash 'upstream-pr/3201'
git switch 'main'
git merge --ff-only 'upstream-pr/3201'
git switch 'main'
git merge 'upstream-pr/3201'
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!3201
No description provided.