Reuse fenced GPU upload scratch across command lists #1524

Closed
franticfrostin wants to merge 1 commit from upstream-pr/1525 into main
franticfrostin commented 2026-11-24 18:45:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by franticfrostin on 2026-11-24T18:45:32Z.


Summary

Recycle idle D3D12 upload scratch across command lists after the GPU has finished using it. The shared pool holds up to 4 MiB. If the fence wait fails, the submission stops through VIctory’s existing GPU failure reporter before the buffers can be recycled.

Testing

On an RTX 4060 Laptop GPU, two 170-second Series S runs compared pooling on and off in the same build. New scratch allocations dropped from 1,669 to 118, while peak scratch capacity rose from 27.5 to 28.5 MiB. A 150-second Series X run also reached world rendering with the pool enabled.

The earlier live runs used 256 KiB chunks and PR #431. The current patch is rebased onto 940d32f and preserves upstream’s on-demand chunk sizing from 64 KiB to 4 MiB. The shared idle pool is capped at 4 MiB in total and reuses chunks of the requested capacity.

On the rebased patch, four scratch tests passed on hardware and WARP. Workspace Clippy with all features, the default-feature GPU Clippy check, and the asset-policy check also passed. Frame rate and long-session stability remain unverified.

Related work includes dedicated upload pooling in #982 and scratch chunk sizing in #1246. Codex helped write and test this patch.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588957294 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1525). Originally posted by [franticfrostin](https://github.com/franticfrostin) on 2026-11-24T18:45:32Z. --- ## Summary Recycle idle D3D12 upload scratch across command lists after the GPU has finished using it. The shared pool holds up to 4 MiB. If the fence wait fails, the submission stops through VIctory’s existing GPU failure reporter before the buffers can be recycled. ## Testing On an RTX 4060 Laptop GPU, two 170-second Series S runs compared pooling on and off in the same build. New scratch allocations dropped from 1,669 to 118, while peak scratch capacity rose from 27.5 to 28.5 MiB. A 150-second Series X run also reached world rendering with the pool enabled. The earlier live runs used 256 KiB chunks and PR #431. The current patch is rebased onto `940d32f` and preserves upstream’s on-demand chunk sizing from 64 KiB to 4 MiB. The shared idle pool is capped at 4 MiB in total and reuses chunks of the requested capacity. On the rebased patch, four scratch tests passed on hardware and WARP. Workspace Clippy with all features, the default-feature GPU Clippy check, and the asset-policy check also passed. Frame rate and long-session stability remain unverified. Related work includes dedicated upload pooling in #982 and scratch chunk sizing in #1246. Codex helped write and test this patch.
DenRakEiw commented 2026-11-24 19:03:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:57:03Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 53 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including the 3 new scratch pool/reclaim tests)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean fenced upload scratch pooling and reuse across command lists within the shared budget. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045439350 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1525#pullrequestreview-6045439350). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T18:57:03Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 53 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including the 3 new scratch pool/reclaim tests) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean fenced upload scratch pooling and reuse across command lists within the shared budget. Looks good. AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 02:06:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:30:13Z.


Automated triage for the maintainers.

Merge candidate. It merges cleanly. In crates/victory-gpu/src/host.rs, HostList::reset now trims each list's scratch to the peak of its last two recordings, and hands the rest to a process-wide idle pool (IDLE_SCRATCH, at most 4 MiB, reused by exact capacity). Scratch::reserve keeps the old growth policy, and it no longer moves the cursor when an allocation fails. This is only safe if no list is reset while its work is still running. I checked that: Host::execute has the only ExecuteCommandLists in the crate, and it waits on the fence for every group. The PR makes a failed fence wait fatal (fail(..) with the removal report) instead of a warning, which closes the one path where a chunk could be recycled while still in use. That behaviour change is deliberate and worth a maintainer's glance. The measured drop from 1,669 to 118 new scratch allocations in a 170 s run is in the description. Overlap with #982 (dedicated uploads) and #1246 (chunk sizing) is noted there.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149619235 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1525#issuecomment-7149619235). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:30:13Z. --- <!-- victory-triage v1 head=dff5a3bc56e1c91759b1429d3798863ef5421e12 verdict=merge-candidate at=2026-11-25T06:32:08Z --> Automated triage for the maintainers. **Merge candidate.** It merges cleanly. In `crates/victory-gpu/src/host.rs`, `HostList::reset` now trims each list's scratch to the peak of its last two recordings, and hands the rest to a process-wide idle pool (`IDLE_SCRATCH`, at most 4 MiB, reused by exact capacity). `Scratch::reserve` keeps the old growth policy, and it no longer moves the cursor when an allocation fails. This is only safe if no list is reset while its work is still running. I checked that: `Host::execute` has the only `ExecuteCommandLists` in the crate, and it waits on the fence for every group. The PR makes a failed fence wait fatal (`fail(..)` with the removal report) instead of a warning, which closes the one path where a chunk could be recycled while still in use. That behaviour change is deliberate and worth a maintainer's glance. The measured drop from 1,669 to 118 new scratch allocations in a 170 s run is in the description. Overlap with #982 (dedicated uploads) and #1246 (chunk sizing) is noted there. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:02 +00:00
Marvisak commented 2026-11-25 22:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:01:32Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the gain is not shown on main. The measurement (new scratch allocations 1,669 to 118) was taken on an older base with fixed 256 KiB chunks plus another PR. On main each host list already keeps its scratch chunks across resets, and since 9cc37c5f host lists themselves are recycled with their chunks, so the churn the pool removes is not known to exist; the trimming can add some, because a list whose use alternates would free chunks main keeps. The fatal fence-wait change is unrelated and should be its own PR.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175839672 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1525#issuecomment-7175839672). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:01:32Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the gain is not shown on `main`. The measurement (new scratch allocations 1,669 to 118) was taken on an older base with fixed 256 KiB chunks plus another PR. On `main` each host list already keeps its scratch chunks across resets, and since 9cc37c5f host lists themselves are recycled with their chunks, so the churn the pool removes is not known to exist; the trimming can add some, because a list whose use alternates would free chunks `main` keeps. The fatal fence-wait change is unrelated and should be its own PR. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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
Marvisak/VIctory!1524
No description provided.