Upload and shared buffers cut from blocks, not each an allocation of its own #991

Merged
0xkn0wh3r3 merged 1 commit from upstream-pr/991 into main 2026-11-28 19:39:38 +00:00
0xkn0wh3r3 commented 2026-11-28 10:48:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T10:48:59Z.


Every upload buffer and every shared buffer (PC memory the CPU maps) was its own committed resource, made resident on the thread that asked for it. That's about a millisecond each, and more while the system pages. A play log (RTX 5070 Ti, 2026-11-28) counted, in each 5 seconds of play:

  • 300 to 441 upload buffers made: 355 to 693 ms of waiting;
  • 220 to 382 shared buffers: 180 to 790 ms;
  • 44 to 51 of the card's own buffers: about 30 ms.

All of it on the threads that translate and submit the title's lists.

What changes

  • Upload and shared buffers of up to 4 MiB are placed in 64 MiB heaps (crate::pool), the way the texture pool places textures. A block is made resident once; a buffer is then one placement and one mapping.
  • A piece comes back when the last reference to its buffer goes (the texture pool's Reclaim, which now names its pool), and rests 2.5 s before it's used again.
  • A piece used before is zeroed by the CPU before it's handed out, since callers rely on a new buffer being zeros (the host copies of title buffers are compared against their card side, which starts as zeros).
  • The card's own buffers are not pooled: no CPU can zero them.
  • Larger buffers are made as before.
  • Empty buffer blocks kept: 2; 1 under memory pressure; 0 when commit is critical.
  • VICTORY_BUFFER_POOL=0 makes each buffer an allocation of its own again. Host::upload_buffer_own and shared_buffer_own are that path.

Tests

  • buffers_up_to_four_mib_are_cut_at_multiples_of_64_kib: which sizes are pooled and the piece each takes.
  • buffers_cut_from_blocks_start_as_zeros_and_come_back: buffers don't overlap, are mapped and start as zeros, also when a piece is used again after its rest.
  • the_card_reads_and_writes_buffers_cut_from_blocks: the card copies what the CPU wrote into a pooled upload buffer into a pooled shared buffer, and the CPU reads it back. Both lie past another buffer in their block.
  • acceptance_buffers_cut_from_blocks: 256 buffers of 64 KiB of each kind, pooled against allocations of their own. With VICTORY_ACCEPTANCE=1 in a release build it fails below 5 times as fast.

Measured (RTX 5070 Ti, release, --test-threads=1), two runs:

256 buffers of 64 KiB Own allocations Cut from a block
Upload 193.5 to 252.7 ms 1.01 to 1.39 ms (139 to 251×)
Shared 130.1 to 164.1 ms 1.02 to 1.10 ms (118 to 160×)

Next to a thread that keeps the system paging, as while a scene loads, one 64 KiB upload buffer took 1.01 ms on average (median 1.15). Pooled it takes 0.06 ms (median 0.003). The slowest pooled call, about 22 ms, is making the block itself, once per 1,024 buffers. 8 MiB buffers aren't pooled: 3.0 ms either way.

About flaky tests under load

With several suites running at once beside busy processes, some watch, descriptor and frame tests in main fail now and then, with this change and without it. They assert on process-wide state that other tests' threads change. This PR doesn't touch them; a fix is in its own commit, to follow separately. On a quiet machine, and in single runs, the suite behaves the same with or without this PR.

Checked

  • cargo test --workspace --locked: all pass (victory-gpu lib: 457 passed, 36 ignored).
  • cargo clippy -p victory-gpu --all-targets, with and without --all-features: nothing in the changed files.
  • Not yet measured in a play session on this branch alone.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539335139 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/991). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T10:48:59Z. --- Every upload buffer and every shared buffer (PC memory the CPU maps) was its own committed resource, made resident on the thread that asked for it. That's about a millisecond each, and more while the system pages. A play log (RTX 5070 Ti, 2026-11-28) counted, in each 5 seconds of play: - 300 to 441 upload buffers made: 355 to 693 ms of waiting; - 220 to 382 shared buffers: 180 to 790 ms; - 44 to 51 of the card's own buffers: about 30 ms. All of it on the threads that translate and submit the title's lists. **What changes** - Upload and shared buffers of up to 4 MiB are placed in 64 MiB heaps (`crate::pool`), the way the texture pool places textures. A block is made resident once; a buffer is then one placement and one mapping. - A piece comes back when the last reference to its buffer goes (the texture pool's `Reclaim`, which now names its pool), and rests 2.5 s before it's used again. - A piece used before is zeroed by the CPU before it's handed out, since callers rely on a new buffer being zeros (the host copies of title buffers are compared against their card side, which starts as zeros). - The card's own buffers are not pooled: no CPU can zero them. - Larger buffers are made as before. - Empty buffer blocks kept: 2; 1 under memory pressure; 0 when commit is critical. - `VICTORY_BUFFER_POOL=0` makes each buffer an allocation of its own again. `Host::upload_buffer_own` and `shared_buffer_own` are that path. **Tests** - `buffers_up_to_four_mib_are_cut_at_multiples_of_64_kib`: which sizes are pooled and the piece each takes. - `buffers_cut_from_blocks_start_as_zeros_and_come_back`: buffers don't overlap, are mapped and start as zeros, also when a piece is used again after its rest. - `the_card_reads_and_writes_buffers_cut_from_blocks`: the card copies what the CPU wrote into a pooled upload buffer into a pooled shared buffer, and the CPU reads it back. Both lie past another buffer in their block. - `acceptance_buffers_cut_from_blocks`: 256 buffers of 64 KiB of each kind, pooled against allocations of their own. With `VICTORY_ACCEPTANCE=1` in a release build it fails below 5 times as fast. Measured (RTX 5070 Ti, release, `--test-threads=1`), two runs: | 256 buffers of 64 KiB | Own allocations | Cut from a block | |---|---|---| | Upload | 193.5 to 252.7 ms | 1.01 to 1.39 ms (139 to 251×) | | Shared | 130.1 to 164.1 ms | 1.02 to 1.10 ms (118 to 160×) | Next to a thread that keeps the system paging, as while a scene loads, one 64 KiB upload buffer took 1.01 ms on average (median 1.15). Pooled it takes 0.06 ms (median 0.003). The slowest pooled call, about 22 ms, is making the block itself, once per 1,024 buffers. 8 MiB buffers aren't pooled: 3.0 ms either way. **About flaky tests under load** With several suites running at once beside busy processes, some watch, descriptor and frame tests in `main` fail now and then, with this change and without it. They assert on process-wide state that other tests' threads change. This PR doesn't touch them; a fix is in its own commit, to follow separately. On a quiet machine, and in single runs, the suite behaves the same with or without this PR. **Checked** - `cargo test --workspace --locked`: all pass (victory-gpu lib: 457 passed, 36 ignored). - `cargo clippy -p victory-gpu --all-targets`, with and without `--all-features`: nothing in the changed files. - Not yet measured in a play session on this branch alone.
Exopus-0x65f7ad0 commented 2026-11-28 13:23:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Exopus-0x65f7ad0 on 2026-11-28T13:23:05Z.


A play session on this branch, since the PR says it hasn't had one yet.

Setup: RTX 5060 Ti 8 GB (DXGI local budget ~7.0 GB), 16 GB RAM (64 GB page file), Windows 11 26300. 63b902f plus this PR, plus a few local commits that don't touch host.rs buffers or pool.rs. README launcher defaults (Series X, native 1440p, DLSS Quality, no frame generation). Opening prison room, same save as my baseline from this morning. 90 s scripted walk (stick input), fps read from the window title every 2 s.

baseline (same machine, no PR) with #991
rendered fps on the walk, mean (min–max) 14.1 (10–22) 15.5 (5–24)
rendered fps in the opening cutscene 15–19 18–20
no upload buffer / no shared buffer 0 / 0 0 / 0
no block of buffers / a block of buffers is not resident — 0 / 0
victory.exe private bytes at the end ~21.2 GB ~22.1 GB
  • Stability: fine. It loaded, played the cutscene and the walk, with no new warnings and none of the new failure lines.
  • Speed: a small gain (+1.4 fps on the mean, cutscene a bit steadier), but within what I'd call noise for one run on a GPU-bound, VRAM-full 8 GB card (texture queue's room … 90.0 % of a budget of 7013 MB: no room most of the run). The submitting threads' buffer-creation time this PR removes is real, but this card is limited elsewhere, so I wouldn't expect a big number here. A CPU-bound machine should show it better.
  • Memory: about +0.9 GB of private bytes. That's within run-to-run variation, but kept 64 MiB blocks are the likely cost. On a 16 GB machine that's worth keeping an eye on, since the D3D12 non-local budget is what runs out first on 8 GB cards (see my numbers on #953).

No regressions seen. 👍

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239897331 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/991#issuecomment-7239897331). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-28T13:23:05Z. --- A play session on this branch, since the PR says it hasn't had one yet. **Setup:** RTX 5060 Ti 8 GB (DXGI local budget ~7.0 GB), 16 GB RAM (64 GB page file), Windows 11 26300. `63b902f` plus this PR, plus a few local commits that don't touch `host.rs` buffers or `pool.rs`. README launcher defaults (Series X, native 1440p, DLSS Quality, no frame generation). Opening prison room, same save as my baseline from this morning. 90 s scripted walk (stick input), fps read from the window title every 2 s. | | baseline (same machine, no PR) | with #991 | |---|---|---| | rendered fps on the walk, mean (min–max) | 14.1 (10–22) | **15.5** (5–24) | | rendered fps in the opening cutscene | 15–19 | 18–20 | | `no upload buffer` / `no shared buffer` | 0 / 0 | 0 / 0 | | `no block of buffers` / `a block of buffers is not resident` | — | 0 / 0 | | `victory.exe` private bytes at the end | ~21.2 GB | ~22.1 GB | - **Stability:** fine. It loaded, played the cutscene and the walk, with no new warnings and none of the new failure lines. - **Speed:** a small gain (+1.4 fps on the mean, cutscene a bit steadier), but within what I'd call noise for one run on a GPU-bound, VRAM-full 8 GB card (`texture queue's room … 90.0 % of a budget of 7013 MB: no room` most of the run). The submitting threads' buffer-creation time this PR removes is real, but this card is limited elsewhere, so I wouldn't expect a big number here. A CPU-bound machine should show it better. - **Memory:** about +0.9 GB of private bytes. That's within run-to-run variation, but kept 64 MiB blocks are the likely cost. On a 16 GB machine that's worth keeping an eye on, since the D3D12 non-local budget is what runs out first on 8 GB cards (see my numbers on #953). No regressions seen. 👍
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
trustno1-coder/VIctory-NVIDIA!991
No description provided.