Skip to content

GPU: pool HostList upload buffers across resets - #2017

Open
lizapropanol wants to merge 1 commit into
Marvisak:mainfrom
lizapropanol:perf/pool-list-upload-buffers
Open

lizapropanol wants to merge 1 commit into
Marvisak:mainfrom
lizapropanol:perf/pool-list-upload-buffers

Conversation

@lizapropanol

Copy link
Copy Markdown

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

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

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).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

HostList upload buffers pooled across resets — allocation reuse; check pool growth bounds on long sessions.

@jeremygold02

Copy link
Copy Markdown
Contributor

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

Evidence

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 GPU: run submissions asynchronously on a host fence timeline #595’s asynchronous submissions land, require fence completion before recycling an upload still owned by an in-flight list.

This verification was AI-assisted.

@Xvania7 Xvania7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto main (940d32f, Windows 10 x64, NVIDIA GeForce RTX 5060, Rust MSVC):

  • cargo test -p victory-gpu --lib -- --test-threads=1 host::tests:: — all 8 host::tests::* tests passed (including list_upload_reuses_buffers_after_reset_and_skips_pooling_oversized and upload_pool_reuses_smallest_fit_and_enforces_caps); the 1 unrelated failure in that filter was descriptor::host::tests::dynamic_slots_are_held_until_released (#1835, NVIDIA 1M descriptor heap cap).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings — 0 warnings
  • cargo xtask policy — ok (182 files ok)

Synthetic tests only; no game data.

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants