GPU: VICTORY_BACK_QUIET=1: copy-backs of write-watched memory no longer read as title writes (#1169) #1185

Open
Yorivel wants to merge 1 commit from upstream-pr/1188 into main
Yorivel commented 2026-11-25 23:14:22 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Yorivel on 2026-11-25T23:14:22Z.


AI-assisted (Claude Code). Numbers and log lines only, no game data.

What

VICTORY_BACK_QUIET=1, off by default. A copy-back into private, write-watched title memory works as follows:

  1. It is written as before.
  2. The written pages' kernel write-watch bits are reset. That happens only if none of those bits was set before the write: if the title had written one of the pages since the last asking, the copy-back is written the old way.
  3. The journal is told the pages changed, through watch::wrote_own, as put_back_own (VICTORY_BACK_OWN_VIEW) does for view memory. Every other copy holding those pages takes them again at its next refresh.
  4. The copy that made the bytes notes itself current, as put_back_own does.

Today the copy-back's own write shows as a title write at the next asking. The copy that wrote the bytes then copies them in again and sends them back up, although it holds them already. shadow.rs says so itself: "Our write shows as a title write at the copy's next refresh, which copies those pages once more (some dozens of MB a frame)." The read census in #1169 measured this at about 92% of the layer's touches of copied-back pages. VICTORY_BACK_OWN_VIEW already removes it for view memory. This switch is the private-memory side of the same thing.

It is hooked where the copy-back writes: copy_back_with (per run), relay_merge and card_merge_relay (before put_back_own), and card_merge.

The shortcut it takes

A title write to one of the pages between the copy-back's write and the reset would be lost to the write-watch. The window is a few kernel calls long. The check before the write excludes pages the title had already written since the last asking. The census saw the title touch copied-back pages at 0.00-0.05 MB/s.

Measured

RTX 4090 (32-lane waves), driver 621.40, i9-14900K, 64 GB, Windows 11, Series X profile, diagnostics build. The tree is not plain main: it is 085ee7c + #994 (with #854/#993) + #346 (with named windows declared only when marked) + #500 + #501. Structure builder on, RELAY=2 and the README's speed set. Barracks after the hand-off, settled, six readings each:

ms a frame fps copies up per frame preparing
without either switch 192-203 5.0-5.2 ~200 MB, 50-56 ms 99-110 ms
VICTORY_BACK_QUIET=1 188-192 5.2-5.3 160-168 MB, 46-48 ms 88-97 ms
VICTORY_BACK_QUIET=1 + VICTORY_BACK_OWN_VIEW=1 164-168 6.0-6.1 104-108 MB, 30-32 ms 73-80 ms
(the same tree with the builder off, for scale) 161 5.9

The quiet path took about 45% of the copy-back stretches (377k stretches, 17 GB in that run). The rest were view memory, which put_back_own took (353k pages noted current). 0 exceptions in every run. A pulsing light leak under bunks and on a face with the builder on shows with and without both switches, so it is not from them.

cargo test -p victory-gpu --lib shadow::: 30 passed. Not measured on plain main or without the builder yet. Reports welcome.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6615694833 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1188). Originally posted by [Yorivel](https://github.com/Yorivel) on 2026-11-25T23:14:22Z. --- *AI-assisted (Claude Code). Numbers and log lines only, no game data.* ## What `VICTORY_BACK_QUIET=1`, off by default. A copy-back into **private, write-watched** title memory works as follows: 1. It is written as before. 2. The written pages' kernel write-watch bits are reset. That happens only if none of those bits was set before the write: if the title had written one of the pages since the last asking, the copy-back is written the old way. 3. The journal is told the pages changed, through `watch::wrote_own`, as `put_back_own` (`VICTORY_BACK_OWN_VIEW`) does for view memory. Every other copy holding those pages takes them again at its next refresh. 4. The copy that made the bytes notes itself current, as `put_back_own` does. Today the copy-back's own write shows as a title write at the next asking. The copy that wrote the bytes then copies them in again and sends them back up, although it holds them already. `shadow.rs` says so itself: *"Our write shows as a title write at the copy's next refresh, which copies those pages once more (some dozens of MB a frame)."* The read census in #1169 measured this at about 92% of the layer's touches of copied-back pages. `VICTORY_BACK_OWN_VIEW` already removes it for view memory. This switch is the private-memory side of the same thing. It is hooked where the copy-back writes: `copy_back_with` (per run), `relay_merge` and `card_merge_relay` (before `put_back_own`), and `card_merge`. ## The shortcut it takes A title write to one of the pages *between* the copy-back's write and the reset would be lost to the write-watch. The window is a few kernel calls long. The check before the write excludes pages the title had already written since the last asking. The census saw the title touch copied-back pages at 0.00-0.05 MB/s. ## Measured RTX 4090 (32-lane waves), driver 621.40, i9-14900K, 64 GB, Windows 11, Series X profile, diagnostics build. The tree is **not** plain `main`: it is `085ee7c` + #994 (with #854/#993) + #346 (with named windows declared only when marked) + #500 + #501. Structure builder on, `RELAY=2` and the README's speed set. Barracks after the hand-off, settled, six readings each: | | ms a frame | fps | copies up per frame | preparing | |---|---|---|---|---| | without either switch | 192-203 | 5.0-5.2 | ~200 MB, 50-56 ms | 99-110 ms | | `VICTORY_BACK_QUIET=1` | 188-192 | 5.2-5.3 | 160-168 MB, 46-48 ms | 88-97 ms | | `VICTORY_BACK_QUIET=1` + `VICTORY_BACK_OWN_VIEW=1` | **164-168** | **6.0-6.1** | **104-108 MB, 30-32 ms** | **73-80 ms** | | (the same tree with the builder **off**, for scale) | 161 | 5.9 | | | The quiet path took about 45% of the copy-back stretches (377k stretches, 17 GB in that run). The rest were view memory, which `put_back_own` took (353k pages noted current). 0 exceptions in every run. A pulsing light leak under bunks and on a face with the builder on shows **with and without** both switches, so it is not from them. `cargo test -p victory-gpu --lib shadow::`: 30 passed. Not measured on plain `main` or without the builder yet. Reports welcome. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ym1r1710 commented 2026-11-26 00:06:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Ym1r1710 on 2026-11-25T23:55:34Z.


Tried it on an RTX 5080 (Series X, fork main 6d20eed + #690's exact copy-back from the issue, prison cell, two runs each, medians).

One thing first: with #690's putback on (VICTORY_EXACT_BACK unset) none of the quiet hooks are reached, because putback::back returns before them. Same reason BACK_OWN_VIEW did nothing on that tree. So I ran it with VICTORY_EXACT_BACK=0:

  • EXACT_BACK=0 alone: 108.6 / 109.1 ms
  • EXACT_BACK=0 + BACK_QUIET=1 + BACK_OWN_VIEW=1: 103.4 / 105.9 ms
  • #690's putback, neither switch: 102.2 / 96.6 ms

So about 4 ms from the pair on the plain path here, no device loss, picture looked the same. The log said 147k stretches quiet (1.66 GB) and ~66k written the old way in both runs.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7178209291 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1188#issuecomment-7178209291). Originally posted by [Ym1r1710](https://github.com/Ym1r1710) on 2026-11-25T23:55:34Z. --- Tried it on an RTX 5080 (Series X, fork main 6d20eed + #690's exact copy-back from the issue, prison cell, two runs each, medians). One thing first: with #690's putback on (VICTORY_EXACT_BACK unset) none of the quiet hooks are reached, because putback::back returns before them. Same reason BACK_OWN_VIEW did nothing on that tree. So I ran it with VICTORY_EXACT_BACK=0: - EXACT_BACK=0 alone: 108.6 / 109.1 ms - EXACT_BACK=0 + BACK_QUIET=1 + BACK_OWN_VIEW=1: 103.4 / 105.9 ms - #690's putback, neither switch: 102.2 / 96.6 ms So about 4 ms from the pair on the plain path here, no device loss, picture looked the same. The log said 147k stretches quiet (1.66 GB) and ~66k written the old way in both runs.
BitWuehler commented 2026-11-26 00:06:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BitWuehler on 2026-11-26T00:01:22Z.


Tested on Linux (GE-Proton + vkd3d-proton, RTX 5080) with VICTORY_BACK_QUIET=1:

  • CPU preparing median dropped from 122.1 ms to 51.2 ms (copies 84.8 ms -> 31.6 ms, copying back 84.4 ms -> 57.5 ms).
  • Logged 360,448 stretches (15,537 MB) handled quietly without re-flagging title writes.

Note: Log analysis and write-up were AI-assisted based on local runtime measurements.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7178309260 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1188#issuecomment-7178309260). Originally posted by [BitWuehler](https://github.com/BitWuehler) on 2026-11-26T00:01:22Z. --- Tested on Linux (GE-Proton + vkd3d-proton, RTX 5080) with `VICTORY_BACK_QUIET=1`: - CPU `preparing` median dropped from `122.1 ms` to **`51.2 ms`** (`copies` `84.8 ms -> 31.6 ms`, `copying back` `84.4 ms -> 57.5 ms`). - Logged `360,448 stretches (15,537 MB)` handled quietly without re-flagging title writes. *Note: Log analysis and write-up were AI-assisted based on local runtime measurements.*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1188:upstream-pr/1188'
git switch 'upstream-pr/1188'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1188'
git switch 'upstream-pr/1188'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1188'
git switch 'upstream-pr/1188'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1188'
git switch 'main'
git merge --squash 'upstream-pr/1188'
git switch 'main'
git merge --ff-only 'upstream-pr/1188'
git switch 'main'
git merge 'upstream-pr/1188'
git push origin 'main'
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
fxceless/victory-fork!1185
No description provided.