fix: let VIctory scratch chunks replace older idle buffers #329

Open
github-bot wants to merge 1 commit from github-bot/gh-329 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 03:35 UTC · original
mauroalvare:codex/victory-scratch-pool-lru → main · +200 −44 · 2 files · 1 commits · open

Change

The command-list scratch pool in VIctory is enabled by default. It takes chunks by exact size, but once its 128 MiB idle pool filled with 4 MiB chunks, it also rejected every returned 256 KiB chunk. A shift to smaller lists could repeatedly allocate upload buffers even while most of the pool sat idle.

Keep recently returned chunks by evicting the oldest idle chunks as needed. The pool enforces its byte cap and releases evicted resources outside its mutex. Only chunks returned by a completed or discarded list enter the pool.

Verification

Windows x64 MSVC debug builds on the RTX 5070 Ti with driver 621.40. Baseline c4c93bdc413191a9dc909998d2d53080a3f0c880 carries the test and its module registration.

Run from third_party/victory.

cargo test --locked --offline -j 2 -p victory-gpu --lib host::scratch_tests::scratch_pool_reuses_small_chunks_after_large_burst -- --exact --nocapture --test-threads=1

The fixture fills the pool with 32 large chunks, then submits six rounds of eight lists requesting 256 KiB each. Three fresh-process A/B pairs reproduced the base allocation assertion failing and the fix passing.

Synthetic measurement after the large burst Base Fix
Small scratch buffers created 48 8
New upload buffer bytes allocated over all six rounds 12 MiB 2 MiB
Scratch reuse hits 0 40
Idle scratch capacity after the last round 128 MiB 126 MiB
GPU readback verified byte for byte 12 MiB 12 MiB
Command Result
baseline-test.exe --test-threads=1 183 passed, 4 failed, 3 ignored
fixed-test.exe --test-threads=1 184 passed, 3 failed, 3 ignored. Includes the exact-size and cap-policy unit test
cargo test --locked --offline -j 2 -p victory-loader --test load_probe 2 passed
cargo xtask policy 200 files passed
cargo test --release --manifest-path rust/Cargo.toml --locked --offline -j 1 Reused 12 passes from the matching Rust and TomBox sources
python -m pytest -ra 1,665 passed with the required runtime and the RTX 5070 Ti
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed
git diff --check Passed

The full victory-gpu runs used the captured Cargo test binaries. Three assertions reproduced on both builds.

  • descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed got None where it expected Some(1).
  • indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots got 0 where it expected 1 in the first result slot on WARP.
  • indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others reported the first differing offsets at 0 through 7 on WARP.

Oracle and test data

The test writes generated byte patterns into ranges allocated by HostList::scratch, copies them to a read-back resource, and verifies every byte after submission completes. It resets the lists between rounds to exercise the real return path. D3D12 resource lifetime and fences

Codex provided AI assistance with the investigation, implementation, and validation.

**@⁠mauroalvare** on GitHub · 2026-11-26 03:35 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/329) `mauroalvare:codex/victory-scratch-pool-lru` → `main` · +200 −44 · 2 files · 1 commits · open ## Change The command-list scratch pool in VIctory is enabled by default. It takes chunks by exact size, but once its 128 MiB idle pool filled with 4 MiB chunks, it also rejected every returned 256 KiB chunk. A shift to smaller lists could repeatedly allocate upload buffers even while most of the pool sat idle. Keep recently returned chunks by evicting the oldest idle chunks as needed. The pool enforces its byte cap and releases evicted resources outside its mutex. Only chunks returned by a completed or discarded list enter the pool. ## Verification Windows x64 MSVC debug builds on the RTX 5070 Ti with driver 621.40. Baseline `c4c93bdc413191a9dc909998d2d53080a3f0c880` carries the test and its module registration. Run from `third_party/victory`. ```powershell cargo test --locked --offline -j 2 -p victory-gpu --lib host::scratch_tests::scratch_pool_reuses_small_chunks_after_large_burst -- --exact --nocapture --test-threads=1 ``` The fixture fills the pool with 32 large chunks, then submits six rounds of eight lists requesting 256 KiB each. Three fresh-process A/B pairs reproduced the base allocation assertion failing and the fix passing. | Synthetic measurement after the large burst | Base | Fix | | --- | ---: | ---: | | Small scratch buffers created | 48 | 8 | | New upload buffer bytes allocated over all six rounds | 12 MiB | 2 MiB | | Scratch reuse hits | 0 | 40 | | Idle scratch capacity after the last round | 128 MiB | 126 MiB | | GPU readback verified byte for byte | 12 MiB | 12 MiB | | Command | Result | | --- | --- | | `baseline-test.exe --test-threads=1` | 183 passed, 4 failed, 3 ignored | | `fixed-test.exe --test-threads=1` | 184 passed, 3 failed, 3 ignored. Includes the exact-size and cap-policy unit test | | `cargo test --locked --offline -j 2 -p victory-loader --test load_probe` | 2 passed | | `cargo xtask policy` | 200 files passed | | `cargo test --release --manifest-path rust/Cargo.toml --locked --offline -j 1` | Reused 12 passes from the matching Rust and TomBox sources | | `python -m pytest -ra` | 1,665 passed with the required runtime and the RTX 5070 Ti | | `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` | All checks passed | | `git diff --check` | Passed | The full `victory-gpu` runs used the captured Cargo test binaries. Three assertions reproduced on both builds. - `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed` got `None` where it expected `Some(1)`. - `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots` got `0` where it expected `1` in the first result slot on WARP. - `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others` reported the first differing offsets at 0 through 7 on WARP. ## Oracle and test data The test writes generated byte patterns into ranges allocated by `HostList::scratch`, copies them to a read-back resource, and verifies every byte after submission completes. It resets the lists between rounds to exercise the real return path. [D3D12 resource lifetime and fences](https://learn.microsoft.com/en-us/windows/win32/direct3d12/fence-based-resource-management) Codex provided AI assistance with the investigation, implementation, and validation.
Keep recently returned scratch chunks under the idle byte cap, releasing oldest buffers after unlocking the pool. Test a large burst followed by repeatedly submitted small lists and verify the GPU copies.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:16 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/329/head:github-bot/gh-329'
git switch 'github-bot/gh-329'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-329'
git switch 'github-bot/gh-329'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-329'
git switch 'github-bot/gh-329'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-329'
git switch 'main'
git merge --squash 'github-bot/gh-329'
git switch 'main'
git merge --ff-only 'github-bot/gh-329'
git switch 'main'
git merge 'github-bot/gh-329'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.