Back reads: per-buffer diagnostics of the memory bridge, copy-back, refreshes and waits (VICTORY_BACK_READS, diagnostics builds only) #2960

Open
github-bot wants to merge 2 commits from github-bot/gh-2960 into main AGit
Owner

@⁠AS-AI-DEV on GitHub · 2026-11-29 19:02 UTC · original
AS-AI-DEV:back-reads → main · +1544 −0 · 7 files · 2 commits · open

Related: #2415 (cutting memory-bridging cost), docs/unified-memory-audit.md (3.6, U0: "a read watch"; VICTORY_READ_WATCH is named in texback.rs but was never built). Needs #2048, or any fix for the diagnostics build, to compile: 829188e's and f889bb0's --features diagnostics build fail on their own (copystat.rs mb, Host::submit's shadowed timing()).

What it changes

Scope: a diagnostic tool only; it changes nothing in how the game runs. Every line it adds to the layer is behind #[cfg(all(windows, feature = "diagnostics"))], so release builds compile none of it (their code is the same as without this PR). In a diagnostics build it is off unless one of its switches is set, and when on it only counts and logs: it never changes what the title reads or writes, never changes a protection, and makes no copy. The one thing it does to memory is take a sample of stored pages out of the working set, which Windows brings back by itself at the next touch (a soft fault). Its cost when on is in "How it was tested". A change based on what it finds would be a separate PR.

A diagnostic for the memory bridge, for everyone working on it. Diagnostics builds only: the module and every hook are #[cfg(all(windows, feature = "diagnostics"))], so release builds do not change.

The layer lands and merges what shaders wrote back into title memory, and refreshes title memory up to its copies, whether or not anything needs the bytes. Per frame and per host copy, this counts what happens to each stored 64 KiB page until its next store: which of the layer's own readers take it, whether the title writes it, and, on a sample, whether anything touched it at all. The look changes no protection: the stored pages are taken out of the working set (VirtualUnlock of unlocked pages) and Windows is asked later which came back (QueryWorkingSetEx); a touched page costs one soft fault.

It complements VICTORY_LAND_READS (land/reads.rs): that one makes landed pages no-access and counts the faults, which is exact about reads and writes but changes protections, costs a fault per page, and gives totals only. This one is passive and gives the table by buffer, which says where to work first.

Ported from Dathinel/victory-4gb's backreads.rs, adapted to this tree: stores are hooked where this tree makes them (crate::land's pieces, shadow::put_changed for merges), and the copy being worked for is a scope on the thread. Added, each its own switch, off unless set:

Switch Adds
VICTORY_BACK_READS=1|2|alt the counts; 2 also looks at one stored page in 8; alt 20 s each way, so the looks' cost shows
VICTORY_BACK_READS_KIND=1 what each buffer is: title buffer or window; copy in card memory, in card memory the CPU maps, write-combined, in place, written by shaders
VICTORY_BACK_READS_TIME=1 CPU time per buffer: merges and landings, title bytes under flights, refreshes; and of it the time preparing submissions (Host::submit, the frame line's "the submitting thread", on whichever thread runs it); the table ranked by that
VICTORY_BACK_READS_WRITES=1 the title's writes after a store where no guard tells them: by the journal (write-watched memory, a lower bound) and by write faults (guarded memory)
VICTORY_REFRESH_WATCH=1 the other way: per buffer, refreshes that ran, those that copied nothing, bytes copied (works alone)
VICTORY_BACK_READS_SCENE=1 the interval's fps and draws a frame in each summary
VICTORY_BACK_READS_WAITS=1 the submissions' waits for the card per buffer: the waits crate::host already blames on a range of title memory go to the copy that holds it, the rest to a row of their own; with the submitting thread's share
VICTORY_BACK_READS_SPLIT_MB=<n> copies bigger than n MB counted by region (a title's big GPU pool is one buffer)
VICTORY_BACK_READS_CSV=<file> rows per buffer and interval, for charts and comparing runs

How to read it, and what it cannot tell, is in docs/back-reads.md.

How it was tested

  • GPU and profile: RTX 5060 Ti 16 GB (resizable BAR on), Ryzen 7 5800X, 32 GB, Windows 11; Series X, 2560x1440 output, DLSS performance, frame generation 2x, ray tracing off. Diagnostics build of f889bb0 + #2048's two compile fixes + this.
  • Before: nothing of the kind per buffer.
  • After, one run standing in a house (~7,000 draws a frame, 17 fps), all switches on, an interval of 267 frames, per frame:
    • 5.3 MB stored back in 307 stretches; 80 % of them of a page stored the frame before or in the same frame.
    • Of the looked-at stores: 38 % untouched before the next store, 43 % touched only by the layer's own readers, 18 % written by the title, none touched by anything else (the most the title's own reads can be). The same shape as the 49-minute run recorded in victory-4gb's notes (60 % untouched, 36 % the layer's only, 0.19 % other).
    • The title wrote after 43 stores by the journal's account and 30 by write faults.
    • CPU time, summed over threads: merges and landings 6.4 ms, refreshes 31.0 ms, title bytes under flights 3.0 ms.
    • 1,144 refreshes, 49 % of them copying nothing; 49 MB copied up.
    • One 174 MB title buffer (copy in card memory, written by shaders) took half of all bytes stored back since the start.
  • Second commit (submitting thread, waits, regions), walking runs of the diagnostics build:
    • Submitting thread: 13.0 of the frame line's 50.5 ms a frame with async submission (refreshes 10.8, title bytes under flights 2.2, landings 0.0: they run on the relay thread); 9.0 of 57.6 ms with submissions on the title's thread (VICTORY_ASYNC_SUBMIT=0 needs VICTORY_THIN=0 too; that run ended in a device loss, as that configuration has before here without this).
    • Waits: as the route plays here, 2.3 ms a frame, all for presents and synchronous submissions, none on a buffer. With waits forced (VICTORY_CARD_STEPS=0): 22.8 ms counted against the frame line's 24.0 ms "waiting for flights", 70 % of it on two small buffers.
    • Regions: with SPLIT_MB=8, no row left for a copy over 8 MB.
    • Cost: every switch on against all off, same route and draw counts: the submitting thread +9 to 11 ms a frame, 5-14 % fewer frames. Counts and shares stand; absolute times are a slower run's. Turn on what you need.
  • A run with only VICTORY_BACK_READS=alt and a release build were also run: the release build is unchanged, the game ran normally under both.
  • For shader changes, the wave sizes tested: none (no shader changes).
  • cargo test passed for the crates it touches: no new failures; victory-gpu's failures on f889bb0 are the same with and without this (every_switch_of_the_translator_is_in_the_key: VICTORY_SCALAR_SPLITS not read any more; the menu and xmem tests that fail only in the full parallel run). The module only counts and has no tests of its own.
  • cargo clippy -p victory-gpu --all-targets --features diagnostics: nothing in the files and lines this adds (the warnings left are elsewhere). cargo xtask policy: nothing from this (the one finding is heap_sites/frame_users.rs, as on f889bb0). Switches read through asked_for! where they are on/off.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: VICTORY_LAND_READS (in the tree, complementary, see above); no open PR adds a per-buffer read or refresh watch.
**@⁠AS-AI-DEV** on GitHub · 2026-11-29 19:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960) `AS-AI-DEV:back-reads` → `main` · +1544 −0 · 7 files · 2 commits · open Related: #2415 (cutting memory-bridging cost), `docs/unified-memory-audit.md` (3.6, U0: "a read watch"; `VICTORY_READ_WATCH` is named in `texback.rs` but was never built). Needs #2048, or any fix for the diagnostics build, to compile: 829188e's and f889bb0's `--features diagnostics` build fail on their own (`copystat.rs` `mb`, `Host::submit`'s shadowed `timing()`). ## What it changes **Scope: a diagnostic tool only; it changes nothing in how the game runs.** Every line it adds to the layer is behind `#[cfg(all(windows, feature = "diagnostics"))]`, so release builds compile none of it (their code is the same as without this PR). In a diagnostics build it is off unless one of its switches is set, and when on it only counts and logs: it never changes what the title reads or writes, never changes a protection, and makes no copy. The one thing it does to memory is take a sample of stored pages out of the working set, which Windows brings back by itself at the next touch (a soft fault). Its cost when on is in "How it was tested". A change based on what it finds would be a separate PR. A diagnostic for the memory bridge, for everyone working on it. Diagnostics builds only: the module and every hook are `#[cfg(all(windows, feature = "diagnostics"))]`, so release builds do not change. The layer lands and merges what shaders wrote back into title memory, and refreshes title memory up to its copies, whether or not anything needs the bytes. Per frame **and per host copy**, this counts what happens to each stored 64 KiB page until its next store: which of the layer's own readers take it, whether the title writes it, and, on a sample, whether anything touched it at all. The look changes no protection: the stored pages are taken out of the working set (`VirtualUnlock` of unlocked pages) and Windows is asked later which came back (`QueryWorkingSetEx`); a touched page costs one soft fault. It complements `VICTORY_LAND_READS` (`land/reads.rs`): that one makes landed pages no-access and counts the faults, which is exact about reads and writes but changes protections, costs a fault per page, and gives totals only. This one is passive and gives the **table by buffer**, which says where to work first. Ported from Dathinel/victory-4gb's `backreads.rs`, adapted to this tree: stores are hooked where this tree makes them (`crate::land`'s pieces, `shadow::put_changed` for merges), and the copy being worked for is a scope on the thread. Added, **each its own switch, off unless set**: | Switch | Adds | |---|---| | `VICTORY_BACK_READS=1\|2\|alt` | the counts; `2` also looks at one stored page in 8; `alt` 20 s each way, so the looks' cost shows | | `VICTORY_BACK_READS_KIND=1` | what each buffer is: title buffer or window; copy in card memory, in card memory the CPU maps, write-combined, in place, written by shaders | | `VICTORY_BACK_READS_TIME=1` | CPU time per buffer: merges and landings, title bytes under flights, refreshes; and of it the time preparing submissions (`Host::submit`, the frame line's "the submitting thread", on whichever thread runs it); the table ranked by that | | `VICTORY_BACK_READS_WRITES=1` | the title's writes after a store where no guard tells them: by the journal (write-watched memory, a lower bound) and by write faults (guarded memory) | | `VICTORY_REFRESH_WATCH=1` | the other way: per buffer, refreshes that ran, those that copied nothing, bytes copied (works alone) | | `VICTORY_BACK_READS_SCENE=1` | the interval's fps and draws a frame in each summary | | `VICTORY_BACK_READS_WAITS=1` | the submissions' waits for the card per buffer: the waits `crate::host` already blames on a range of title memory go to the copy that holds it, the rest to a row of their own; with the submitting thread's share | | `VICTORY_BACK_READS_SPLIT_MB=<n>` | copies bigger than `n` MB counted by region (a title's big GPU pool is one buffer) | | `VICTORY_BACK_READS_CSV=<file>` | rows per buffer and interval, for charts and comparing runs | How to read it, and what it cannot tell, is in `docs/back-reads.md`. ## How it was tested - GPU and profile: RTX 5060 Ti 16 GB (resizable BAR on), Ryzen 7 5800X, 32 GB, Windows 11; Series X, 2560x1440 output, DLSS performance, frame generation 2x, ray tracing off. Diagnostics build of f889bb0 + #2048's two compile fixes + this. - Before: nothing of the kind per buffer. - After, one run standing in a house (~7,000 draws a frame, 17 fps), all switches on, an interval of 267 frames, per frame: - **5.3 MB stored back** in 307 stretches; **80 %** of them of a page stored the frame before or in the same frame. - Of the looked-at stores: **38 % untouched** before the next store, **43 % touched only by the layer's own readers**, 18 % written by the title, **none touched by anything else** (the most the title's own reads can be). The same shape as the 49-minute run recorded in victory-4gb's notes (60 % untouched, 36 % the layer's only, 0.19 % other). - The title wrote after 43 stores by the journal's account and 30 by write faults. - CPU time, summed over threads: merges and landings 6.4 ms, refreshes 31.0 ms, title bytes under flights 3.0 ms. - **1,144 refreshes, 49 % of them copying nothing**; 49 MB copied up. - One 174 MB title buffer (copy in card memory, written by shaders) took **half of all bytes stored back** since the start. - Second commit (submitting thread, waits, regions), walking runs of the diagnostics build: - *Submitting thread*: 13.0 of the frame line's 50.5 ms a frame with async submission (refreshes 10.8, title bytes under flights 2.2, landings 0.0: they run on the relay thread); 9.0 of 57.6 ms with submissions on the title's thread (`VICTORY_ASYNC_SUBMIT=0` needs `VICTORY_THIN=0` too; that run ended in a device loss, as that configuration has before here without this). - *Waits*: as the route plays here, 2.3 ms a frame, all for presents and synchronous submissions, none on a buffer. With waits forced (`VICTORY_CARD_STEPS=0`): 22.8 ms counted against the frame line's 24.0 ms "waiting for flights", 70 % of it on two small buffers. - *Regions*: with `SPLIT_MB=8`, no row left for a copy over 8 MB. - *Cost*: every switch on against all off, same route and draw counts: the submitting thread +9 to 11 ms a frame, 5-14 % fewer frames. Counts and shares stand; absolute times are a slower run's. Turn on what you need. - A run with only `VICTORY_BACK_READS=alt` and a release build were also run: the release build is unchanged, the game ran normally under both. - For shader changes, the wave sizes tested: none (no shader changes). - `cargo test` passed for the crates it touches: no new failures; `victory-gpu`'s failures on f889bb0 are the same with and without this (`every_switch_of_the_translator_is_in_the_key`: `VICTORY_SCALAR_SPLITS` not read any more; the menu and xmem tests that fail only in the full parallel run). The module only counts and has no tests of its own. - `cargo clippy -p victory-gpu --all-targets --features diagnostics`: nothing in the files and lines this adds (the warnings left are elsewhere). `cargo xtask policy`: nothing from this (the one finding is `heap_sites/frame_users.rs`, as on f889bb0). Switches read through `asked_for!` where they are on/off. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: `VICTORY_LAND_READS` (in the tree, complementary, see above); no open PR adds a per-buffer read or refresh watch.
Port of Dathinel/victory-4gb's backreads.rs (from its c36971b on),
adapted to this tree, with switches added; diagnostics builds only.

What shaders wrote is landed or merged back into title memory, and title
memory is refreshed up to its copies, whether or not anything needs the
bytes. Per frame and per host copy this counts what happens to each
stored 64 KiB page until its next store: which readers of ours take it,
whether the title writes it, and (on a sample) whether anything touched
it at all: the page is taken out of the working set after the store and
Windows is asked later whether it came back, with no protection changed.

Adapted: stores are hooked where this tree makes them (crate::land's
pieces, shadow::put_changed for merges), the copy is told by a scope on
the thread, a merge's read ends the page's last store in host::read_into.

Added, each its own switch, off unless set (docs/back-reads.md):
VICTORY_BACK_READS_KIND (what each buffer is), _TIME (CPU time per
buffer by reader), _WRITES (title writes by the journal and by write
faults where no guard tells them), _SCENE (fps and draws in each
summary), _CSV=<file> (rows per buffer and interval), and
VICTORY_REFRESH_WATCH (refreshes per buffer: ran, copied nothing, bytes).

Run here (diagnostics build, Ryzen 7 5800X, RTX 5060 Ti 16 GB, standing,
~7,000 draws, 17 fps): 5.3 MB a frame stored back in 307 stretches; of
the looked-at stores 38 % untouched, 43 % touched by readers of ours
only, 18 % written by the title, none by anything else; 1,144 refreshes
a frame, 49 % of them copying nothing.

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

@⁠akimfomin on GitHub · 2026-11-29 19:53 UTC · original

Thanks for adding per-buffer evidence. We’re evaluating the read-back path for native 2560×1440 on Ada, with Series X, RT enabled, DLSS and FG off. Your observation that one 174 MB buffer accounts for half the stored bytes stood out. Which counters or negative controls would you use to separate truly redundant transfers from CPU-visible partial writes and from time waiting for GPU completion? Have you identified a public synthetic workload where omitting a transfer remained byte-exact? We’d like to validate the invariants before trying a change in-game.

**@⁠akimfomin** on GitHub · 2026-11-29 19:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960#issuecomment-7261637003) Thanks for adding per-buffer evidence. We’re evaluating the read-back path for native 2560×1440 on Ada, with Series X, RT enabled, DLSS and FG off. Your observation that one 174 MB buffer accounts for half the stored bytes stood out. Which counters or negative controls would you use to separate truly redundant transfers from CPU-visible partial writes and from time waiting for GPU completion? Have you identified a public synthetic workload where omitting a transfer remained byte-exact? We’d like to validate the invariants before trying a change in-game.
Author
Owner

@⁠AS-AI-DEV on GitHub · 2026-11-29 20:14 UTC · original · edited 2026-11-29 21:20 UTC

Thanks, good questions. What the tool can and cannot separate, as it stands:

Redundant vs. partial CPU writes vs. needed, per stored 64 KiB page until its next store:

  • untouched (looks, VICTORY_BACK_READS=2): nothing touched the page at all. This is the candidate for "the transfer was redundant".
  • written by the title: with VICTORY_BACK_READS_WRITES=1, by write faults on guarded memory (never the layer's: its stores open the guard first) and by the journal on write-watched memory (the first asking after the layer's store is that store itself, so this is a lower bound). A page in this bucket was overwritten, but possibly only in part: the tool does not tell a partial write from a whole one, so this bucket alone does not prove the transfer redundant.
  • touched with readers of ours and no write: only the layer's own refreshes/landings read it. Redundant for the title, but it may feed another copy (I saw small buffers whose landed pages were read 100 % by the layer's own refreshes of another copy, i.e. a card → title memory → card round trip).
  • touched by something else: the upper bound of the title's own reads. That is the bucket that must stay.

Negative controls / cross-checks I would use:

  • VICTORY_LAND_READS=1 (already in the tree) on the same scene: it makes landed pages no-access and counts the faults by whose code, exact about reads vs. writes. Its "other code read" should not exceed this tool's something else bucket, and its untouched should match its "landed again untouched".
  • VICTORY_BACK_READS=alt: looks on 20 s, off 20 s, so the looks' own cost (one soft fault per touched page) shows in the frame log.
  • A buffer the title is known to read back on the CPU should land in something else; one only the card reads should not. I have not built such a labelled control yet.

Time waiting for GPU completion is not measured by this tool. It times the CPU work of merges/landings, refreshes and the look for title bytes under flights (VICTORY_BACK_READS_TIME, split by thread on my local branch at the time, since added to this PR). Waits for flights are in the existing frame line ("waiting for flights") and the card meter.

One finding from today that may matter for your evaluation: on this tree (VICTORY_RELAY=1) the landings run on the relay thread, not on the submitting thread. In a walking run (Series X, 2560x1440, DLSS performance, frame generation 2x, ray tracing off; RTX 5060 Ti, Ryzen 7 5800X), the bridge's CPU time on the submitting thread was ~14.6 ms a frame: refreshes 11.5 ms and the look for title bytes under flights 3.1 ms, while landings/merges there were 0.0 ms (9.5 ms on other threads). So omitting redundant landings would mostly save helper CPU and memory bandwidth, not the frame. Also, the 174 MB buffer is one buffer covering most of a 185 MB GPU pool the title reserves at device start; split by region (VICTORY_BACK_READS_SPLIT_MB=8, on my local branch at the time, since added to this PR), its first 8 MB holds most of its refresh cost.

A byte-exact synthetic workload: I have not found or built one. Two candidates in the tree: host/membench.rs (synthetic frames through the title's own calls, added in the v2026.11.29.02 hotfix) could get a mode that leaves out a class of landing and compares the title-memory bytes the next frame reads against a run that lands everything; and the captured-frame replay (diagnostics builds) could compare render targets with and without a transfer. Neither is done; I would be glad to compare notes if you start one.

**@⁠AS-AI-DEV** on GitHub · 2026-11-29 20:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960#issuecomment-7261924310) · edited 2026-11-29 21:20 UTC Thanks, good questions. What the tool can and cannot separate, as it stands: **Redundant vs. partial CPU writes vs. needed**, per stored 64 KiB page until its next store: - *untouched* (looks, `VICTORY_BACK_READS=2`): nothing touched the page at all. This is the candidate for "the transfer was redundant". - *written by the title*: with `VICTORY_BACK_READS_WRITES=1`, by write faults on guarded memory (never the layer's: its stores open the guard first) and by the journal on write-watched memory (the first asking after the layer's store is that store itself, so this is a lower bound). A page in this bucket was overwritten, but possibly only in part: the tool does not tell a partial write from a whole one, so this bucket alone does not prove the transfer redundant. - *touched with readers of ours and no write*: only the layer's own refreshes/landings read it. Redundant for the title, but it may feed another copy (I saw small buffers whose landed pages were read 100 % by the layer's own refreshes of another copy, i.e. a card → title memory → card round trip). - *touched by something else*: the upper bound of the title's own reads. That is the bucket that must stay. **Negative controls / cross-checks** I would use: - `VICTORY_LAND_READS=1` (already in the tree) on the same scene: it makes landed pages no-access and counts the faults by whose code, exact about reads vs. writes. Its "other code read" should not exceed this tool's *something else* bucket, and its *untouched* should match its "landed again untouched". - `VICTORY_BACK_READS=alt`: looks on 20 s, off 20 s, so the looks' own cost (one soft fault per touched page) shows in the frame log. - A buffer the title is known to read back on the CPU should land in *something else*; one only the card reads should not. I have not built such a labelled control yet. **Time waiting for GPU completion is not measured by this tool.** It times the CPU work of merges/landings, refreshes and the look for title bytes under flights (`VICTORY_BACK_READS_TIME`, split by thread on my local branch at the time, since added to this PR). Waits for flights are in the existing frame line ("waiting for flights") and the card meter. One finding from today that may matter for your evaluation: on this tree (`VICTORY_RELAY=1`) the landings run on the relay thread, **not on the submitting thread**. In a walking run (Series X, 2560x1440, DLSS performance, frame generation 2x, ray tracing off; RTX 5060 Ti, Ryzen 7 5800X), the bridge's CPU time on the submitting thread was ~14.6 ms a frame: refreshes 11.5 ms and the look for title bytes under flights 3.1 ms, while landings/merges there were 0.0 ms (9.5 ms on other threads). So omitting redundant landings would mostly save helper CPU and memory bandwidth, not the frame. Also, the 174 MB buffer is one buffer covering most of a 185 MB GPU pool the title reserves at device start; split by region (`VICTORY_BACK_READS_SPLIT_MB=8`, on my local branch at the time, since added to this PR), its first 8 MB holds most of its refresh cost. **A byte-exact synthetic workload:** I have not found or built one. Two candidates in the tree: `host/membench.rs` (synthetic frames through the title's own calls, added in the v2026.11.29.02 hotfix) could get a mode that leaves out a class of landing and compares the title-memory bytes the next frame reads against a run that lands everything; and the captured-frame replay (diagnostics builds) could compare render targets with and without a transfer. Neither is done; I would be glad to compare notes if you start one.
Author
Owner

@⁠AS-AI-DEV on GitHub · 2026-11-29 20:20 UTC · original · edited 2026-11-29 21:20 UTC

A correction to my comment above: where it said "on our branch" (now "on my local branch at the time"), that meant my local working tree, not this pull request's branch, which was unclear. Two things it mentions are not in this PR:

  • the CPU time split by thread (time on the submitting thread apart from the helpers'), which the submitting-thread numbers in that comment came from;
  • VICTORY_BACK_READS_SPLIT_MB=<n> (copies bigger than n MB counted by region).

Everything else in it (the buckets, VICTORY_BACK_READS_WRITES, alt, the VICTORY_LAND_READS cross-check, the limits) matches what this PR contains. If those two would help your evaluation, I can add them here as a separate commit.

**@⁠AS-AI-DEV** on GitHub · 2026-11-29 20:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960#issuecomment-7262001318) · edited 2026-11-29 21:20 UTC A correction to my comment above: where it said "on our branch" (now "on my local branch at the time"), that meant my local working tree, not this pull request's branch, which was unclear. Two things it mentions are **not** in this PR: - the CPU time split by thread (time on the submitting thread apart from the helpers'), which the submitting-thread numbers in that comment came from; - `VICTORY_BACK_READS_SPLIT_MB=<n>` (copies bigger than `n` MB counted by region). Everything else in it (the buckets, `VICTORY_BACK_READS_WRITES`, `alt`, the `VICTORY_LAND_READS` cross-check, the limits) matches what this PR contains. If those two would help your evaluation, I can add them here as a separate commit.
Three additions to VICTORY_BACK_READS, each its own switch or part of
one, diagnostics builds only (docs/back-reads.md):

- With VICTORY_BACK_READS_TIME, the time spent preparing submissions
  (Host::submit: the frame line's "the submitting thread", on whichever
  thread runs it, victory-submit with async submission or the title's
  thread without) is counted apart from the helpers'.
- VICTORY_BACK_READS_WAITS: the submissions' waits for the card, per
  buffer. The waits crate::host already blames on a range of title
  memory go to the copy seen that holds it (looked up in this module's
  own record of copies, so nothing is made), the others to a row of
  their own; with the submitting thread's share.
- VICTORY_BACK_READS_SPLIT_MB=<n>: copies longer than n MB are counted by
  region of n MB (landings, merges, refreshes and the looks for title
  bytes under flights all say where they work).

Checked in walking runs of a diagnostics build (RTX 5060 Ti 16 GB,
Ryzen 7 5800X, Series X 2560x1440, DLSS performance, frame generation
2x): submitting thread 13.0 of the frame line's 50.5 ms with async
submission, 9.0 of 57.6 ms without (VICTORY_ASYNC_SUBMIT=0 with
VICTORY_THIN=0; that run ended in a device loss, as that configuration
has before here without this module); with waits forced
(VICTORY_CARD_STEPS=0) 22.8 ms counted against the frame line's 24.0 ms
"waiting for flights", 70 % of it on two buffers; no row left for a copy
over 8 MB with SPLIT_MB=8. Cost with every switch on: the submitting
thread +9 to 11 ms a frame against all off.

Co-Authored-By: AS-AI-DEV <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠AS-AI-DEV on GitHub · 2026-11-29 21:08 UTC · original

Reopened with a second commit (a1d988f) that adds what was missing above, now checked, plus the waits you asked about:

  • The submitting thread apart (VICTORY_BACK_READS_TIME): time spent preparing submissions (Host::submit, the frame line's "the submitting thread") is counted apart from the helpers', on whichever thread runs it. The earlier version told the thread by its name and would have shown 0 with async submission off; this one does not.
  • Waits for the card, per buffer (VICTORY_BACK_READS_WAITS): the waits crate::host already blames on a range of title memory go to the copy that holds it (no copy is made by looking), the rest to a row of their own, with the submitting thread's share. So a row now tells copying from waiting, the third part of your question.
  • Big copies by region (VICTORY_BACK_READS_SPLIT_MB=<n>).

How it was checked, walking runs of a diagnostics build (details in the PR text and docs/back-reads.md):

  • submitting thread 13.0 of the frame line's 50.5 ms with async submission, 9.0 of 57.6 ms with submissions on the title's thread;
  • with waits forced (VICTORY_CARD_STEPS=0), 22.8 ms of waits counted against the frame line's 24.0 ms "waiting for flights", 70 % of them on two small buffers; as the route plays normally here, the submissions hardly wait (2.3 ms a frame, presents and synchronous submissions only);
  • the module's own cost with every switch on: the submitting thread +9 to 11 ms a frame against all off, now stated in the doc.

The run with VICTORY_THIN=0 and VICTORY_ASYNC_SUBMIT=0 ended in a device loss; that configuration has lost the device here before without this module, but say if you see it with it.

**@⁠AS-AI-DEV** on GitHub · 2026-11-29 21:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960#issuecomment-7262636418) Reopened with a second commit (a1d988f) that adds what was missing above, now checked, plus the waits you asked about: - **The submitting thread apart** (`VICTORY_BACK_READS_TIME`): time spent preparing submissions (`Host::submit`, the frame line's "the submitting thread") is counted apart from the helpers', on whichever thread runs it. The earlier version told the thread by its name and would have shown 0 with async submission off; this one does not. - **Waits for the card, per buffer** (`VICTORY_BACK_READS_WAITS`): the waits `crate::host` already blames on a range of title memory go to the copy that holds it (no copy is made by looking), the rest to a row of their own, with the submitting thread's share. So a row now tells copying from waiting, the third part of your question. - **Big copies by region** (`VICTORY_BACK_READS_SPLIT_MB=<n>`). How it was checked, walking runs of a diagnostics build (details in the PR text and `docs/back-reads.md`): - submitting thread 13.0 of the frame line's 50.5 ms with async submission, 9.0 of 57.6 ms with submissions on the title's thread; - with waits forced (`VICTORY_CARD_STEPS=0`), 22.8 ms of waits counted against the frame line's 24.0 ms "waiting for flights", 70 % of them on two small buffers; as the route plays normally here, the submissions hardly wait (2.3 ms a frame, presents and synchronous submissions only); - the module's own cost with every switch on: the submitting thread +9 to 11 ms a frame against all off, now stated in the doc. The run with `VICTORY_THIN=0` and `VICTORY_ASYNC_SUBMIT=0` ended in a device loss; that configuration has lost the device here before without this module, but say if you see it with it.
github-bot changed title from Back reads: who touches what comes back from the card, per buffer (VICTORY_BACK_READS) to Back reads: per-buffer diagnostics of the memory bridge, copy-back, refreshes and waits (VICTORY_BACK_READS, diagnostics builds only) 2026-11-29 21:16:34 +00:00
Author
Owner

@⁠AS-AI-DEV on GitHub · 2026-11-29 21:15 UTC · original · edited 2026-11-29 21:20 UTC

@⁠akimfomin thank you for the review and the questions: they shaped the second commit. The waits per buffer (VICTORY_BACK_READS_WAITS) answer the third part of your question (copying vs. waiting for the card), and the submitting thread is now told apart correctly with async submission on or off.

The title and description now say the scope plainly: this is a diagnostic tool only. Release builds compile none of it, diagnostics builds run it only when its switches are set, and it never changes what the title reads or writes. The doc (docs/back-reads.md) has how to read it, what it costs when on, and how it was checked.

If you try it on your setup (GPU-limited, ray tracing on), the waits and the per-buffer table are where it should differ most from mine, and I would be glad to see what it shows.

**@⁠AS-AI-DEV** on GitHub · 2026-11-29 21:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2960#issuecomment-7262736165) · edited 2026-11-29 21:20 UTC @⁠akimfomin thank you for the review and the questions: they shaped the second commit. The waits per buffer (`VICTORY_BACK_READS_WAITS`) answer the third part of your question (copying vs. waiting for the card), and the submitting thread is now told apart correctly with async submission on or off. The title and description now say the scope plainly: this is a diagnostic tool only. Release builds compile none of it, diagnostics builds run it only when its switches are set, and it never changes what the title reads or writes. The doc (`docs/back-reads.md`) has how to read it, what it costs when on, and how it was checked. If you try it on your setup (GPU-limited, ray tracing on), the waits and the per-buffer table are where it should differ most from mine, and I would be glad to see what it shows.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/watch.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/2960/head:github-bot/gh-2960'
git switch 'github-bot/gh-2960'

Merge

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