The title's bytes go in under shader writes in one pass (VICTORY_UNDER_FUSED, from SlaktarnVI) #3582

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

@⁠banaanpapa on GitHub · 2026-11-30 01:23 UTC · original
banaanpapa:port/under-fused → main · +278 −0 · 1 files · 1 commits · open

A port of an idea from Slaktarn700/SlaktarnVI (GPL-3.0-or-later, as this tree). No game was run here: the figure is a synthetic measurement on one PC (Ryzen 9 9950X3D).

What it is

Shadow::merge_under_writes puts the title's bytes into the CPU's side of a copy while flights may be writing it. For each stale page it found the changed runs (word_runs) and then copied each run on its own, a few bytes at a time. SlaktarnVI's session play-1125-1724 had 190,000 such runs in 400 pages in one frame.

The refresh already has a pass that compares and puts in at once (word_runs_and_update, from 03d5f570). This path could not use it: it must stop when the copies of their own run out (runs_left, 512 or 4,096 a submission), and a pass that puts in as it goes cannot stop. SlaktarnVI's answer, taken over here: take the most copies a page can have before the pass, and give back what was not used.

  • A copy of its own is a run of more than 256 bytes (goes_as_words), and an unchanged word lies between two runs, so a page of n bytes has n / 260 + 1 at most. (That is SlaktarnVI's count; one fewer would do, 15 for a page of 4 KiB.)
  • A page that is not whole words at word offsets, or with fewer copies left than it can have, goes in in two passes as before. So does every page with pairs off (VICTORY_UNDER_WORDS=0, VICTORY_SEND_OWN=0) or with VICTORY_UPCOPY_CHECK=1.
  • SlaktarnVI's own compare-and-put pass (word_runs_put) is not taken over: word_runs_and_update here is the same pass.

On unless VICTORY_UNDER_FUSED=0 (SlaktarnVI's default, and the switch is of the toggled! kind, so an A/B run can flip it): the bytes held, the runs told to go up and the copies taken are the same either way, and the tests below hold it to that.

Measured

shadow::merge_tests::how_long_a_frame_of_small_runs_takes_in_two_passes_and_in_one (ignored; run by name): 400 pages with 190,000 runs of a word each, the median of 31 frames, three runs.

A frame's pages
Two passes (before) 605-617 us
One pass 426-429 us
The pass alone, without counting copies 336-339 us

About 0.18 ms of the submitting thread at that load: small, and free.

What was run

  • a_page_merged_in_one_pass_is_the_page_merged_in_two: 400 random pages with short and long runs; the same runs, the same bytes held, the same number taken from what is left; refused and untouched with one copy fewer left than the page can have; the page with the most copies it can have; pages that are not whole words. It fails when what was not used is not given back, and when a refused page keeps what it took.
  • title_bytes_go_in_under_writes_the_same_in_one_pass_and_in_two (needs a host GPU): two copies with a card's side over view memory with the same bytes, one merged with 4,096 copies left (one pass, counted) and one with 15 (two passes): the CPU's side is title memory, exactly the words that changed are told to go up, and two copies are taken in both. It fails when the one pass puts nothing in. 20 runs of it alone and three of the shadow tests pass.
  • No test that was there reached this path: all of them pass usize::MAX for what is left, which is -1 as the signed count the pages share, so they merge in two passes as before.
  • cargo test -p victory-gpu --release --lib, twice with it on and twice with VICTORY_UNDER_FUSED=0: the same set fails either way, and on main (shader_cache's key test; card_steps::shared_scratch_eliminates_flight_settle_end_to_end and uav_pool's lifecycle test now and then).
  • Clippy, with and without the diagnostics feature: nothing on a line this adds.

Limits

  • No title run. How many runs a frame of this title merges under writes here is the MERGED counters' to say; the gain scales with it.
  • The branch is on f72cec77; it was built and tested merged with 41adb551, and the merge is clean.

The check

The check job fails here as it does on main: Clippy stops at crates/victory-loader/src/crash.rs:804 (unwind_copy is never used), a file this branch does not touch. Nothing in the job's log names a line of this change.

Measured in play (2026-11-30)

One session in the title's world on an RTX 5080 with a Ryzen 9 9950X3D (driver 621.40, Series X profile, 1440p, DLSS Quality, about 4,800 draws a frame), built on e1251c31. VICTORY_AB=10,VICTORY_SUBMIT_SPLIT,VICTORY_TELL_ONCE,VICTORY_UNDER_FUSED flipped the three switches every 10 s through all eight combinations. Each switch's effect is the mean of its four "on" phases minus its four "off" phases, within each full 80-second cycle, over 5 cycles:

Switch Frame, mean Frame, p90 Submitting thread
VICTORY_SUBMIT_SPLIT (upstream's, off by default) ±0.00 ms -0.93 ms -2.68 ms (17.0 to 14.4)
VICTORY_TELL_ONCE (#3268) -0.25 ms, faster in 4 of 5 cycles -0.18 ms -0.20 ms
VICTORY_UNDER_FUSED (#3582) -0.15 ms, faster in 4 of 5 cycles -0.05 ms -0.03 ms

The card was 99 to 100 % busy throughout, so in this scene the frame waits on the card, not on the submitting thread. Where the frame is bound by that thread, these gains should show more; this session can't say how much more. Five cycles of one scene is a small sample.

🤖 Generated with Claude Code

**@⁠banaanpapa** on GitHub · 2026-11-30 01:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3582) `banaanpapa:port/under-fused` → `main` · +278 −0 · 1 files · 1 commits · open A port of an idea from Slaktarn700/SlaktarnVI (GPL-3.0-or-later, as this tree). No game was run here: the figure is a synthetic measurement on one PC (Ryzen 9 9950X3D). ## What it is `Shadow::merge_under_writes` puts the title's bytes into the CPU's side of a copy while flights may be writing it. For each stale page it found the changed runs (`word_runs`) and then copied each run on its own, a few bytes at a time. SlaktarnVI's session play-1125-1724 had 190,000 such runs in 400 pages in one frame. The refresh already has a pass that compares and puts in at once (`word_runs_and_update`, from 03d5f570). This path could not use it: it must stop when the copies of their own run out (`runs_left`, 512 or 4,096 a submission), and a pass that puts in as it goes cannot stop. SlaktarnVI's answer, taken over here: take the most copies a page can have before the pass, and give back what was not used. - A copy of its own is a run of more than 256 bytes (`goes_as_words`), and an unchanged word lies between two runs, so a page of `n` bytes has `n / 260 + 1` at most. (That is SlaktarnVI's count; one fewer would do, 15 for a page of 4 KiB.) - A page that is not whole words at word offsets, or with fewer copies left than it can have, goes in in two passes as before. So does every page with pairs off (`VICTORY_UNDER_WORDS=0`, `VICTORY_SEND_OWN=0`) or with `VICTORY_UPCOPY_CHECK=1`. - SlaktarnVI's own compare-and-put pass (`word_runs_put`) is not taken over: `word_runs_and_update` here is the same pass. On unless `VICTORY_UNDER_FUSED=0` (SlaktarnVI's default, and the switch is of the `toggled!` kind, so an A/B run can flip it): the bytes held, the runs told to go up and the copies taken are the same either way, and the tests below hold it to that. ## Measured `shadow::merge_tests::how_long_a_frame_of_small_runs_takes_in_two_passes_and_in_one` (ignored; run by name): 400 pages with 190,000 runs of a word each, the median of 31 frames, three runs. | | A frame's pages | |---|---| | Two passes (before) | 605-617 us | | One pass | 426-429 us | | The pass alone, without counting copies | 336-339 us | About 0.18 ms of the submitting thread at that load: small, and free. ## What was run - `a_page_merged_in_one_pass_is_the_page_merged_in_two`: 400 random pages with short and long runs; the same runs, the same bytes held, the same number taken from what is left; refused and untouched with one copy fewer left than the page can have; the page with the most copies it can have; pages that are not whole words. It fails when what was not used is not given back, and when a refused page keeps what it took. - `title_bytes_go_in_under_writes_the_same_in_one_pass_and_in_two` (needs a host GPU): two copies with a card's side over view memory with the same bytes, one merged with 4,096 copies left (one pass, counted) and one with 15 (two passes): the CPU's side is title memory, exactly the words that changed are told to go up, and two copies are taken in both. It fails when the one pass puts nothing in. 20 runs of it alone and three of the `shadow` tests pass. - No test that was there reached this path: all of them pass `usize::MAX` for what is left, which is -1 as the signed count the pages share, so they merge in two passes as before. - `cargo test -p victory-gpu --release --lib`, twice with it on and twice with `VICTORY_UNDER_FUSED=0`: the same set fails either way, and on `main` (`shader_cache`'s key test; `card_steps::shared_scratch_eliminates_flight_settle_end_to_end` and `uav_pool`'s lifecycle test now and then). - Clippy, with and without the diagnostics feature: nothing on a line this adds. ## Limits - No title run. How many runs a frame of this title merges under writes here is the `MERGED` counters' to say; the gain scales with it. - The branch is on `f72cec77`; it was built and tested merged with `41adb551`, and the merge is clean. ## The check The `check` job fails here as it does on `main`: Clippy stops at `crates/victory-loader/src/crash.rs:804` (`unwind_copy` is never used), a file this branch does not touch. Nothing in the job's log names a line of this change. ## Measured in play (2026-11-30) One session in the title's world on an RTX 5080 with a Ryzen 9 9950X3D (driver 621.40, Series X profile, 1440p, DLSS Quality, about 4,800 draws a frame), built on `e1251c31`. `VICTORY_AB=10,VICTORY_SUBMIT_SPLIT,VICTORY_TELL_ONCE,VICTORY_UNDER_FUSED` flipped the three switches every 10 s through all eight combinations. Each switch's effect is the mean of its four "on" phases minus its four "off" phases, within each full 80-second cycle, over 5 cycles: | Switch | Frame, mean | Frame, p90 | Submitting thread | |---|---|---|---| | `VICTORY_SUBMIT_SPLIT` (upstream's, off by default) | ±0.00 ms | -0.93 ms | -2.68 ms (17.0 to 14.4) | | `VICTORY_TELL_ONCE` (#3268) | -0.25 ms, faster in 4 of 5 cycles | -0.18 ms | -0.20 ms | | `VICTORY_UNDER_FUSED` (#3582) | -0.15 ms, faster in 4 of 5 cycles | -0.05 ms | -0.03 ms | The card was 99 to 100 % busy throughout, so in this scene the frame waits on the card, not on the submitting thread. Where the frame is bound by that thread, these gains should show more; this session can't say how much more. Five cycles of one scene is a small sample. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`merge_under_writes` found a page's changed runs and then copied each into
the CPU's side of the copy, a few bytes at a time. The refresh has had a
pass that does both at once (`word_runs_and_update`); this path could not
use it, because it must stop when the copies of their own run out and a
pass that puts in as it goes cannot. SlaktarnVI's answer: take the most
copies a page can have first, and give back what was not used.

The same bytes end up held, the same runs are told to go up, and as many
copies are taken from what is left; a page that is not whole words, or
with fewer copies left than it can have, goes in in two passes as before.

Measured (`how_long_a_frame_of_small_runs_takes_in_two_passes_and_in_one`,
ignored; a Ryzen 9 9950X3D): the frame SlaktarnVI's session had, 400 pages
with 190,000 runs, takes 605-617 us in two passes and 426-429 us in one.

(From Slaktarn700/SlaktarnVI's `VICTORY_UNDER_FUSED`, on there too. Its
compare-and-put pass is not taken over: the one here is the same. Its
count of a page's copies, `n / 260 + 1`, is kept though one fewer would
do.)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 01:25:55 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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