GPU: pool HostList upload buffers across resets #2017

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

@⁠lizapropanol on GitHub · 2026-11-25 03:10 UTC · original
lizapropanol:perf/pool-list-upload-buffers → main · +171 −5 · 1 files · 1 commits · open

Reuse D3D12 staging upload buffers on HostList across resets instead of creating and mapping a new committed buffer for every HostList::upload call (CopyTextureRegion / CopyTextureRegionX).

Summary

  • Add UploadPool / UploadBuffer on HostList in crates/victory-gpu/src/host.rs and return in-use buffers to the free list in HostList::reset.
  • Bucket pooled allocations in powers of two from 64 KiB (FIRST_UPLOAD_BUFFER) up to 4 MiB (MAX_POOLED_UPLOAD), selecting the smallest free buffer that fits and capping retained pool memory at 32 MiB (MAX_UPLOAD_POOL_BYTES) per list.
  • Keep oversized (> 4 MiB) or over-budget allocations in deferred().uploads so they drop on reset as before.
  • Add tests upload_pool_reuses_smallest_fit_and_enforces_caps and list_upload_reuses_buffers_after_reset_and_skips_pooling_oversized.

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace --locked
  • cargo xtask policy
**@⁠lizapropanol** on GitHub · 2026-11-25 03:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2017) `lizapropanol:perf/pool-list-upload-buffers` → `main` · +171 −5 · 1 files · 1 commits · open Reuse D3D12 staging upload buffers on `HostList` across resets instead of creating and mapping a new committed buffer for every `HostList::upload` call (`CopyTextureRegion` / `CopyTextureRegionX`). ### Summary - Add `UploadPool` / `UploadBuffer` on `HostList` in `crates/victory-gpu/src/host.rs` and return in-use buffers to the free list in `HostList::reset`. - Bucket pooled allocations in powers of two from 64 KiB (`FIRST_UPLOAD_BUFFER`) up to 4 MiB (`MAX_POOLED_UPLOAD`), selecting the smallest free buffer that fits and capping retained pool memory at 32 MiB (`MAX_UPLOAD_POOL_BYTES`) per list. - Keep oversized (> 4 MiB) or over-budget allocations in `deferred().uploads` so they drop on reset as before. - Add tests `upload_pool_reuses_smallest_fit_and_enforces_caps` and `list_upload_reuses_buffers_after_reset_and_skips_pooling_oversized`. ### Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo test --workspace --locked` - `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:51:44 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 03:20 UTC · original

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 0f4fd8c. victory-gpu: 143 passed, 2 failed, 2 ignored; the new upload_pool_reuses_smallest_fit_and_enforces_caps and list_upload_reuses_buffers_after_reset_and_skips_pooling_oversized pass. The 2 are #1744's NVIDIA failures on main (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, the heap-cap ones). Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 03:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2017#issuecomment-7151827160) Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `0f4fd8c`. `victory-gpu`: 143 passed, 2 failed, 2 ignored; the new `upload_pool_reuses_smallest_fit_and_enforces_caps` and `list_upload_reuses_buffers_after_reset_and_skips_pooling_oversized` pass. The 2 are #1744's NVIDIA failures on `main` (`dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, the heap-cap ones). Same as `main` on this hardware. Not run: a title. AI-assisted (Claude Code).
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 03:34 UTC · original

Triage verdict — Choose one upload pool; verify retention and GPU lifetime (0f4fd8c)

Evidence

  • #982 and #1894 pool the same mapped uploads at the host level. This PR keeps them on each list, with a 4 MiB per-entry limit and a 32 MiB cap per list. #1894 proposes a shared 64 MiB idle-pool cap, so the two designs make different tradeoffs when many command lists live at once.
  • The new D3D12 test checks resource and mapped-pointer reuse after reset, but it submits a list without recording a copy that reads the uploads.

Checks and limits

  • The exact-head Windows check passed. I compared source and published checks without rerunning the host test or measuring upload workloads.

Next step

  • Merge at most one pool design. Compare allocation counts and retained bytes across multiple command lists before choosing the cap and ownership model. Keep this PR’s cap and oversized-allocation tests, and add a synthetic copy/readback across reset. If #595’s asynchronous submissions land, require fence completion before recycling an upload still owned by an in-flight list.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 03:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2017#issuecomment-7152036924) **Triage verdict — Choose one upload pool; verify retention and GPU lifetime** (`0f4fd8c`) **Evidence** - #982 and #1894 pool the same mapped uploads at the host level. This PR keeps them on each list, with a 4 MiB per-entry limit and a 32 MiB cap **per list**. #1894 proposes a shared 64 MiB idle-pool cap, so the two designs make different tradeoffs when many command lists live at once. - The new D3D12 test checks resource and mapped-pointer reuse after reset, but it submits a list without recording a copy that reads the uploads. **Checks and limits** - The [exact-head Windows check](https://github.com/Marvisak/VIctory/actions/runs/45538158062/job/138949785917) passed. I compared source and published checks without rerunning the host test or measuring upload workloads. **Next step** - Merge at most one pool design. Compare allocation counts and retained bytes across multiple command lists before choosing the cap and ownership model. Keep this PR’s cap and oversized-allocation tests, and add a synthetic copy/readback across reset. If #595’s asynchronous submissions land, require fence completion before recycling an upload still owned by an in-flight list. This verification was AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:17 UTC · original

Automated triage for the maintainers.

Proposed close.

This pools the mapped upload buffers handed out by HostList::upload (crates/victory-gpu/src/host.rs), which is the shortcut: note on that function. The same change is already open as #1894 (host-wide pool, returned in HostList::reset, capped at 64 buffers / 64 MiB in total), which merges cleanly and was triaged as a merge candidate earlier; #982 is a third take on it. The reuse here is safe for the same reason as there (reset runs only after the list's submissions finished), but the design is weaker on one point: the 32 MiB cap is per HostList, and buffers stay retained for the list's whole life, so a title with many long-lived command lists can keep far more upload memory than #1894's single shared cap allows. There is also no measurement showing upload creation cost in a session.

Proposed for close as a duplicate of #1894; it will be closed in 48 hours unless the author pushes a change (for example, measurements showing the per-list design is better, or porting the cap and oversized-allocation tests onto #1894) or a maintainer removes the label.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 09:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2017#issuecomment-7158135987) <!-- victory-triage v1 head=0f4fd8c6fb2090471f1f2209af03f0520e6c2314 verdict=proposed-close at=2026-11-25T09:17:32Z --> Automated triage for the maintainers. **Proposed close.** This pools the mapped upload buffers handed out by `HostList::upload` (`crates/victory-gpu/src/host.rs`), which is the `shortcut:` note on that function. The same change is already open as #1894 (host-wide pool, returned in `HostList::reset`, capped at 64 buffers / 64 MiB in total), which merges cleanly and was triaged as a merge candidate earlier; #982 is a third take on it. The reuse here is safe for the same reason as there (`reset` runs only after the list's submissions finished), but the design is weaker on one point: the 32 MiB cap is per `HostList`, and buffers stay retained for the list's whole life, so a title with many long-lived command lists can keep far more upload memory than #1894's single shared cap allows. There is also no measurement showing upload creation cost in a session. Proposed for close as a duplicate of #1894; it will be closed in 48 hours unless the author pushes a change (for example, measurements showing the per-list design is better, or porting the cap and oversized-allocation tests onto #1894) or a maintainer removes the label. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2017'
git switch 'github-bot/gh-2017'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2017'
git switch 'github-bot/gh-2017'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2017'
git switch 'main'
git merge --squash 'github-bot/gh-2017'
git switch 'main'
git merge --ff-only 'github-bot/gh-2017'
git switch 'main'
git merge 'github-bot/gh-2017'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2017
No description provided.