gpu: keep titles' copies of half a MiB on the card, not sixteen #641

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

@⁠superboynick on GitHub · 2026-11-28 02:30 UTC · original
superboynick:perf/card-buffer-min → main · +24 −10 · 1 files · 1 commits · open

What this changes

On a card whose VRAM budget is 12 GiB or less, the smallest title copy kept in the card's memory was 16 MiB. The CPU searches those copies for what shaders wrote, and the copies the card holds are searched on the card instead — so everything between 16 MiB and a megabyte was searched on the CPU, every frame.

The floor becomes 512 KiB (in resolve_card_limits, which is where VICTORY_CARD_BUFFERS_MIN_KB already set it for anyone who asked).

What I tested

RTX 5070 Ti Laptop (budget 11,176 MB), Windows 11 26100, RTX 5070 Ti driver 32.0.16.1714, Series X profile, the 36-item play set, one save, warm shader cache. Windows paired by index and kept only where draws/frame agrees within 5%.

card_buffers_min CPU search a frame frame, median of in-world windows
16 MiB (before) 377.3 MB in 397 ranges 470.4 ms
2 MiB 42.0 MB 201.2 ms
1 MiB 27.3 MB 196.0 ms
512 KiB (this) 14.7 MB 188.6 ms

Paired windows, 16 MiB against 512 KiB — seven of them, every one in the same direction:

window draws 16 MiB 512 KiB Δ
27 5,015 425.9 186.6 −239.3
28 4,988 435.8 180.1 −255.7
29 4,998 431.1 180.2 −250.9
30 4,983 422.0 184.0 −238.0
31 4,980 416.5 182.1 −234.4
32 4,982 419.8 184.3 −235.5
33 4,960 412.9 180.3 −232.6

Median 425.9 → 184.0 ms (−56.8 %), which is 2.35 → 5.43 fps in the dense city.

Stability

A 480 s soak at 512 KiB: 65 in-world windows, median 181.2 ms, P90 188.4 ms, no device loss, VRAM 8.1 GB of a 10.7 GB budget. Series S gains the same way (101.1 ms median in the world, against 264-310 ms before).

Nothing below half a MiB goes to the card: below that the per-copy bookkeeping costs more than the search it saves. Copies the card cannot hold stay on the CPU, so the budget still caps it — this only decides where the search happens, not how much memory is spent.

What it costs in VRAM, since that is the obvious objection

Same run, same place of the same scene, the line the layer prints right after the swap chain settles:

card_buffers_min video memory in use
16 MiB (before) 8,086 MB of a 10,723 MB budget
512 KiB (this) 8,132 MB of a 10,731 MB budget

+46 MB, about 0.6 percent, for 56.8 percent of the frame. The budget still caps what the card keeps,
and whatever does not fit stays on the CPU exactly as before, so a card with less memory loses the benefit
rather than the stability.

One more thing, in case it helps you place this: it is the same family as #6 and #7, which are already in main — the
question of which of the title's bytes sit in card memory and are looked at there, rather than on the CPU. #7's
"texture read-backs written by a thread of their own" is that question from the write-back side; this is the same
question at the search side, and it is the largest single item left in the frame here.

One risk, found after opening this, and stated rather than left for you to find

At Series S with VICTORY_UPLOAD_AHEAD=1 and VICTORY_ASYNC_SUBMIT=1 alongside the 512 KiB
threshold, two runs in three device-lost (0x887A0005, the host device went while textures picked by index were made ready). The threshold on its own does not: Series S with nothing else
changed ran clean, 34 windows, median 103.4 ms, no loss.

That is the frame shadow.rs already describes — "the fault lay in a texture made in the same
tenth of a second, in a new block" — and putting more of the title's copies in card memory makes
more new blocks, so that window widens. My reading is that VICTORY_WAIT_RESIDENT (on by default)
is the thing that has to keep up here, not the threshold, but I have not proven it, and it is your
call whether a default that widens a known window is worth 56 % of a frame.

So: if you take the number and not the default, the switch already exists and I will leave it at
that. I have taken the combination out of the launcher I use here and written the loss into it.
One more line for whoever runs the tests: on this branch cargo test -p victory-gpu --lib is 443 passed, 0 failed, 36 ignored (WARP, one test thread), so no assertion in the tree depended on the 16 MiB floor. Nothing else in the branch changes behaviour: the floor moves, and VICTORY_CARD_BUFFERS_MIN_KB still overrides it.

What would make it mergeable

  • The numbers above are one machine. If you would rather keep the default and have this only as the switch it already is, say so and I will turn this into a one-line note in the docs instead.
  • If the direction is right but the number wrong, 1 MiB is 196.0 ms and 2 MiB is 201.2 — the curve is monotone, so the floor is a budget decision rather than a cliff.
  • The same question applies to the 16–20 GiB branch, whose default is 4 MiB: I cannot test it here, and the shape says it would gain the same way.
**@⁠superboynick** on GitHub · 2026-11-28 02:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/641) `superboynick:perf/card-buffer-min` → `main` · +24 −10 · 1 files · 1 commits · open ## What this changes On a card whose VRAM budget is 12 GiB or less, the smallest title copy kept in the card's memory was **16 MiB**. The CPU searches those copies for what shaders wrote, and the copies the card holds are searched **on the card** instead — so everything between 16 MiB and a megabyte was searched on the CPU, every frame. The floor becomes **512 KiB** (in `resolve_card_limits`, which is where `VICTORY_CARD_BUFFERS_MIN_KB` already set it for anyone who asked). ## What I tested RTX 5070 Ti Laptop (budget 11,176 MB), Windows 11 26100, RTX 5070 Ti driver 32.0.16.1714, Series X profile, the 36-item play set, one save, warm shader cache. Windows paired by index and kept only where `draws/frame` agrees within 5%. | card_buffers_min | CPU search a frame | frame, median of in-world windows | |---|---|---| | 16 MiB (before) | 377.3 MB in 397 ranges | 470.4 ms | | 2 MiB | 42.0 MB | 201.2 ms | | 1 MiB | 27.3 MB | 196.0 ms | | **512 KiB (this)** | **14.7 MB** | **188.6 ms** | Paired windows, 16 MiB against 512 KiB — seven of them, every one in the same direction: | window | draws | 16 MiB | 512 KiB | Δ | |---|---:|---:|---:|---:| | 27 | 5,015 | 425.9 | 186.6 | −239.3 | | 28 | 4,988 | 435.8 | 180.1 | −255.7 | | 29 | 4,998 | 431.1 | 180.2 | −250.9 | | 30 | 4,983 | 422.0 | 184.0 | −238.0 | | 31 | 4,980 | 416.5 | 182.1 | −234.4 | | 32 | 4,982 | 419.8 | 184.3 | −235.5 | | 33 | 4,960 | 412.9 | 180.3 | −232.6 | **Median 425.9 → 184.0 ms (−56.8 %)**, which is 2.35 → 5.43 fps in the dense city. ## Stability A 480 s soak at 512 KiB: 65 in-world windows, median 181.2 ms, **P90 188.4 ms**, no device loss, VRAM **8.1 GB of a 10.7 GB budget**. Series S gains the same way (101.1 ms median in the world, against 264-310 ms before). Nothing below half a MiB goes to the card: below that the per-copy bookkeeping costs more than the search it saves. Copies the card cannot hold stay on the CPU, so the budget still caps it — this only decides *where* the search happens, not how much memory is spent. ## What it costs in VRAM, since that is the obvious objection Same run, same place of the same scene, the line the layer prints right after the swap chain settles: | `card_buffers_min` | video memory in use | |---|---:| | 16 MiB (before) | **8,086 MB** of a 10,723 MB budget | | 512 KiB (this) | **8,132 MB** of a 10,731 MB budget | **+46 MB, about 0.6 percent**, for 56.8 percent of the frame. The budget still caps what the card keeps, and whatever does not fit stays on the CPU exactly as before, so a card with less memory loses the benefit rather than the stability. --- One more thing, in case it helps you place this: it is the same family as #6 and #7, which are already in main — the question of which of the title's bytes sit in card memory and are looked at there, rather than on the CPU. #7's "texture read-backs written by a thread of their own" is that question from the write-back side; this is the same question at the search side, and it is the largest single item left in the frame here. ## One risk, found after opening this, and stated rather than left for you to find At Series S with `VICTORY_UPLOAD_AHEAD=1` and `VICTORY_ASYNC_SUBMIT=1` alongside the 512 KiB threshold, two runs in three device-lost (**0x887A0005**, `the host device went while textures picked by index were made ready`). The threshold on its own does not: Series S with nothing else changed ran clean, 34 windows, median 103.4 ms, no loss. That is the frame `shadow.rs` already describes — "the fault lay in a texture made in the same tenth of a second, in a new block" — and putting more of the title's copies in card memory makes more new blocks, so that window widens. My reading is that `VICTORY_WAIT_RESIDENT` (on by default) is the thing that has to keep up here, not the threshold, but I have not proven it, and it is your call whether a default that widens a known window is worth 56 % of a frame. So: if you take the number and not the default, the switch already exists and I will leave it at that. I have taken the combination out of the launcher I use here and written the loss into it. One more line for whoever runs the tests: on this branch `cargo test -p victory-gpu --lib` is **443 passed, 0 failed, 36 ignored** (WARP, one test thread), so no assertion in the tree depended on the 16 MiB floor. Nothing else in the branch changes behaviour: the floor moves, and `VICTORY_CARD_BUFFERS_MIN_KB` still overrides it. ## What would make it mergeable - The numbers above are one machine. If you would rather keep the default and have this only as the switch it already is, say so and I will turn this into a one-line note in the docs instead. - If the direction is right but the number wrong, 1 MiB is 196.0 ms and 2 MiB is 201.2 — the curve is monotone, so the floor is a budget decision rather than a cliff. - The same question applies to the 16–20 GiB branch, whose default is 4 MiB: I cannot test it here, and the shape says it would gain the same way.
The CPU searches the title's copies for what shaders wrote, and the copies the card keeps are
searched there instead. On a card whose budget is 12 GiB or less the smallest copy kept on the
card was 16 MiB, so everything between that and a megabyte was searched on the CPU every frame.

Measured on an RTX 5070 Ti Laptop (budget 11,176 MB), Series X profile, the 36-item play set, one
save, draw-matched windows paired by index:

| card_buffers_min | CPU search a frame | frame, median of in-world windows |
|---|---|---|
| 16 MiB (before) | 377.3 MB in 397 ranges | 470.4 ms |
| 2 MiB | 42.0 MB | 201.2 ms |
| 1 MiB | 27.3 MB | 196.0 ms |
| 512 KiB (this) | 14.7 MB | 188.6 ms |

Eight paired windows at 16 MiB against 512 KiB: 425.9, 435.8, 431.1, 422.0, 416.5, 419.8, 412.9
against 191.5, 195.2, 193.4, 196.0, 192.0, 192.1, 189.9 — every one of them, no exception. A 480 s
soak at 512 KiB: 65 in-world windows, median 181.2 ms, P90 188.4 ms, no device loss, VRAM 8.1 GB
of a 10.7 GB budget. Series S gains the same way: 101.1 ms median in the world against 264-310
before.

The floor moves from 1 MiB to 512 KiB in resolve_card_limits, which is where VICTORY_CARD_BUFFERS_MIN_KB
already set it for anyone who asked. Copies below half a MiB keep being searched on the CPU: their
bookkeeping costs more than the search saves.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 02:31:40 +00:00
github-bot force-pushed github-bot/gh-641 from 76889c7d1b to 65dc0af355 2026-11-28 03:55:02 +00:00 Compare
Author
Owner

@⁠wildheathen on GitHub · 2026-11-28 15:40 UTC · original

The existing test shadow::window_tests::card_limits_scale_with_local_vram_budget fails on this branch (at 65dc0af, cargo test -p victory-gpu --lib -- card_limits: left: (0, 512), right: (16, 512)): its <= 12 GiB assertions still expect 16, and the doc comment above default_card_limits_mb still says 16 MiB for that tier. The commit also adds a BOM to shadow.rs and re-encodes five comment lines (179, 189, 190, 5996, 6002), so "8–12" became "8鈥?2": the en dash and the digit after it are lost.

**@⁠wildheathen** on GitHub · 2026-11-28 15:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/641#issuecomment-7241649558) The existing test `shadow::window_tests::card_limits_scale_with_local_vram_budget` fails on this branch (at `65dc0af`, `cargo test -p victory-gpu --lib -- card_limits`: `left: (0, 512)`, `right: (16, 512)`): its `<= 12 GiB` assertions still expect 16, and the doc comment above `default_card_limits_mb` still says 16 MiB for that tier. The commit also adds a BOM to `shadow.rs` and re-encodes five comment lines (179, 189, 190, 5996, 6002), so "8–12" became "8鈥?2": the en dash and the digit after it are lost.
github-bot force-pushed github-bot/gh-641 from 65dc0af355 to 7fae2df79d 2026-11-29 08:09:39 +00:00 Compare
Author
Owner

@⁠superboynick on GitHub · 2026-11-29 08:05 UTC · original

All three are right, and all three are fixed in 7fae2df7, rebased onto e1f2eb60 (the branch had drifted 320 commits behind, which is how the test caught me: it did not exist when I last ran the suite).

  • The test: card_limits_scale_with_local_vram_budget now expects 0 for the <= 12 GiB tier instead of 16, and the resolve_card_limits case that pinned the floor at 1 MiB now expects 512 << 10. cargo test -p victory-gpu --lib on this branch: 589 passed, 0 failed, 44 ignored (WARP, one thread).
  • The doc comment: the tier now reads half a MiB, with the reasoning and the numbers beside it, instead of 16 MiB.
  • The BOM and the five re-encoded lines: my fault entirely — I wrote the file with a tool that adds a byte-order mark and mangles the en dashes (8–12 became 8鈥?2). I restored the file from main and re-applied only the two changes by hand, so the diff is now two hunks plus the comment, with no BOM and no re-encoded lines: git diff main -- crates/victory-gpu/src/shadow.rs shows 24 insertions and 10 deletions, and every line that is not one of the two changes is byte-identical to main.

One thing I should flag rather than leave for you to find: the numbers in the description were measured before the 320 commits that rewrote this path (0174844a's shared shadow lock, 225cba4e's batched card.dirty, 041d0ee6's scatter, 38fd3d93's write-back scopes). I am re-running the seven-window pair on 568c5e5→e1f2eb60 now and will put the new figures in this description, or say plainly that the change is worth less than it was if that is what the fresh numbers show.

**@⁠superboynick** on GitHub · 2026-11-29 08:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/641#issuecomment-7252882647) All three are right, and all three are fixed in `7fae2df7`, rebased onto `e1f2eb60` (the branch had drifted 320 commits behind, which is how the test caught me: it did not exist when I last ran the suite). - **The test**: `card_limits_scale_with_local_vram_budget` now expects `0` for the `<= 12 GiB` tier instead of `16`, and the `resolve_card_limits` case that pinned the floor at 1 MiB now expects `512 << 10`. `cargo test -p victory-gpu --lib` on this branch: **589 passed, 0 failed, 44 ignored** (WARP, one thread). - **The doc comment**: the tier now reads half a MiB, with the reasoning and the numbers beside it, instead of 16 MiB. - **The BOM and the five re-encoded lines**: my fault entirely — I wrote the file with a tool that adds a byte-order mark and mangles the en dashes (`8–12` became `8鈥?2`). I restored the file from `main` and re-applied only the two changes by hand, so the diff is now two hunks plus the comment, with no BOM and no re-encoded lines: `git diff main -- crates/victory-gpu/src/shadow.rs` shows 24 insertions and 10 deletions, and every line that is not one of the two changes is byte-identical to `main`. One thing I should flag rather than leave for you to find: **the numbers in the description were measured before the 320 commits that rewrote this path** (`0174844a`'s shared shadow lock, `225cba4e`'s batched `card.dirty`, `041d0ee6`'s scatter, `38fd3d93`'s write-back scopes). I am re-running the seven-window pair on `568c5e5`→`e1f2eb60` now and will put the new figures in this description, or say plainly that the change is worth less than it was if that is what the fresh numbers show.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 08:28 UTC · original

Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.

**@⁠trustno1-coder** on GitHub · 2026-11-29 08:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/641#issuecomment-7253123356) Thank you! An earlier version of this pull request was merged into main with its original commits and is part of [v2026.11.29.01](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.29.01), where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
This pull request has changes conflicting with the target branch.
  • 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/641/head:github-bot/gh-641'
git switch 'github-bot/gh-641'

Merge

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