GPU: a list gives its scratch chunks back when its submission lands, not after the bury lag #112

Closed
github-bot wants to merge 2 commits from github-bot/gh-112 into main AGit
Owner

@⁠simbaui4life on GitHub · 2026-11-27 18:19 UTC · original
fix/scratch-at-landing → main · +939 −7 · 7 files · 2 commits · closed without merging

Builds on #111 (the memory bench): its commit is included, and only the last commit is new.

This is a port of work originally made for avatarmanz/VIctory-7900XTX (that repository is no longer reachable). The numbers below were measured on this fork.

Cause: a host list kept every scratch chunk it took until its reset, and a list that has run is reset only after the bury lag (host.rs land()/bury_lag()). The lag is 16 submissions on a PC with 32 GB or less (residency::limited_host_ram()) and 64 above. In the relay mode that scripts/play-foxhound.ps1 sets (VICTORY_RELAY=2), the memory bench at only 8 lists a frame had 42 landed lists holding 130.5 MB of 4 MiB chunks. A game run makes far more host lists a frame, so the real amount is likely larger. That is not measured here.

What this does

  • At landing: after the flight's read-backs and next to release_tables(), a list hands its chunks to the spare pool (HostList::release_scratch). This happens at both landing sites in host.rs, through Detached::release_scratch() in list.rs.
    • The card has read the chunks for the last time, and a landed host list is never run again, only reset later.
    • The reasoning is the same as for the early release of descriptor slots. The constant views that scratch_held puts in slots go with release_tables() at the same moment.
  • Nothing is freed earlier than before: the spare pool takes chunks only up to its limit (spare_what_fits). That limit is SPARE_MOST, 128 MiB, on a PC with 32 GB or less, and SPARE_KEPT, 1 GiB, above with VICTORY_KEEP_FREED. Chunks the pool does not take stay with the list and are freed at its reset after the bury lag, as before.
  • Scope and switch: it applies only with shared chunks (VICTORY_SCRATCH_POOL, on by default). VICTORY_SCRATCH_AT_LANDING=0 turns it off.
  • memory_bench_steady_state now asserts that landed lists keep no scratch.

Tested (RTX 4070 Ti, driver 621.01, Windows 11 26200, debug build, 32 GB RAM; the same build with the switch off and on)

VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 switch off switch on
private bytes 591.3 MB 466.6 MB (−21 %)
scratch of landed lists 130.5 MB 0 MB
list scratch alive 160.2 MB 38.8 MB
upload bytes made 184.2 MB 62.8 MB
PC memory shared with the card 322.6 MB 201.1 MB
without the relay (private bytes) 387 MB 387 MB (unchanged)
  • The steady state stays flat with and without the relay. The pressure test passes in both modes.
  • The launcher's full settings (every switch play-foxhound.ps1 sets by default, VICTORY_THIN=1 among them):
    • Switch on, 3 runs: 500–529 MB private after the warm-up, landed scratch 0 MB, list scratch 91–104 MB.
    • Switch off, 1 run: 684 MB private, landed scratch 169 → 182 MB, list scratch 257 MB.
    • All 4 runs failed the steady-state check on a single 64 MB upload buffer made once after the warm-up. The bench PR shows the same step without this commit, and it is there with the switch off too, so this commit does not cause it. The thin path is outside what the bench drives.
  • cargo test -p victory-gpu: 418 passed, 2 failed, 37 ignored, the same as the bench PR. The 2 failures are already on main (indirect::tests::host_list_budget_starts_empty_at_each_submission, indirect::tests::warp_batch_charges_every_execution).
    • descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync failed once in a full run while another test job used the GPU. It passed alone 5 of 5 times and in 4 more full runs. It calls the global sync_heaps(), which tests running beside it also call, so it looks like a race between tests rather than this change.
  • Clippy -D warnings adds nothing (main's existing failures are listed in the bench PR). rustfmt: no new differences in the touched files.

Not tested:

  • In the game (no game data here). That covers the real saving, and whether anything reads scratch after landing that the bench does not exercise (read-backs run before the release, and the thin path is not driven).
  • A PC with more than 32 GB of RAM (bury lag 64, spare pool up to 1 GiB).
  • AMD and other GPUs.

No game data in the commits.

🤖 Generated with Claude Code

**@⁠simbaui4life** on GitHub · 2026-11-27 18:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/112) `fix/scratch-at-landing` → `main` · +939 −7 · 7 files · 2 commits · closed without merging **Builds on #111** (the memory bench): its commit is included, and only the last commit is new. This is a port of work originally made for avatarmanz/VIctory-7900XTX (that repository is no longer reachable). The numbers below were measured on this fork. **Cause:** a host list kept every scratch chunk it took until its reset, and a list that has run is reset only after the bury lag (`host.rs` `land()`/`bury_lag()`). The lag is 16 submissions on a PC with 32 GB or less (`residency::limited_host_ram()`) and 64 above. In the relay mode that `scripts/play-foxhound.ps1` sets (`VICTORY_RELAY=2`), the memory bench at only 8 lists a frame had 42 landed lists holding 130.5 MB of 4 MiB chunks. A game run makes far more host lists a frame, so the real amount is likely larger. That is not measured here. **What this does** - **At landing:** after the flight's read-backs and next to `release_tables()`, a list hands its chunks to the spare pool (`HostList::release_scratch`). This happens at both landing sites in `host.rs`, through `Detached::release_scratch()` in `list.rs`. - The card has read the chunks for the last time, and a landed host list is never run again, only reset later. - The reasoning is the same as for the early release of descriptor slots. The constant views that `scratch_held` puts in slots go with `release_tables()` at the same moment. - **Nothing is freed earlier than before:** the spare pool takes chunks only up to its limit (`spare_what_fits`). That limit is `SPARE_MOST`, 128 MiB, on a PC with 32 GB or less, and `SPARE_KEPT`, 1 GiB, above with `VICTORY_KEEP_FREED`. Chunks the pool does not take stay with the list and are freed at its reset after the bury lag, as before. - **Scope and switch:** it applies only with shared chunks (`VICTORY_SCRATCH_POOL`, on by default). `VICTORY_SCRATCH_AT_LANDING=0` turns it off. - `memory_bench_steady_state` now asserts that landed lists keep no scratch. **Tested** (RTX 4070 Ti, driver 621.01, Windows 11 26200, debug build, 32 GB RAM; the same build with the switch off and on) | `VICTORY_RELAY=2 VICTORY_RELAY_COPY=1` | switch off | switch on | |---|---|---| | private bytes | 591.3 MB | 466.6 MB (−21 %) | | scratch of landed lists | 130.5 MB | 0 MB | | list scratch alive | 160.2 MB | 38.8 MB | | upload bytes made | 184.2 MB | 62.8 MB | | PC memory shared with the card | 322.6 MB | 201.1 MB | | without the relay (private bytes) | 387 MB | 387 MB (unchanged) | - The steady state stays flat with and without the relay. The pressure test passes in both modes. - **The launcher's full settings** (every switch `play-foxhound.ps1` sets by default, `VICTORY_THIN=1` among them): - Switch on, 3 runs: 500–529 MB private after the warm-up, landed scratch 0 MB, list scratch 91–104 MB. - Switch off, 1 run: 684 MB private, landed scratch 169 → 182 MB, list scratch 257 MB. - All 4 runs failed the steady-state check on a single 64 MB upload buffer made once after the warm-up. The bench PR shows the same step without this commit, and it is there with the switch off too, so this commit does not cause it. The thin path is outside what the bench drives. - `cargo test -p victory-gpu`: 418 passed, 2 failed, 37 ignored, the same as the bench PR. The 2 failures are already on main (`indirect::tests::host_list_budget_starts_empty_at_each_submission`, `indirect::tests::warp_batch_charges_every_execution`). - `descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync` failed once in a full run while another test job used the GPU. It passed alone 5 of 5 times and in 4 more full runs. It calls the global `sync_heaps()`, which tests running beside it also call, so it looks like a race between tests rather than this change. - Clippy `-D warnings` adds nothing (main's existing failures are listed in the bench PR). rustfmt: no new differences in the touched files. **Not tested:** - In the game (no game data here). That covers the real saving, and whether anything reads scratch after landing that the bench does not exercise (read-backs run before the release, and the thin path is not driven). - A PC with more than 32 GB of RAM (bury lag 64, spare pool up to 1 GiB). - AMD and other GPUs. No game data in the commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ignored tests memory_bench_steady_state and memory_bench_pressure_lets_idle_go: lists, copies,
submissions, fences and windows through the title-facing methods, with title memory from a
write-watched VirtualAlloc allocator; per-class bytes from the existing counters and private
bytes, flat over 240 frames; idle memory let go when little RAM is said to be free.

A port of the bench made for avatarmanz/VIctory-7900XTX. Here the free RAM said for the test
(host::FREE_RAM_SAID) also reaches crate::residency, whose pressure is on by default on this
fork; the bench reads the process's memory itself (copystat is diagnostics-only here);
pool::memory joins shadow::memory/windows and texture::memory/let_go under
cfg(any(test, feature = "diagnostics")); list::with_state is pub(crate).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A host list kept every scratch chunk it took until its reset, and a list that has run is reset
only after the bury lag (16 submissions on a PC of 32 GB or less, 64 above). In the relay mode
the launcher sets (VICTORY_RELAY=2) the memory bench, at only 8 lists a frame, had 42 landed
lists holding 130.5 MB of 4 MiB chunks.

At landing, after its read-backs and next to release_tables(), a list now hands its chunks to
the spare pool (HostList::release_scratch). The card has read them for the last time. Chunks
the pool does not take stay with the list and are freed at its reset as before, so nothing is
freed earlier than it was. Only with shared chunks (VICTORY_SCRATCH_POOL); off with
VICTORY_SCRATCH_AT_LANDING=0.

Memory bench, RTX 4070 Ti, same build, switch off/on, VICTORY_RELAY=2 VICTORY_RELAY_COPY=1:
- private bytes 591.3 -> 466.6 MB
- scratch of landed lists 130.5 -> 0 MB
- upload bytes made 184.2 -> 62.8 MB
- without the relay unchanged (387 MB)

The steady-state test now asserts that landed lists keep no scratch. A port of the change
made for avatarmanz/VIctory-7900XTX.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:22:47 +00:00
github-bot closed this pull request 2026-11-27 21:47:09 +00:00
Author
Owner

@⁠JoeY54 on GitHub · 2026-11-27 21:41 UTC · original

Independent synthetic validation of this exact PR head 4ad8b9b4dd133bf1b2cfe5cb9ef25754f8fff38e on a PC above the 32 GB RAM threshold.

Environment: RTX 5090 32 GB, driver 621.24; Ryzen 9 9950X3D; 192 GB installed RAM; Windows 11 build 26300; Rust 1.98.1/MSVC. Debug test profile. An independent D3D12 adapter probe confirmed the default device is the RTX 5090 (10de:2b85, software=false). Exclusive GPU use, serial tests, separate process and cache/data directories per case; inherited VICTORY_* variables cleared. No game data or game launch.

Method: same unchanged PR-head build for both switch states. Three relay runs with VICTORY_SCRATCH_AT_LANDING=0, followed by three with =1; VICTORY_RELAY=2 VICTORY_RELAY_COPY=1. Each steady-state run uses the benchmark's 60 warm-up + 240 measured frames.

cargo test -p victory-gpu --lib --locked memory_bench_steady_state -- --ignored --nocapture --test-threads=1
cargo test -p victory-gpu --lib --locked memory_bench_pressure_lets_idle_go -- --ignored --nocapture --test-threads=1

All six relay steady-state runs passed. End-of-measurement values below are MiB (the benchmark labels them MB but divides by 2^20).

Metric Switch off Switch on
Process private bytes, three runs 1239.4 / 1232.1 / 1226.5 584.4 / 582.9 / 582.3
Median private bytes 1232.1 582.9
Landed lists waiting for bury lag 170 in each run 170 in each run
Scratch retained by landed lists 546.5 in each run 0 in each run
Total list scratch 572.2 in each run 30.2 in each run

The median private-byte reduction is 649.2 MiB, about 52.7%, in this synthetic scenario. Both switch states remain flat during the measured interval.

Additional controls:

  • No relay, one steady run per switch state: both passed; private bytes at end 399.4 MiB off / 399.6 MiB on.
  • Pressure test with the fix enabled: no-relay and relay both passed. Idle windows go 8 -> 1 after the injected low-free-RAM condition. Spare scratch goes 272.0 -> 0.5 MiB without relay, and 272.0 -> 25.5 MiB with relay.
  • Those pressure runs still report retained idle list pools (64 / 68, versus warm 2 / 6) and the relevant fetch buffer (32 MiB versus warm 16 MiB). These are separate outstanding reclamation limits; this report does not claim this PR fixes them.

Scope: ten successful benchmark invocations at the exact head (six relay steady, two no-relay steady, two pressure). No source modifications. The complete workspace suite was not run at this standalone PR head. The benchmark does not exercise draws/dispatches, descriptor/texture paths, thin mode or real presentation, and these short runs do not prove long-term leak freedom or game performance. The on/off runs were sequential, not randomized. This adds the previously untested >32 GB RAM case, without claiming coverage beyond the synthetic workload.

AI-assisted by OpenAI Codex.

**@⁠JoeY54** on GitHub · 2026-11-27 21:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/112#issuecomment-7228673814) Independent synthetic validation of this exact PR head `4ad8b9b4dd133bf1b2cfe5cb9ef25754f8fff38e` on a PC above the 32 GB RAM threshold. **Environment:** RTX 5090 32 GB, driver 621.24; Ryzen 9 9950X3D; 192 GB installed RAM; Windows 11 build 26300; Rust 1.98.1/MSVC. Debug test profile. An independent D3D12 adapter probe confirmed the default device is the RTX 5090 (10de:2b85, software=false). Exclusive GPU use, serial tests, separate process and cache/data directories per case; inherited VICTORY_* variables cleared. No game data or game launch. **Method:** same unchanged PR-head build for both switch states. Three relay runs with `VICTORY_SCRATCH_AT_LANDING=0`, followed by three with `=1`; `VICTORY_RELAY=2 VICTORY_RELAY_COPY=1`. Each steady-state run uses the benchmark's 60 warm-up + 240 measured frames. ```text cargo test -p victory-gpu --lib --locked memory_bench_steady_state -- --ignored --nocapture --test-threads=1 cargo test -p victory-gpu --lib --locked memory_bench_pressure_lets_idle_go -- --ignored --nocapture --test-threads=1 ``` All six relay steady-state runs passed. End-of-measurement values below are MiB (the benchmark labels them MB but divides by 2^20). | Metric | Switch off | Switch on | |---|---:|---:| | Process private bytes, three runs | 1239.4 / 1232.1 / 1226.5 | 584.4 / 582.9 / 582.3 | | Median private bytes | 1232.1 | 582.9 | | Landed lists waiting for bury lag | 170 in each run | 170 in each run | | Scratch retained by landed lists | 546.5 in each run | 0 in each run | | Total list scratch | 572.2 in each run | 30.2 in each run | The median private-byte reduction is 649.2 MiB, about 52.7%, in this synthetic scenario. Both switch states remain flat during the measured interval. **Additional controls:** - No relay, one steady run per switch state: both passed; private bytes at end 399.4 MiB off / 399.6 MiB on. - Pressure test with the fix enabled: no-relay and relay both passed. Idle windows go 8 -> 1 after the injected low-free-RAM condition. Spare scratch goes 272.0 -> 0.5 MiB without relay, and 272.0 -> 25.5 MiB with relay. - Those pressure runs still report retained idle list pools (64 / 68, versus warm 2 / 6) and the relevant fetch buffer (32 MiB versus warm 16 MiB). These are separate outstanding reclamation limits; this report does not claim this PR fixes them. **Scope:** ten successful benchmark invocations at the exact head (six relay steady, two no-relay steady, two pressure). No source modifications. The complete workspace suite was not run at this standalone PR head. The benchmark does not exercise draws/dispatches, descriptor/texture paths, thin mode or real presentation, and these short runs do not prove long-term leak freedom or game performance. The on/off runs were sequential, not randomized. This adds the previously untested >32 GB RAM case, without claiming coverage beyond the synthetic workload. AI-assisted by OpenAI Codex.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.