Copies whose shader writes stay on the card: a range taken again with no title write since sends only what changed; VICTORY_CLOBBER_WATCH=1 diagnostics (#1387) #4341

Closed
github-bot wants to merge 3 commits from github-bot/gh-4340 into main AGit
Owner

@⁠Lyrnc on GitHub · 2026-11-30 19:04 UTC · original
Lyrnc:fix/wc-keep-left → main · +947 −20 · 4 files · 3 commits · closed without merging

Refs #1387 (closed as older than v2026.11.29.01; a user on an RTX 5080 still sees it on a v2026.11.29-based build: the picture turns white "like a flashbang", then comes back over about 10 s). Same shape as #2259, where it repeats for the whole drive.

What is confirmed: the mechanism below, by reading the code and in unit tests. Not confirmed: that it is what turns the picture white. The white-out was not reproduced here: it needs a night drive, and I have no save for one. So this is a fix of a real fault that fits the report, plus diagnostics that can tie a white-out in a log to an event.

The fault

With VICTORY_WC_NO_BACK=1, which victory play and play-nvidia.ps1 set with a 1 MiB floor, what shaders write in big write-combined copies is never copied back. Only the card's side has it. Any title bytes sent over such a range put the title's older bytes back. The wc_no_back comment already accepts that for pages the title writes, because of counters.

It also happens where the title wrote nothing:

  • copy_stale takes a page again whenever copied[page] is 0 and neither ranged slot nor the range's memo slot holds the range.
  • copied notes a page only when one refresh holds all of it. A page that draws read a few hundred bytes at a time (constant views) is never noted, so its ranges count as current only while a slot still holds them.
  • When other ranges of the copy take those slots, the next refresh of the range copies it from title memory again, and copy() marks all of it to go up. The shaders' bytes in that range go back to what the title last wrote, often its first values.

A value a pass carries from frame to frame and adapts over seconds would then jump and adapt back, at no fixed time. That is the shape of #1387 and #2259. Nothing is logged when it happens. The rule is live in the reporters' runs:

  • #1387 and #2259 run the launcher's switches with ray tracing off.
  • The RTX 5080 report runs hardware RT on a build without 9a427c14, which turns the rule off under HW RT. Its play log has 75 copies of 1 to 24 MB under the rule.

What changes

  • Shadow::leaves marks a copy whose shader writes stay on the card. It runs in the write-combined branches of gpu_writes and shader_writes, and in the VICTORY_UNIFIED_BACK branches when wc_left is set.
  • Such a copy keeps, per 64 KiB page, the ranges refreshes took since the title last wrote the page (Cover: joined ranges and the asking of that write; cleared when the write watch reports a newer write).
  • In copy_stale, for such a copy with two sides: the part of a page it would take again goes through the existing dword compare when all of it lies inside those ranges. This is the same compare VICTORY_SEND_CHANGED uses (take()'s body moved to take_into()). Only dwords where title memory differs from the CPU's side go up.
    • The compare's blind spot (the title writing again the value it wrote before) cannot occur there: the write watch says the title wrote nothing in the page since those exact bytes were taken.
    • A change the write watch missed still goes up, as its dwords.
    • Everything else goes up whole as before. That includes a range not taken since the page's last write: another range of the same page taken after the write says nothing about this one. So the counter set to 0 again, the case wc_no_back names, still reaches the card. A test covers it.
  • VICTORY_WC_KEEP_LEFT=0 restores the old behaviour.

Copies whose shader writes come back are not touched, and neither are single-sided or mapped (VICTORY_WC_BAR) copies. Cost: for copies under the rule only, and only for the pages a refresh takes (again): one uncontended lock per refresh and a short range lookup per such page. Pages that are current cost nothing more than before (benchmark under Tests). The compare replaces a copy and sends less.

Diagnostics: VICTORY_CLOBBER_WATCH=1 (off by default)

clobber.rs, one WARN line per event with the frame:

  • A refresh sends title bytes over shader writes left on the card. It fires when the range was declared written within VICTORY_CLOBBER_FRAMES frames (16 unset) and the bytes differ from the CPU's side. The line has the copy, title address, size, range, frames since the write, hashes of the bytes there and of those sent, and the first changed dword.
  • A copy is made again from title memory where a freed copy held such writes.
  • A small read-back jumps. This covers one row of at most 96 bytes, i.e. the light metering's 5x1 and 1x1 float rows the title reads back every frame. It fires when a value is not finite, when the row is all zeros after a row that was not, or when a value is 16 times or a sixteenth of the last landing at that address.
  • A count line every 5 s while anything happens, including how many re-takes the change above turned into compares.

Each kind logs its first 64 events, then every 256th. Off, it costs one relaxed load at those places.

For someone who sees the white-out:

  1. Run with VICTORY_CLOBBER_WATCH=1 and note the time it turns white.
  2. A/B VICTORY_WC_NO_BACK=0, which leaves no shader writes on the card at all. If the white-outs stop with it, they are this class.

Tests

  • keep_left_tests::a_range_taken_again_without_a_title_write_keeps_what_shaders_left: a partial range of a two-sided copy marked as leaving writes on the card is taken, its slots are taken over (a range in its memo slot is found by search), and it is taken again with no title write. Nothing goes up. A copy whose writes come back is taken whole as before. After a title write of the page it goes up whole once, then nothing again.
    • With VICTORY_WC_KEEP_LEFT=0 this test fails at the re-take: the whole range goes up. That is the old behaviour.
  • keep_left_tests::a_word_the_title_sets_again_goes_up_although_another_range_was_taken_since (the counter case), a_change_the_write_watch_missed_goes_up_as_its_dwords, a_cover_holds_what_was_taken_since_the_last_write_and_nothing_else.
  • clobber::tests (7): range notes, recency and overlap, the made-again list, read-back jumps, line limits, hash.
  • keep_left_tests::copy_stale_cost_of_the_cover (#[ignore = "benchmark"]): copy_stale in nanoseconds a refresh, for a copy under the rule against one without it. Release, Ryzen 7 9800X3D, at 72b3a244: a small range that is current 16 ns (16 without the rule), 1,024 current pages 1,462 ns (1,457), a small range taken again with nothing changed 55 ns (61). Before 72b3a244 the cover was looked at for every page, current or not: 24 ns and 8,950 ns for the first two.

Update (01 Dec): rebased onto main 5fabb46e, and 72b3a244 looks at the cover only for pages a refresh takes (IRennie74's review). On 72b3a244: cargo test --release -p victory-gpu --lib -- keep_left clobber --include-ignored passes (the four tests above, the benchmark, clobber::tests). cargo test -p victory-gpu --lib: 1,106 passed, 0 failed, 67 ignored. cargo clippy -p victory-gpu --all-targets -- -D warnings: 5 errors, all in host/font.rs, host/menu.rs and host/panel.rs from main's F1/F3 panel merge (#4635), none from this PR.

What was run before that (RTX 5080, Windows 11, on 84bd61e2):

  • cargo test -p victory-gpu --lib: all pass except list::thin::tests::bindings_record_no_work and shader_cache::tests::every_switch_of_the_translator_is_in_the_key. Both fail the same way without this change.
  • cargo clippy -p victory-gpu --all-targets [--all-features] -- -D warnings: nothing from this change. What is left fails on 84bd61e2 too: Shadow::ranged never used, seed % 3 in a host test, copystat::mb with all features.
  • cargo xtask policy: only the existing victory-shader/src/native.rs finding.
  • In game: nothing yet. A daytime walk A/B with the watch on (VICTORY_WC_KEEP_LEFT=0 against the default, ray tracing off) is queued on our bench. It can count how often the old behaviour sends title bytes over shader writes left on the card. It cannot show the night white-out.

Not changed here: copies found by address (by_address, the structure arenas, changes_only). A partial-page re-take with known == false goes up whole there too.

Written with AI assistance (Claude Code, Claude Opus 5.5). No game data.

🤖 Generated with Claude Code

**@⁠Lyrnc** on GitHub · 2026-11-30 19:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340) `Lyrnc:fix/wc-keep-left` → `main` · +947 −20 · 4 files · 3 commits · closed without merging Refs #1387 (closed as older than v2026.11.29.01; a user on an RTX 5080 still sees it on a v2026.11.29-based build: the picture turns white "like a flashbang", then comes back over about 10 s). Same shape as #2259, where it repeats for the whole drive. **What is confirmed:** the mechanism below, by reading the code and in unit tests. **Not confirmed:** that it is what turns the picture white. The white-out was not reproduced here: it needs a night drive, and I have no save for one. So this is a fix of a real fault that fits the report, plus diagnostics that can tie a white-out in a log to an event. ## The fault With `VICTORY_WC_NO_BACK=1`, which `victory play` and `play-nvidia.ps1` set with a 1 MiB floor, what shaders write in big write-combined copies is never copied back. Only the card's side has it. Any title bytes sent over such a range put the title's older bytes back. The `wc_no_back` comment already accepts that for pages the title writes, because of counters. It also happens where the title wrote nothing: - `copy_stale` takes a page again whenever `copied[page]` is 0 and neither `ranged` slot nor the range's memo slot holds the range. - `copied` notes a page only when one refresh holds all of it. A page that draws read a few hundred bytes at a time (constant views) is never noted, so its ranges count as current only while a slot still holds them. - When other ranges of the copy take those slots, the next refresh of the range copies it from title memory again, and `copy()` marks all of it to go up. The shaders' bytes in that range go back to what the title last wrote, often its first values. A value a pass carries from frame to frame and adapts over seconds would then jump and adapt back, at no fixed time. That is the shape of #1387 and #2259. Nothing is logged when it happens. The rule is live in the reporters' runs: - #1387 and #2259 run the launcher's switches with ray tracing off. - The RTX 5080 report runs hardware RT on a build without 9a427c14, which turns the rule off under HW RT. Its play log has 75 copies of 1 to 24 MB under the rule. ## What changes - `Shadow::leaves` marks a copy whose shader writes stay on the card. It runs in the write-combined branches of `gpu_writes` and `shader_writes`, and in the `VICTORY_UNIFIED_BACK` branches when `wc_left` is set. - Such a copy keeps, per 64 KiB page, the ranges refreshes took since the title last wrote the page (`Cover`: joined ranges and the asking of that write; cleared when the write watch reports a newer write). - In `copy_stale`, for such a copy with two sides: the part of a page it would take again goes through the existing dword compare when all of it lies inside those ranges. This is the same compare `VICTORY_SEND_CHANGED` uses (`take()`'s body moved to `take_into()`). Only dwords where title memory differs from the CPU's side go up. - The compare's blind spot (the title writing again the value it wrote before) cannot occur there: the write watch says the title wrote nothing in the page since those exact bytes were taken. - A change the write watch missed still goes up, as its dwords. - Everything else goes up whole as before. That includes a range not taken since the page's last write: another range of the same page taken after the write says nothing about this one. So the counter set to 0 again, the case `wc_no_back` names, still reaches the card. A test covers it. - `VICTORY_WC_KEEP_LEFT=0` restores the old behaviour. Copies whose shader writes come back are not touched, and neither are single-sided or mapped (`VICTORY_WC_BAR`) copies. Cost: for copies under the rule only, and only for the pages a refresh takes (again): one uncontended lock per refresh and a short range lookup per such page. Pages that are current cost nothing more than before (benchmark under Tests). The compare replaces a copy and sends less. ## Diagnostics: `VICTORY_CLOBBER_WATCH=1` (off by default) `clobber.rs`, one `WARN` line per event with the frame: - **A refresh sends title bytes over shader writes left on the card.** It fires when the range was declared written within `VICTORY_CLOBBER_FRAMES` frames (16 unset) and the bytes differ from the CPU's side. The line has the copy, title address, size, range, frames since the write, hashes of the bytes there and of those sent, and the first changed dword. - **A copy is made again from title memory** where a freed copy held such writes. - **A small read-back jumps.** This covers one row of at most 96 bytes, i.e. the light metering's 5x1 and 1x1 float rows the title reads back every frame. It fires when a value is not finite, when the row is all zeros after a row that was not, or when a value is 16 times or a sixteenth of the last landing at that address. - **A count line every 5 s** while anything happens, including how many re-takes the change above turned into compares. Each kind logs its first 64 events, then every 256th. Off, it costs one relaxed load at those places. For someone who sees the white-out: 1. Run with `VICTORY_CLOBBER_WATCH=1` and note the time it turns white. 2. A/B `VICTORY_WC_NO_BACK=0`, which leaves no shader writes on the card at all. If the white-outs stop with it, they are this class. ## Tests - `keep_left_tests::a_range_taken_again_without_a_title_write_keeps_what_shaders_left`: a partial range of a two-sided copy marked as leaving writes on the card is taken, its slots are taken over (a range in its memo slot is found by search), and it is taken again with no title write. Nothing goes up. A copy whose writes come back is taken whole as before. After a title write of the page it goes up whole once, then nothing again. - With `VICTORY_WC_KEEP_LEFT=0` this test fails at the re-take: the whole range goes up. That is the old behaviour. - `keep_left_tests::a_word_the_title_sets_again_goes_up_although_another_range_was_taken_since` (the counter case), `a_change_the_write_watch_missed_goes_up_as_its_dwords`, `a_cover_holds_what_was_taken_since_the_last_write_and_nothing_else`. - `clobber::tests` (7): range notes, recency and overlap, the made-again list, read-back jumps, line limits, hash. - `keep_left_tests::copy_stale_cost_of_the_cover` (`#[ignore = "benchmark"]`): `copy_stale` in nanoseconds a refresh, for a copy under the rule against one without it. Release, Ryzen 7 9800X3D, at 72b3a244: a small range that is current 16 ns (16 without the rule), 1,024 current pages 1,462 ns (1,457), a small range taken again with nothing changed 55 ns (61). Before 72b3a244 the cover was looked at for every page, current or not: 24 ns and 8,950 ns for the first two. Update (01 Dec): rebased onto main 5fabb46e, and 72b3a244 looks at the cover only for pages a refresh takes (IRennie74's review). On 72b3a244: `cargo test --release -p victory-gpu --lib -- keep_left clobber --include-ignored` passes (the four tests above, the benchmark, `clobber::tests`). `cargo test -p victory-gpu --lib`: 1,106 passed, 0 failed, 67 ignored. `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 5 errors, all in `host/font.rs`, `host/menu.rs` and `host/panel.rs` from main's F1/F3 panel merge (#4635), none from this PR. What was run before that (RTX 5080, Windows 11, on `84bd61e2`): - `cargo test -p victory-gpu --lib`: all pass except `list::thin::tests::bindings_record_no_work` and `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`. Both fail the same way without this change. - `cargo clippy -p victory-gpu --all-targets [--all-features] -- -D warnings`: nothing from this change. What is left fails on `84bd61e2` too: `Shadow::ranged` never used, `seed % 3` in a host test, `copystat::mb` with all features. - `cargo xtask policy`: only the existing `victory-shader/src/native.rs` finding. - In game: nothing yet. A daytime walk A/B with the watch on (`VICTORY_WC_KEEP_LEFT=0` against the default, ray tracing off) is queued on our bench. It can count how often the old behaviour sends title bytes over shader writes left on the card. It cannot show the night white-out. Not changed here: copies found by address (`by_address`, the structure arenas, `changes_only`). A partial-page re-take with `known == false` goes up whole there too. Written with AI assistance (Claude Code, Claude Opus 5.5). No game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With VICTORY_WC_NO_BACK=1 (a play default) what shaders write in big
write-combined copies is never copied back, so the card's side alone has
it, and any title bytes sent over such a range put older bytes back.
shadow.rs takes that on for pages the title writes (counters). It also
happened where the title wrote nothing: copy_stale takes a page again
whenever `copied` is 0 and neither range slot nor the memo slot holds the
range, and `copied` notes only pages a refresh held whole. A page draws
read a few hundred bytes at a time is never noted, so once other ranges
take its slots the next refresh copies the range again and sends it
whole. A value a pass carries from frame to frame would jump back and
adapt again: the shape of the white-outs in #1387 and #2259 (not shown in
game).

- Shadow::leaves marks a copy whose shader writes stay on the card. Such a
  copy keeps, per page, the ranges refreshes took since the title last
  wrote the page (Cover).
- copy_stale: for such a copy with two sides, the part of a page taken
  again that lies inside those ranges goes through the dword compare
  (take_into, shared with send_changed) instead of a whole copy. Anything
  else goes up whole as before, including another range of a page whose
  neighbour was taken after the title's write (the counter case).
  VICTORY_WC_KEEP_LEFT=0 restores the old behaviour.
- clobber.rs (VICTORY_CLOBBER_WATCH=1, off by default): a line when a
  refresh sends differing title bytes over a range shaders left on the
  card within VICTORY_CLOBBER_FRAMES frames (16), when a copy is made
  again where a freed one held such writes, and when a small read-back
  (the light metering's float rows) jumps; a count line every 5 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:09:26 +00:00
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-30 19:04 UTC · original

Overlap note: #4295 adds an early return to copy_stale when every page is already taken and nothing was written. If both land, that early return should also note the range in the copy's Cover for copies with left set (cover.entry(page).or_default(), then .written(write) and .took(a, b) per page, as the walk does). Otherwise a range only ever answered by that early return is not in the cover, and its first re-take after its slots are reused goes up whole, as before this change. Both edit the same lines around let last, so git will probably also report a conflict there. (AI-assisted: Claude Code)

**@⁠Lyrnc** on GitHub · 2026-11-30 19:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7288808200) Overlap note: #4295 adds an early return to `copy_stale` when every page is already taken and nothing was written. If both land, that early return should also note the range in the copy's `Cover` for copies with `left` set (`cover.entry(page).or_default()`, then `.written(write)` and `.took(a, b)` per page, as the walk does). Otherwise a range only ever answered by that early return is not in the cover, and its first re-take after its slots are reused goes up whole, as before this change. Both edit the same lines around `let last`, so git will probably also report a conflict there. (AI-assisted: Claude Code)
Author
Owner

@⁠paales on GitHub · 2026-11-30 20:52 UTC · original

Written by 🤖:

In-game numbers, tested together with #2504 in one build, so the two are not told apart. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count.

Base: main 84bd61e2 with #3918, #1727, #3553, #3043, #4207 (VICTORY_FILL_AHEAD=1), #4138 and #720 (VICTORY_HEAP_WORKER=1). One run each, back to back:

base with #2504 and #4341
the submitting thread per frame 35.4 ms 42.5 ms
of it, refreshes 12.9 ms 19.4 ms
copies in the card's memory 7.6 ms 9.7 ms
seconds with a frame over 40 ms 40 40
seconds with a frame over 100 ms 11 7

I could not measure a gain. One run is not enough to call it a loss on this PC either.

**@⁠paales** on GitHub · 2026-11-30 20:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7291580162) _Written by 🤖:_ In-game numbers, tested together with #2504 in one build, so the two are not told apart. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count. Base: `main` 84bd61e2 with #3918, #1727, #3553, #3043, #4207 (`VICTORY_FILL_AHEAD=1`), #4138 and #720 (`VICTORY_HEAP_WORKER=1`). One run each, back to back: | | base | with #2504 and #4341 | | --- | --- | --- | | the submitting thread per frame | 35.4 ms | 42.5 ms | | of it, refreshes | 12.9 ms | 19.4 ms | | copies in the card's memory | 7.6 ms | 9.7 ms | | seconds with a frame over 40 ms | 40 | 40 | | seconds with a frame over 100 ms | 11 | 7 | I could not measure a gain. One run is not enough to call it a loss on this PC either.
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:38 UTC · original

A cost concern for PCs where the submitting thread is the limit. VICTORY_WC_KEEP_LEFT is read with toggled!, so it is on by default, and the launcher's VICTORY_WC_NO_BACK=1 makes most large copies left. For those, copy_stale now holds the cover lock for the whole refresh (shadow.rs:7711) and, for every page in the range, does a BTreeMap::entry plus Cover::written / holds / took (7734-7741), including pages that are current and will not be taken; took scans and rebuilds up to 64 ranges each time. That is work on every refresh, not only on the re-takes it fixes.

On a Ryzen 5 5600X with an RTX 3060 our submitting thread is busy 44-54 ms of a 55-58 ms frame, of which refreshes are 11-15 ms, so a few ms there shows directly in the frame. paales' run above (refreshes 12.9 -> 19.4 ms, together with #2504) is confounded but points the same way. Two options:

  • touch the cover only for pages being taken again (taken == 0 || write > taken), noting current pages' ranges lazily, at the cost of a little more re-take;
  • or asked_for! until it has been measured on a CPU-bound PC.

On whether it fixes what it targets: #4377 adds VICTORY_FLICKER_DETECT=1, which counts A-B-A flicker events a minute at every present (about 59 a minute walking on our combined build). A value that jumps back to its first state and adapts again should show there, so VICTORY_WC_KEEP_LEFT=0 against the default with it on gives a number even without the night white-out. We can run that pair on the 3060.

**@⁠IRennie74** on GitHub · 2026-11-30 22:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7294105684) A cost concern for PCs where the submitting thread is the limit. `VICTORY_WC_KEEP_LEFT` is read with `toggled!`, so it is on by default, and the launcher's `VICTORY_WC_NO_BACK=1` makes most large copies `left`. For those, `copy_stale` now holds the cover lock for the whole refresh (`shadow.rs:7711`) and, for every page in the range, does a `BTreeMap::entry` plus `Cover::written` / `holds` / `took` (`7734-7741`), including pages that are current and will not be taken; `took` scans and rebuilds up to 64 ranges each time. That is work on every refresh, not only on the re-takes it fixes. On a Ryzen 5 5600X with an RTX 3060 our submitting thread is busy 44-54 ms of a 55-58 ms frame, of which refreshes are 11-15 ms, so a few ms there shows directly in the frame. paales' run above (refreshes 12.9 -> 19.4 ms, together with #2504) is confounded but points the same way. Two options: - touch the cover only for pages being taken again (`taken == 0 || write > taken`), noting current pages' ranges lazily, at the cost of a little more re-take; - or `asked_for!` until it has been measured on a CPU-bound PC. On whether it fixes what it targets: #4377 adds `VICTORY_FLICKER_DETECT=1`, which counts A-B-A flicker events a minute at every present (about 59 a minute walking on our combined build). A value that jumps back to its first state and adapts again should show there, so `VICTORY_WC_KEEP_LEFT=0` against the default with it on gives a number even without the night white-out. We can run that pair on the 3060.
Author
Owner

@⁠paales on GitHub · 2026-11-30 22:42 UTC · original

Written by 🤖:

Right, my run measured #2504 and #4341 together (refreshes 12.9 against 19.4 ms a frame, the submitting thread 35.4 against 42.5 ms, RTX 5070 Ti with a Ryzen 9 5900X). I did not measure #4341 alone, so I cannot say which of the two cost what. asked_for! until a CPU-bound run measures it alone seems the safe default to me.

**@⁠paales** on GitHub · 2026-11-30 22:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7294207559) _Written by 🤖:_ Right, my run measured #2504 and #4341 together (refreshes 12.9 against 19.4 ms a frame, the submitting thread 35.4 against 42.5 ms, RTX 5070 Ti with a Ryzen 9 5900X). I did not measure #4341 alone, so I cannot say which of the two cost what. `asked_for!` until a CPU-bound run measures it alone seems the safe default to me.
Author
Owner

@⁠Lyrnc on GitHub · 2026-12-01 03:49 UTC · original

Bench result: the daytime walk A/B from "What was run", this morning. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Release build of this PR at 837b45e4, one shared shader cache (warmed first). Series X, 1440p, DLSS Quality, frame generation off, ray tracing off. Same save, a 5-minute scripted walk, 420 s runs, VICTORY_CLOBBER_WATCH=1 in both. old = VICTORY_WC_KEEP_LEFT=0, keep = default.

run fps frame ms p50 / p99 >50 ms /1000 draws/frame 5 s count lines refreshes over shader writes left on the card (title bytes sent) per second copies made again over them small read-backs jumped keep-left re-takes: runs / KB looked at / KB sent
old 27.4 35.5 / 73.0 123 8,428 71 457,715 (46.1 GB) ~1,290 0 66 0 / 0 / 0
keep 28.6 32.9 / 70.7 80 5,855 72 487,845 (49.2 GB) ~1,355 0 73 11 / 40 / 0

No device removed, DRED or "did not close" line in either run. No white-out, as expected in daytime.

What this shows

  • The new path works and is cheap. In keep it fired 11 times in 6 minutes: ranges taken again with no title write since, 40 KB compared, 0 KB sent. Before, each of those went up whole over what the shaders had left.
  • It is rare on a daytime walk. 11 re-takes against ~460,000-490,000 "refresh sends title bytes over shader writes left on the card" events per run in both arms.
    • That's ~1,300 a second and ~46-49 GB of title bytes over 6 minutes.
    • Those events are refreshes of ranges declared written by shaders in the last 16 frames, whose title bytes differ from the CPU's side. That is the case the PR deliberately leaves alone: the title wrote the page. The counts are the same with and without the change.
    • If the white-out is this class, the watch shows a large background of it in ordinary daytime play. The question is which of these, if any, matter to a value carried over frames.
  • Small read-back jumps (a value 16 times the one before, or a sixteenth, in the 80-byte rows) came 66 and 73 times, in both arms alike. These runs took no captures, so there is no picture to go with them.

What it does not show

  • Anything about the night white-out. That needs a night drive, and a run with VICTORY_WC_NO_BACK=0 to see whether the watch's counts and the jumps go away with it.
  • Frame rates are not a comparison. The two walks drew 8,428 and 5,855 per frame: different scenes, one run each.
  • Not tested: HW RT, other GPUs, VICTORY_UNIFIED_BACK.

AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs with its own scripts, and wrote this comment.

**@⁠Lyrnc** on GitHub · 2026-12-01 03:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7300100077) Bench result: the daytime walk A/B from "What was run", this morning. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Release build of this PR at 837b45e4, one shared shader cache (warmed first). Series X, 1440p, DLSS Quality, frame generation off, ray tracing off. Same save, a 5-minute scripted walk, 420 s runs, `VICTORY_CLOBBER_WATCH=1` in both. **old** = `VICTORY_WC_KEEP_LEFT=0`, **keep** = default. | run | fps | frame ms p50 / p99 | >50 ms /1000 | draws/frame | 5 s count lines | refreshes over shader writes left on the card (title bytes sent) | per second | copies made again over them | small read-backs jumped | keep-left re-takes: runs / KB looked at / KB sent | |---|---:|---|---:|---:|---:|---|---:|---:|---:|---| | old | 27.4 | 35.5 / 73.0 | 123 | 8,428 | 71 | 457,715 (46.1 GB) | ~1,290 | 0 | 66 | 0 / 0 / 0 | | keep | 28.6 | 32.9 / 70.7 | 80 | 5,855 | 72 | 487,845 (49.2 GB) | ~1,355 | 0 | 73 | 11 / 40 / 0 | No device removed, DRED or "did not close" line in either run. No white-out, as expected in daytime. **What this shows** - **The new path works and is cheap.** In keep it fired 11 times in 6 minutes: ranges taken again with no title write since, 40 KB compared, 0 KB sent. Before, each of those went up whole over what the shaders had left. - **It is rare on a daytime walk.** 11 re-takes against ~460,000-490,000 "refresh sends title bytes over shader writes left on the card" events per run in both arms. - That's ~1,300 a second and ~46-49 GB of title bytes over 6 minutes. - Those events are refreshes of ranges declared written by shaders in the last 16 frames, whose title bytes differ from the CPU's side. That is the case the PR deliberately leaves alone: the title wrote the page. The counts are the same with and without the change. - If the white-out is this class, the watch shows a large background of it in ordinary daytime play. The question is which of these, if any, matter to a value carried over frames. - **Small read-back jumps** (a value 16 times the one before, or a sixteenth, in the 80-byte rows) came 66 and 73 times, in both arms alike. These runs took no captures, so there is no picture to go with them. **What it does not show** - **Anything about the night white-out.** That needs a night drive, and a run with `VICTORY_WC_NO_BACK=0` to see whether the watch's counts and the jumps go away with it. - **Frame rates are not a comparison.** The two walks drew 8,428 and 5,855 per frame: different scenes, one run each. - Not tested: HW RT, other GPUs, `VICTORY_UNIFIED_BACK`. AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs with its own scripts, and wrote this comment.
github-bot force-pushed github-bot/gh-4340 from 837b45e456 to 72b3a24485 2026-12-01 04:14:01 +00:00 Compare
Author
Owner

@⁠Lyrnc on GitHub · 2026-12-01 04:11 UTC · original · edited 2026-12-01 04:23 UTC

Thanks @⁠IRennie74, your reading was right, and thanks @⁠paales for the run. On the previous head, every page of every refresh of a copy under the rule went through the cover: the lock, a BTreeMap::entry, written, holds and took, also for pages that were current and would not be taken.

Fixed in 72b3a244 (your first option): the cover is looked at, and locked, only for pages that are taken (again), taken == 0 || write > taken. Nothing else changes:

  • A range that is current was noted when it was taken, so pages that are not taken need no look.
  • write is the page's last write, so the cover learns of title writes in time at the page's next take.
  • The one thing lost: a range taken before its copy first got shader writes left on the card is not in the cover until its next take. That take goes up whole, as before.
  • The four keep_left_tests pass unchanged.

Cost, before and after. A new benchmark, shadow::keep_left_tests::copy_stale_cost_of_the_cover (#[ignore = "benchmark"]), times copy_stale for a copy under the rule against one without it. Release build, Ryzen 7 9800X3D, nanoseconds a refresh:

small range, current 1,024 pages (64 MiB), all current small range taken again, nothing changed
without the rule 16 1,457-1,906 (1.4-1.9 a page) 59-61
under the rule, previous head 24 8,950 (8.7 a page) 55
under the rule, 72b3a244 16 1,462 (1.4 a page) 55

So the per-page cost for pages that are current is gone. The take path costs what it did: a lookup on top of a copy or compare of the range. This is a warm-cache best case. In game the map lookups could miss the cache, so the old cost per page was probably higher than 7 ns. That makes the change matter more, not less.

What our bench saw in game (B1's comment above, daytime walk, RTX 5080): the new path fired 11 times in 6 minutes (40 KB compared, 0 sent). The clobber watch counted about 1,300 refreshes a second that sent title bytes over shader writes on pages the title had also written. That is the case VICTORY_WC_NO_BACK=1 accepts on purpose, and this PR doesn't change it. So if the night white-out is that class, the fix is beyond this PR: it's the NO_BACK trade-off, and VICTORY_WC_NO_BACK=0 is the test.

Default: with the cost on current pages gone, I've left VICTORY_WC_KEEP_LEFT on. Your A/B (VICTORY_WC_KEEP_LEFT=0 against the default with VICTORY_FLICKER_DETECT=1) works as you proposed. Yes please, on the 3060. A third arm with VICTORY_WC_NO_BACK=0 would show whether the A-B-A count comes from the NO_BACK class.

@⁠paales: your combined run can't separate #2504 from this. With the cover now off the walk over current pages, a run of this PR alone would show whether any of the 6.5 ms of refreshes was it.

Also rebased onto current main. Main's history was rewritten after 0c8c2092, so the PR showed as conflicting. Since the cover is now noted only at takes, #4295's early return no longer needs to touch it. My overlap note above no longer applies; only the textual conflict near let last remains.

Checks on 72b3a244 (Windows 11, rustc 1.98.1): cargo test --release -p victory-gpu --lib -- keep_left clobber --include-ignored passes the four keep_left_tests, the benchmark and the seven clobber::tests. cargo test -p victory-gpu --lib: 1,106 passed, 0 failed, 67 ignored. cargo clippy -p victory-gpu --all-targets -- -D warnings: 5 errors, all in host/font.rs, host/menu.rs and host/panel.rs from main's F1/F3 panel merge (#4635), none from this PR.

AI use: Claude Code (Claude Opus 5.5) made the change, wrote and ran the benchmark and tests, and wrote this.

**@⁠Lyrnc** on GitHub · 2026-12-01 04:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7300475412) · edited 2026-12-01 04:23 UTC Thanks @⁠IRennie74, your reading was right, and thanks @⁠paales for the run. On the previous head, every page of every refresh of a copy under the rule went through the cover: the lock, a `BTreeMap::entry`, `written`, `holds` and `took`, also for pages that were current and would not be taken. **Fixed in 72b3a244** (your first option): the cover is looked at, and locked, only for pages that are taken (again), `taken == 0 || write > taken`. Nothing else changes: - A range that is current was noted when it was taken, so pages that are not taken need no look. - `write` is the page's last write, so the cover learns of title writes in time at the page's next take. - The one thing lost: a range taken before its copy first got shader writes left on the card is not in the cover until its next take. That take goes up whole, as before. - The four `keep_left_tests` pass unchanged. **Cost, before and after.** A new benchmark, `shadow::keep_left_tests::copy_stale_cost_of_the_cover` (`#[ignore = "benchmark"]`), times `copy_stale` for a copy under the rule against one without it. Release build, Ryzen 7 9800X3D, nanoseconds a refresh: | | small range, current | 1,024 pages (64 MiB), all current | small range taken again, nothing changed | |---|---:|---:|---:| | without the rule | 16 | 1,457-1,906 (1.4-1.9 a page) | 59-61 | | under the rule, previous head | 24 | 8,950 (8.7 a page) | 55 | | under the rule, 72b3a244 | 16 | 1,462 (1.4 a page) | 55 | So the per-page cost for pages that are current is gone. The take path costs what it did: a lookup on top of a copy or compare of the range. This is a warm-cache best case. In game the map lookups could miss the cache, so the old cost per page was probably higher than 7 ns. That makes the change matter more, not less. **What our bench saw in game** (B1's comment above, daytime walk, RTX 5080): the new path fired 11 times in 6 minutes (40 KB compared, 0 sent). The clobber watch counted about 1,300 refreshes a second that sent title bytes over shader writes on pages the title had also written. That is the case `VICTORY_WC_NO_BACK=1` accepts on purpose, and this PR doesn't change it. So if the night white-out is that class, the fix is beyond this PR: it's the NO_BACK trade-off, and `VICTORY_WC_NO_BACK=0` is the test. **Default:** with the cost on current pages gone, I've left `VICTORY_WC_KEEP_LEFT` on. Your A/B (`VICTORY_WC_KEEP_LEFT=0` against the default with `VICTORY_FLICKER_DETECT=1`) works as you proposed. Yes please, on the 3060. A third arm with `VICTORY_WC_NO_BACK=0` would show whether the A-B-A count comes from the NO_BACK class. @⁠paales: your combined run can't separate #2504 from this. With the cover now off the walk over current pages, a run of this PR alone would show whether any of the 6.5 ms of refreshes was it. Also rebased onto current main. Main's history was rewritten after 0c8c2092, so the PR showed as conflicting. Since the cover is now noted only at takes, #4295's early return no longer needs to touch it. My overlap note above no longer applies; only the textual conflict near `let last` remains. Checks on 72b3a244 (Windows 11, rustc 1.98.1): `cargo test --release -p victory-gpu --lib -- keep_left clobber --include-ignored` passes the four `keep_left_tests`, the benchmark and the seven `clobber::tests`. `cargo test -p victory-gpu --lib`: 1,106 passed, 0 failed, 67 ignored. `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 5 errors, all in `host/font.rs`, `host/menu.rs` and `host/panel.rs` from main's F1/F3 panel merge (#4635), none from this PR. AI use: Claude Code (Claude Opus 5.5) made the change, wrote and ran the benchmark and tests, and wrote this.
Author
Owner

@⁠albertik322-sudo on GitHub · 2026-12-01 17:00 UTC · original

Positive on a laptop, in the same batch (with #4295, #4494, #4877, #4207). PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, 1080p output, DLSS Performance, FG x4.

Combined effect of the batch: fixed cost per frame (linear fit of ms vs draws over ~5 min standing still) dropped 47 ms to 25.5 ms, fps median 15.9 to 17.4, copy-back line ~13-18 ms with no growth in copied-back bytes. No missing or wrong surfaces observed in hours of play — the clobber watch catches nothing here.

Laptop note: the related zero-copy-through-BAR experiment (VICTORY_WC_BAR=1) is a catastrophe on this machine specifically — 1.4 fps, copy-back 700-1300 ms, PCIe writes page by page. MSI GP66 Leopard; the BAR is resizable and the writes are just slow. Keep whatever stays-on-card logic off that path on laptops.

**@⁠albertik322-sudo** on GitHub · 2026-12-01 17:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7318594286) Positive on a laptop, in the same batch (with #4295, #4494, #4877, #4207). PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, 1080p output, DLSS Performance, FG x4. Combined effect of the batch: fixed cost per frame (linear fit of ms vs draws over ~5 min standing still) dropped **47 ms to 25.5 ms**, fps median 15.9 to 17.4, copy-back line ~13-18 ms with no growth in copied-back bytes. No missing or wrong surfaces observed in hours of play — the clobber watch catches nothing here. Laptop note: the related zero-copy-through-BAR experiment (`VICTORY_WC_BAR=1`) is a catastrophe on this machine specifically — 1.4 fps, copy-back 700-1300 ms, PCIe writes page by page. MSI GP66 Leopard; the BAR is resizable and the writes are just slow. Keep whatever stays-on-card logic off that path on laptops.
github-bot closed this pull request 2026-12-01 18:43:49 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4340#issuecomment-7321385312) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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!4341
No description provided.