Card copies' hashes in shared 1 MiB buffers (VICTORY_PACK_HASHES=1, off by default); live card buffers in the log #945

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

@⁠Robotniq on GitHub · 2026-11-28 09:38 UTC · original
Robotniq:pr-hashes → main · +254 −10 · 2 files · 1 commits · open

What was wrong

Every card copy of a title buffer that shaders are declared to write gets a committed buffer of its own for the hashes of its 64 KiB pieces (Shadow::card_make_before, made with Host::uav_buffer(card_hash_bytes(size))): (size / 64 KiB + 2) * 16 bytes, 48 bytes for most copies. With VICTORY_CARD_BUFFERS_MIN_KB=64, which both launchers set, there are thousands of them: on main at 63b902f with the launcher as shipped, about 3,150 were alive near the end of a 5-minute run on my 8 GB card (see the table below).

On this card a committed buffer takes far more than it asks for. The ignored test in this branch makes some and reads DXGI's CurrentUsage: 2,000 buffers of 256 bytes raised it by 73 MB, about 36 KiB each. As a check, 20 buffers of 1 MiB read as about 947 KiB each, so these readings are approximate. If a 48-byte buffer costs what a 256-byte one does, the hashes held about 110 MB of the card.

No line of the log shows this. "host copies in the card's memory: ... their bytes from before" counts the 48 bytes (it says 0 MB), and "made so far: ... card buffers" counts what was made since the start, not what is alive.

What changes

  • VICTORY_PACK_HASHES=1 (off by default; unset, every copy keeps a buffer of its own, as now). Hashes of up to 32 KiB lie in slots of shared 1 MiB buffers, one set per size class (256 B, 512 B ... 32 KiB); larger ones keep their own buffer. A slot goes back when its copy goes and is taken again 10 s later at the earliest. A copy that gets a slot has all its pieces hashed into it first, as with a new buffer. Shadow::card_sides now gives the hashes' address on the card (Option<u64>) instead of a buffer, and the two SetComputeRootUnorderedAccessView(2, ...) calls take it as it is. The hashes are only reached through that root view, and the barrier before the compare is a UAV barrier on no resource, so no barrier names a shared buffer (the reasoning of VICTORY_BUDGET_PACK's slots). The shared buffers stay until the end of the run.
  • A line every 30 s, from the sweep: the card buffers Host::uav_buffer made that are alive, by the size asked for (4 KiB or less, over 4 KiB up to 64 KiB, larger), each with the bytes asked for rounded up to a multiple of 64 KiB (so more than the ~36 KiB measured above for the small ones). A buffer is counted until its last release, through a COM object kept as its private data, the way book.rs learns when its objects go. No switch: it costs a box and one SetPrivateDataInterface call per buffer made.
  • small_buffers_cost_the_card, an ignored test for the cost above (cargo test -p victory-gpu small_buffers_cost_the_card -- --ignored --nocapture). small_buffers_cost in host/place.rs measures buffers of 64 KiB; this one measures 256 bytes against 1 MiB.

With the switch unset, nothing changes but the new line.

Measured

RTX 3070 Ti 8 GB, i7-13700F, 32 GB RAM, Windows 11, driver 621.40. Series S profile, DLSS Quality, the title's ray tracing off (its 43 ray-tracing pipelines left out with VICTORY_SKIP_PIPELINES), VICTORY_CARD_ROOM_FOR_TARGETS_MB=1600, VICTORY_TEXTURE_ROOM_PERCENT=85, diagnostics build through play-foxhound.ps1 -Build diag. The same save each time, keys sent by a script, 300 s from when the world starts. fps is the median of the frame-rate lines after the first minute and moves about ±1 between runs.

On main at 63b902f with this branch, the launcher as shipped (memory stack on, VICTORY_INDIRECT_CARD_BUDGET at its default), one run each after a warm-up run; the two runs' switch lists differ only in this switch:

unset VICTORY_PACK_HASHES=1
card buffers alive asked for 4 KiB or less, near the end 4,135 977
fps, median after the first minute 22.1 22.3
peak in use 6,788 MB 6,791 MB
error lines Streamline's presentCommon() line, which every run has the same
  • The 977 left are the host lists' 256-byte card budgets (about one per host list); VICTORY_INDIRECT_CARD_BUDGET=0 removes those, and this change does not touch them.
  • About 110 MB of the card back by the estimate above (3,158 buffers); one run's peak moves by ±300 MB from run to run, so it does not show there.
  • The fps difference (0.2) is inside the run-to-run noise.

Earlier, on my own tree (based on 0cef07e with the fxceless/victory-fork tree of 27 November merged in and changes of my own), the same switch took the count from 3,214 to 1 with VICTORY_INDIRECT_CARD_BUDGET=0, fps 25.4 and 24.9 (one pair), and every later run that day had it on with no device loss. A review of the change by another AI model (GPT, through Codex) found no lifetime problem: when fences complete normally, a slot cannot be taken again while a submission that wrote it is in flight.

Tests

  • cargo clippy --workspace --all-targets --locked -- -D warnings, plain and with --all-features: no warning from this change. On 63b902f clippy already stops on three warnings of main's own (clippy::let_and_return in victory-shader/src/emit/mod.rs, clippy::manual_is_multiple_of in victory-gpu/src/shadow.rs and, with --all-features, in victory-gpu/src/descriptor.rs), the ones #705 clears.
  • cargo test --workspace --locked: all pass, no failure (victory-gpu: 453 passed, 37 ignored).
  • small_buffers_cost_the_card by hand on the RTX 3070 Ti: the 73 MB and 947 KiB above.

Not tested

  • Other cards and drivers, AMD and Intel included: what a small committed buffer costs may differ.
  • Series X, frame generation, the title's ray tracing on.
  • A session longer than the 5-minute test with it on.
  • A fence wait that fails: then only the 10 s keeps a slot from being taken again.

Notes

  • BudgetSlot gives its slots back through retire. I kept the 10 s wait because that is what ran; I can switch to retire if you prefer.
  • If #890 goes in, cards under 10 GiB keep the 16 MiB floor and have few card copies, so this would matter mostly where VICTORY_CARD_BUFFERS_MIN_KB=64 still holds.
  • #884 and #682 also change Host::uav_buffer. Whichever lands second moves the one count_uav call to where the card buffer is made.

Measured with AI assistance (Claude Code); the runs were made on my machine.

🤖 Generated with Claude Code

https://claude.ai/code/session_017D5NZ3Fd7undwVFyu8fQN1

**@⁠Robotniq** on GitHub · 2026-11-28 09:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/945) `Robotniq:pr-hashes` → `main` · +254 −10 · 2 files · 1 commits · open ## What was wrong Every card copy of a title buffer that shaders are declared to write gets a committed buffer of its own for the hashes of its 64 KiB pieces (`Shadow::card_make_before`, made with `Host::uav_buffer(card_hash_bytes(size))`): `(size / 64 KiB + 2) * 16` bytes, 48 bytes for most copies. With `VICTORY_CARD_BUFFERS_MIN_KB=64`, which both launchers set, there are thousands of them: on `main` at 63b902f with the launcher as shipped, about 3,150 were alive near the end of a 5-minute run on my 8 GB card (see the table below). On this card a committed buffer takes far more than it asks for. The ignored test in this branch makes some and reads DXGI's `CurrentUsage`: 2,000 buffers of 256 bytes raised it by 73 MB, about 36 KiB each. As a check, 20 buffers of 1 MiB read as about 947 KiB each, so these readings are approximate. If a 48-byte buffer costs what a 256-byte one does, the hashes held about 110 MB of the card. No line of the log shows this. "host copies in the card's memory: ... their bytes from before" counts the 48 bytes (it says 0 MB), and "made so far: ... card buffers" counts what was made since the start, not what is alive. ## What changes - `VICTORY_PACK_HASHES=1` (off by default; unset, every copy keeps a buffer of its own, as now). Hashes of up to 32 KiB lie in slots of shared 1 MiB buffers, one set per size class (256 B, 512 B ... 32 KiB); larger ones keep their own buffer. A slot goes back when its copy goes and is taken again 10 s later at the earliest. A copy that gets a slot has all its pieces hashed into it first, as with a new buffer. `Shadow::card_sides` now gives the hashes' address on the card (`Option<u64>`) instead of a buffer, and the two `SetComputeRootUnorderedAccessView(2, ...)` calls take it as it is. The hashes are only reached through that root view, and the barrier before the compare is a UAV barrier on no resource, so no barrier names a shared buffer (the reasoning of `VICTORY_BUDGET_PACK`'s slots). The shared buffers stay until the end of the run. - A line every 30 s, from the sweep: the card buffers `Host::uav_buffer` made that are alive, by the size asked for (4 KiB or less, over 4 KiB up to 64 KiB, larger), each with the bytes asked for rounded up to a multiple of 64 KiB (so more than the ~36 KiB measured above for the small ones). A buffer is counted until its last release, through a COM object kept as its private data, the way `book.rs` learns when its objects go. No switch: it costs a box and one `SetPrivateDataInterface` call per buffer made. - `small_buffers_cost_the_card`, an ignored test for the cost above (`cargo test -p victory-gpu small_buffers_cost_the_card -- --ignored --nocapture`). `small_buffers_cost` in `host/place.rs` measures buffers of 64 KiB; this one measures 256 bytes against 1 MiB. With the switch unset, nothing changes but the new line. ## Measured RTX 3070 Ti 8 GB, i7-13700F, 32 GB RAM, Windows 11, driver 621.40. Series S profile, DLSS Quality, the title's ray tracing off (its 43 ray-tracing pipelines left out with `VICTORY_SKIP_PIPELINES`), `VICTORY_CARD_ROOM_FOR_TARGETS_MB=1600`, `VICTORY_TEXTURE_ROOM_PERCENT=85`, diagnostics build through `play-foxhound.ps1 -Build diag`. The same save each time, keys sent by a script, 300 s from when the world starts. fps is the median of the frame-rate lines after the first minute and moves about ±1 between runs. On `main` at 63b902f with this branch, the launcher as shipped (memory stack on, `VICTORY_INDIRECT_CARD_BUDGET` at its default), one run each after a warm-up run; the two runs' switch lists differ only in this switch: | | unset | `VICTORY_PACK_HASHES=1` | |---|---:|---:| | card buffers alive asked for 4 KiB or less, near the end | 4,135 | 977 | | fps, median after the first minute | 22.1 | 22.3 | | peak in use | 6,788 MB | 6,791 MB | | error lines | Streamline's `presentCommon()` line, which every run has | the same | - The 977 left are the host lists' 256-byte card budgets (about one per host list); `VICTORY_INDIRECT_CARD_BUDGET=0` removes those, and this change does not touch them. - About 110 MB of the card back by the estimate above (3,158 buffers); one run's peak moves by ±300 MB from run to run, so it does not show there. - The fps difference (0.2) is inside the run-to-run noise. Earlier, on my own tree (based on 0cef07e with the fxceless/victory-fork tree of 27 November merged in and changes of my own), the same switch took the count from 3,214 to 1 with `VICTORY_INDIRECT_CARD_BUDGET=0`, fps 25.4 and 24.9 (one pair), and every later run that day had it on with no device loss. A review of the change by another AI model (GPT, through Codex) found no lifetime problem: when fences complete normally, a slot cannot be taken again while a submission that wrote it is in flight. ## Tests - `cargo clippy --workspace --all-targets --locked -- -D warnings`, plain and with `--all-features`: no warning from this change. On 63b902f clippy already stops on three warnings of main's own (`clippy::let_and_return` in `victory-shader/src/emit/mod.rs`, `clippy::manual_is_multiple_of` in `victory-gpu/src/shadow.rs` and, with `--all-features`, in `victory-gpu/src/descriptor.rs`), the ones #705 clears. - `cargo test --workspace --locked`: all pass, no failure (`victory-gpu`: 453 passed, 37 ignored). - `small_buffers_cost_the_card` by hand on the RTX 3070 Ti: the 73 MB and 947 KiB above. ## Not tested - Other cards and drivers, AMD and Intel included: what a small committed buffer costs may differ. - Series X, frame generation, the title's ray tracing on. - A session longer than the 5-minute test with it on. - A fence wait that fails: then only the 10 s keeps a slot from being taken again. ## Notes - `BudgetSlot` gives its slots back through `retire`. I kept the 10 s wait because that is what ran; I can switch to `retire` if you prefer. - If #890 goes in, cards under 10 GiB keep the 16 MiB floor and have few card copies, so this would matter mostly where `VICTORY_CARD_BUFFERS_MIN_KB=64` still holds. - #884 and #682 also change `Host::uav_buffer`. Whichever lands second moves the one `count_uav` call to where the card buffer is made. Measured with AI assistance (Claude Code); the runs were made on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017D5NZ3Fd7undwVFyu8fQN1
Every card copy of a title buffer whose shader writes are declared had a
committed buffer of its own for the hashes of its 64 KiB pieces, 48 bytes
for most, and a small committed buffer costs the card far more than that
(about 36 KiB for 256 bytes on an RTX 3070 Ti, small_buffers_cost_the_card).
With the switch, hashes of up to 32 KiB take slots of shared 1 MiB buffers
by size class; a slot given back is taken again 10 s later at the earliest.
On 63b902f with the launcher as shipped, 5-minute run: card buffers alive
asked for 4 KiB or less 4,135 -> 977, fps 22.1 -> 22.3.

A line every 30 s counts the card buffers Host::uav_buffer made that are
alive, by the size asked for, until their last release (a COM object kept
as private data); no other line counts them alive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017D5NZ3Fd7undwVFyu8fQN1
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:30:45 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/shadow.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/945/head:github-bot/gh-945'
git switch 'github-bot/gh-945'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-945'
git switch 'github-bot/gh-945'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-945'
git switch 'github-bot/gh-945'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-945'
git switch 'main'
git merge --squash 'github-bot/gh-945'
git switch 'main'
git merge --ff-only 'github-bot/gh-945'
git switch 'main'
git merge 'github-bot/gh-945'
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/trustno1-coder--VIctory-NVIDIA!945
No description provided.