Refresh cost on Series S is ~70% per-range write-watch "ask", not data copying #795

Closed
opened 2026-11-28 06:10:56 +00:00 by github-bot · 6 comments
Owner

@⁠iamswiggity on GitHub · 2026-11-28 06:07 UTC · original

TL;DR

On a CPU-prepare-bound config (RTX 4060 Ti, Series S, DLSS Performance + frame gen, Windows 10), the per-frame host-copy refresh wall (~20 ms) is dominated by the write-watch ask, not by copying changed bytes. Profiling a busy ~6,000-draw scene:

  • ~1,250 update-copies/frame, ~50 µs each, but only ~38 KB each → ~760 MB/s effective (≈15–25× slower than raw memcpy, so ~94% of each update is overhead, not bytes).
  • Of that update time: write-watch ask ≈ 70%, copy-stale (guarded page reads) ≈ 30%, actual bytes negligible.

The slow asks are the ranges that fall through the flush's single batched ask_ahead into the per-range Asking::hold + kernel_written path. Filing this as a profiling data point, not a patch — the batching exclusion looks load-bearing for correctness, so I didn't want to guess at the invariants.

Setup

  • GPU: RTX 4060 Ti 16 GB (driver 32.0.16.1074). CPU: Intel i5-13400F (6P+4E, 16 logical). 32 GB RAM. Windows 10 19045, HAGS on.
  • Build at 63b902f, fully warmed (88,775 pipelines, 0 failures).
  • Profile: Series S, VICTORY_DLSS=1 performance, frame gen 2x, VICTORY_PASSES_HOT=1, the default launcher env otherwise (VICTORY_LIGHT_REFRESH on, VICTORY_SOFT_VIEWS=copies, etc.).
  • Steady, busy open-world scene (~6,000–7,000 draws/frame), ~13.4 fps / ~75 ms, firmly CPU-prepare-bound (card ~48–50% busy, ~45 ms idle-behind-us).

Measurements

Throwaway instrumentation (reverted after):

  • In HostList::update (host.rs): accumulate per-frame summed us, count, and copied bytes for the update-copies.
  • In Shadow::update_free (shadow.rs): time the crate::watch::writes(..) call vs the following copy_stale(..) separately, summed per frame.

Representative per-frame lines (summed across the refresh threads):

update-copies 62.3 ms summed, 1191 a frame, 52.3 us each; 43.9 MB/frame, 36.0 KB each, 706 MB/s effective;
  of it: write-watch ask 43.8 ms, copy-stale 17.6 ms   (vs the ~19 ms refresh wall)
update-copies 56.5 ms summed, 1217 a frame, 46.4 us each; 42.2 MB/frame, 33.8 KB each, 746 MB/s effective;
  of it: write-watch ask 39.4 ms, copy-stale 16.2 ms   (vs the ~17.6 ms refresh wall)

So of the refresh wall, roughly two-thirds is the write-watch ask, and the actual byte-copy is a rounding error (~2–3 µs of a 38 KB copy at real memory bandwidth).

Where the time goes (code trace)

  1. Host::refresh_front (host.rs) builds the batched ask from only the spans that pass asked_ahead():

    let ranges: Vec<(usize, usize)> =
        spans.iter().filter(|r| r.0.asked_ahead()).map(|r| (r.1, r.2)).collect();
    crate::watch::ask_ahead(&ranges);
    
  2. Shadow::asked_ahead (shadow.rs) excludes guarded copies whenever light() is on:

    watched != NOT_WATCHED && (watched != GUARDED || !crate::watch::light())
    
  3. Each update then calls crate::watch::writes(from, to, true) (via Shadow::update_free). writes (watch.rs) serves fast from the journal only if the range is fully inside an ask_ahead region, else from published bits, else it falls through to:

    let _range = Asking::hold(first, last);   // shared lock
    ... kernel_written(first, last) ...        // per-range GetWriteWatch, or the guard path
    

    That per-range path is the ~50 µs. The light() doc itself notes this class of work was "~94 ms a frame of all threads' time, most of it waiting" before the published-bits optimization — i.e., it's largely lock-wait on the guards'/asking lock, on up to ~7 threads.

Why I did not patch it

  • VICTORY_LIGHT_REFRESH=0 makes it worse, not better — light is the optimization, not the cause.
  • ask_ahead uses GetWriteWatch, which the kernel refuses for guarded/view memory ("asked together with others, theirs" too), so naively folding the excluded copies into the batch would break coverage → risk missed writes → corruption. The exclusion appears deliberate and correctness-critical.

So the remaining ~13 ms wall looks like a mix of lock contention on the guards'/asking lock and genuine per-range correctness checks that can't be batched the GetWriteWatch way.

Open question for maintainers

Is there a safe way to cut the per-range ask cost for the guarded/uncovered ranges on this kind of high-count workload (~1,250 updates/frame)? For example:

  • Can the guarded copies share a single coalesced guard/publish pass per flush (analogous to ask_ahead, but for the guard mechanism) instead of Asking::hold per range?
  • Is the Asking::hold lock the dominant cost here (the "most of it waiting"), and if so could the asking for a flush's guarded ranges be done under one lock acquisition?

Happy to re-run the instrumented build and capture any specific counters that would help (e.g., split the slow asks by which writes() branch they take: journal miss vs unpublished-guarded vs kernel fallback).

Context

Not urgent — Series S is already very playable here after your recent refresh work (27→18 ms) plus PASSES_HOT. Posting because the diagnosis seemed worth sharing while it was fresh, in case it points at a cheap win on CPU-bound rigs.

**@⁠iamswiggity** on GitHub · 2026-11-28 06:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795) ## TL;DR On a CPU-prepare-bound config (RTX 4060 Ti, Series S, DLSS Performance + frame gen, Windows 10), the per-frame host-copy **refresh wall (~20 ms)** is dominated by the write-watch **ask**, not by copying changed bytes. Profiling a busy ~6,000-draw scene: - ~1,250 update-copies/frame, **~50 µs each**, but only **~38 KB each** → **~760 MB/s effective** (≈15–25× slower than raw `memcpy`, so ~94% of each update is overhead, not bytes). - Of that update time: **write-watch ask ≈ 70%**, copy-stale (guarded page reads) ≈ 30%, actual bytes negligible. The slow asks are the ranges that fall through the flush's single batched `ask_ahead` into the per-range `Asking::hold` + `kernel_written` path. Filing this as a profiling data point, not a patch — the batching exclusion looks load-bearing for correctness, so I didn't want to guess at the invariants. ## Setup - GPU: RTX 4060 Ti 16 GB (driver 32.0.16.1074). CPU: Intel i5-13400F (6P+4E, 16 logical). 32 GB RAM. Windows 10 19045, HAGS on. - Build at `63b902f`, fully warmed (88,775 pipelines, 0 failures). - Profile: Series S, `VICTORY_DLSS=1` performance, frame gen 2x, `VICTORY_PASSES_HOT=1`, the default launcher env otherwise (`VICTORY_LIGHT_REFRESH` on, `VICTORY_SOFT_VIEWS=copies`, etc.). - Steady, busy open-world scene (~6,000–7,000 draws/frame), ~13.4 fps / ~75 ms, firmly CPU-prepare-bound (card ~48–50% busy, ~45 ms idle-behind-us). ## Measurements Throwaway instrumentation (reverted after): - In `HostList::update` (`host.rs`): accumulate per-frame summed `us`, count, and copied bytes for the update-copies. - In `Shadow::update_free` (`shadow.rs`): time the `crate::watch::writes(..)` call vs the following `copy_stale(..)` separately, summed per frame. Representative per-frame lines (summed across the refresh threads): ``` update-copies 62.3 ms summed, 1191 a frame, 52.3 us each; 43.9 MB/frame, 36.0 KB each, 706 MB/s effective; of it: write-watch ask 43.8 ms, copy-stale 17.6 ms (vs the ~19 ms refresh wall) update-copies 56.5 ms summed, 1217 a frame, 46.4 us each; 42.2 MB/frame, 33.8 KB each, 746 MB/s effective; of it: write-watch ask 39.4 ms, copy-stale 16.2 ms (vs the ~17.6 ms refresh wall) ``` So of the refresh wall, roughly **two-thirds is the write-watch ask**, and the actual byte-copy is a rounding error (~2–3 µs of a 38 KB copy at real memory bandwidth). ## Where the time goes (code trace) 1. `Host::refresh_front` (`host.rs`) builds the batched ask from only the spans that pass `asked_ahead()`: ```rust let ranges: Vec<(usize, usize)> = spans.iter().filter(|r| r.0.asked_ahead()).map(|r| (r.1, r.2)).collect(); crate::watch::ask_ahead(&ranges); ``` 2. `Shadow::asked_ahead` (`shadow.rs`) excludes guarded copies whenever `light()` is on: ```rust watched != NOT_WATCHED && (watched != GUARDED || !crate::watch::light()) ``` 3. Each update then calls `crate::watch::writes(from, to, true)` (via `Shadow::update_free`). `writes` (`watch.rs`) serves fast from the journal **only if the range is fully inside an `ask_ahead` region**, else from published bits, else it falls through to: ```rust let _range = Asking::hold(first, last); // shared lock ... kernel_written(first, last) ... // per-range GetWriteWatch, or the guard path ``` That per-range path is the ~50 µs. The `light()` doc itself notes this class of work was "~94 ms a frame of all threads' time, most of it waiting" before the published-bits optimization — i.e., it's largely lock-wait on the guards'/asking lock, on up to ~7 threads. ## Why I did not patch it - `VICTORY_LIGHT_REFRESH=0` makes it worse, not better — `light` is the optimization, not the cause. - `ask_ahead` uses `GetWriteWatch`, which the kernel refuses for guarded/view memory ("asked together with others, theirs" too), so naively folding the excluded copies into the batch would break coverage → risk missed writes → corruption. The exclusion appears deliberate and correctness-critical. So the remaining ~13 ms wall looks like a mix of **lock contention on the guards'/asking lock** and **genuine per-range correctness checks** that can't be batched the `GetWriteWatch` way. ## Open question for maintainers Is there a safe way to cut the per-range ask cost for the guarded/uncovered ranges on this kind of high-count workload (~1,250 updates/frame)? For example: - Can the guarded copies share a **single coalesced guard/publish pass per flush** (analogous to `ask_ahead`, but for the guard mechanism) instead of `Asking::hold` per range? - Is the `Asking::hold` lock the dominant cost here (the "most of it waiting"), and if so could the asking for a flush's guarded ranges be done under one lock acquisition? Happy to re-run the instrumented build and capture any specific counters that would help (e.g., split the slow asks by which `writes()` branch they take: journal miss vs unpublished-guarded vs kernel fallback). ## Context Not urgent — Series S is already very playable here after your recent refresh work (27→18 ms) plus `PASSES_HOT`. Posting because the diagnosis seemed worth sharing while it was fresh, in case it points at a cheap win on CPU-bound rigs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 06:10:57 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 06:07 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-28 06:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7235098401) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠jptorres96 on GitHub · 2026-11-28 11:39 UTC · original

A synthetic reproduction of this, without the game, that points at lock contention between the refresh threads rather than at the kernel asking itself.

The probe. It is an ignored test in watch.rs, on my fork's branch probe-795, +187 lines and nothing else touched. The setup follows your figures: 1,250 ranges of 38 KiB over a 176 MiB heap, with 7,000 pages of 4 KiB written between refreshes. It times writes(start, end, guarded) per range:

  • on write-watched memory, per range and through ask_ahead;
  • on a section mapped as title view memory and guarded, which is what falls out of the batch under VICTORY_LIGHT_REFRESH;
  • with 1, 4 and 8 threads sharing the ranges.

A diagnostics build also prints lock_waits per frame.

cargo test --release -p victory-gpu --lib [--features diagnostics] watch::ask_cost_probe -- --ignored --nocapture --test-threads=1

Results at 63b902f, Ryzen 5 5600X, Windows build 26300. Medians of 24 frames; two default runs and one with VICTORY_LIGHT_REFRESH=0 agree within about 10%.

Memory, threads Wall per frame Summed per frame Per range (summed)
write-watched, 1, per range 1.7 ms 1.7 ms 1.3 us
write-watched, 1, ask_ahead 0.7 ms 0.7 ms 0.6 us
guarded view, 1 7.9 ms 7.6 ms 6.0-7.0 us
guarded view, 4 15.5 ms 60 ms 48 us
guarded view, 8 14.9 ms 115 ms 92 us
write-watched, 8, per range 4.8 ms 32 ms 25 us

With several threads the guarded view lands right on your ~50 us per update and on the "summed far above wall" shape. The wall time also doubles from 1 to 4 threads instead of falling. Where the summed time goes (diagnostics build, per frame):

Guarded view Summed Waiting for the guards' lock Waiting for ASKING
4 threads 60 ms 28.6 ms (47%) 8.0 ms (13%)
8 threads 115 ms 73.9 ms (64%) 14.6 ms (13%)

With one thread both waits are 0. On write-watched memory the lock waits stay under 1 ms even at 8 threads. The per-range cost there still grows (1.3 to 25 us), which looks like contention inside the kernel's write-watch query on one reservation, which these counters cannot see.

So on this host, most of the "ask" in your trace is threads queueing for the guards' lock, then for ASKING. The kernel call and the bytes are not the main cost. That fits your observation that the slow ranges are the ones outside the single batched ask_ahead.

Not covered:

  • the real heap's mix of watched and guarded copies;
  • the title writing during the refresh: the probe writes before each frame, so its faults are not in the timings;
  • the batch exclusion itself. I agree it looks load-bearing, and the probe doesn't propose changing it.

What it gives is a number to check a change against without the game, for instance fewer guard-lock round trips per range or a batched guard query.

**@⁠jptorres96** on GitHub · 2026-11-28 11:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7238692668) A synthetic reproduction of this, without the game, that points at lock contention between the refresh threads rather than at the kernel asking itself. **The probe.** It is an ignored test in `watch.rs`, on my fork's branch [`probe-795`](https://github.com/jptorres96/VIctory-NVIDIA/commit/3f9891d4772fab77d1c51f328c10e51e2c285f77), +187 lines and nothing else touched. The setup follows your figures: 1,250 ranges of 38 KiB over a 176 MiB heap, with 7,000 pages of 4 KiB written between refreshes. It times `writes(start, end, guarded)` per range: - on write-watched memory, per range and through `ask_ahead`; - on a section mapped as title view memory and guarded, which is what falls out of the batch under `VICTORY_LIGHT_REFRESH`; - with 1, 4 and 8 threads sharing the ranges. A diagnostics build also prints `lock_waits` per frame. ``` cargo test --release -p victory-gpu --lib [--features diagnostics] watch::ask_cost_probe -- --ignored --nocapture --test-threads=1 ``` **Results** at `63b902f`, Ryzen 5 5600X, Windows build 26300. Medians of 24 frames; two default runs and one with `VICTORY_LIGHT_REFRESH=0` agree within about 10%. | Memory, threads | Wall per frame | Summed per frame | Per range (summed) | | --- | ---: | ---: | ---: | | write-watched, 1, per range | 1.7 ms | 1.7 ms | 1.3 us | | write-watched, 1, `ask_ahead` | 0.7 ms | 0.7 ms | 0.6 us | | guarded view, 1 | 7.9 ms | 7.6 ms | 6.0-7.0 us | | guarded view, 4 | 15.5 ms | 60 ms | 48 us | | guarded view, 8 | 14.9 ms | 115 ms | 92 us | | write-watched, 8, per range | 4.8 ms | 32 ms | 25 us | With several threads the guarded view lands right on your ~50 us per update and on the "summed far above wall" shape. The wall time also *doubles* from 1 to 4 threads instead of falling. Where the summed time goes (diagnostics build, per frame): | Guarded view | Summed | Waiting for the guards' lock | Waiting for `ASKING` | | --- | ---: | ---: | ---: | | 4 threads | 60 ms | 28.6 ms (47%) | 8.0 ms (13%) | | 8 threads | 115 ms | 73.9 ms (64%) | 14.6 ms (13%) | With one thread both waits are 0. On write-watched memory the lock waits stay under 1 ms even at 8 threads. The per-range cost there still grows (1.3 to 25 us), which looks like contention inside the kernel's write-watch query on one reservation, which these counters cannot see. So on this host, most of the "ask" in your trace is threads queueing for the guards' lock, then for `ASKING`. The kernel call and the bytes are not the main cost. That fits your observation that the slow ranges are the ones outside the single batched `ask_ahead`. **Not covered:** - the real heap's mix of watched and guarded copies; - the title writing during the refresh: the probe writes before each frame, so its faults are not in the timings; - the batch exclusion itself. I agree it looks load-bearing, and the probe doesn't propose changing it. What it gives is a number to check a change against without the game, for instance fewer guard-lock round trips per range or a batched guard query.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-29 03:12 UTC · original

/claim

Independent confirmation from a sampling profile on different hardware, plus what I plan to try.

Setup: RTX 5070 12 GB (driver 621.40), Ryzen 7 5800X (8C/16T), 64 GB RAM, Windows 11 build 26300. Series X profile, 1440p, DLSS Performance, frame generation off. Diagnostics build of main (--profile diag, same optimisation as release), VICTORY_PROFILE over 60 s of an idle test run, 5 ms sampling. The frames were named from the build's PDB.

What the profile says:

  • The submitting thread spends ~41% of its samples waiting. Most of that is idle in queue::behind::Lane::serve (waiting for work); ~4–6% waits inside shadow::wide on the refresh threads.
  • Under Shadow::update, across all threads, 51% of the samples are in Mutex::lock_contended, and 99.6% of those are watch::guards ← watch::writes. The kernel calls of the guard path (watch::protect, watch::cover) are ~11%, and the copy itself (memcpy, victory_safe_copy_at) is ~14%.
  • From the log of two preloaded runs on 568c5e5, the refresh wall is stable: 21.6 and 22.4 ms per frame, ~8,000 refreshes per frame with ~6,870 known to copy nothing. Base FPS is much noisier (11.8 vs 14.6 FPS between the same two runs, because the scene differs), so I'm using the refresh ms as the metric.
  • VICTORY_WIDE_CHUNK=16 (fewer wake-ups) left the refresh wall unchanged (21.0 vs 21.3 ms), which fits the cost being the guards' lock rather than the fan-out.

This matches @⁠jptorres96's probe: the cost is threads queueing for GUARDS, not the kernel or the bytes.

What I'll try (crates/victory-gpu/src/watch.rs only): a lock-free fast path in guard() for the common case where every block of the range is clean and nothing is beside or unsettled. It would use an atomic mirror of Guards::clean, kept like PROTECTED/BESIDE/OPENING and updated under the lock at the 9 places clean changes. The ordering to respect, given #817: the fast path reads OPENING/TOLD/BESIDE before the clean bits, and every place that clears a block's clean bit does so before its opening/told bits are cleared. I'll measure it against the probe-795 test (1/4/8 threads) and then in preloaded test runs, using the refresh ms and the prep ms per 1,000 draws, before opening a PR.

**@⁠DoubleD17** on GitHub · 2026-11-29 03:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7249909917) /claim Independent confirmation from a sampling profile on different hardware, plus what I plan to try. **Setup:** RTX 5070 12 GB (driver 621.40), Ryzen 7 5800X (8C/16T), 64 GB RAM, Windows 11 build 26300. Series X profile, 1440p, DLSS Performance, frame generation off. Diagnostics build of `main` (`--profile diag`, same optimisation as release), `VICTORY_PROFILE` over 60 s of an idle test run, 5 ms sampling. The frames were named from the build's PDB. **What the profile says:** - The submitting thread spends ~41% of its samples waiting. Most of that is idle in `queue::behind::Lane::serve` (waiting for work); ~4–6% waits inside `shadow::wide` on the refresh threads. - Under `Shadow::update`, across all threads, **51% of the samples are in `Mutex::lock_contended`**, and **99.6% of those are `watch::guards` ← `watch::writes`**. The kernel calls of the guard path (`watch::protect`, `watch::cover`) are ~11%, and the copy itself (`memcpy`, `victory_safe_copy_at`) is ~14%. - From the log of two preloaded runs on `568c5e5`, the refresh wall is stable: **21.6 and 22.4 ms per frame**, ~8,000 refreshes per frame with ~6,870 known to copy nothing. Base FPS is much noisier (11.8 vs 14.6 FPS between the same two runs, because the scene differs), so I'm using the refresh ms as the metric. - `VICTORY_WIDE_CHUNK=16` (fewer wake-ups) left the refresh wall unchanged (21.0 vs 21.3 ms), which fits the cost being the guards' lock rather than the fan-out. This matches @⁠jptorres96's probe: the cost is threads queueing for `GUARDS`, not the kernel or the bytes. **What I'll try** (`crates/victory-gpu/src/watch.rs` only): a lock-free fast path in `guard()` for the common case where every block of the range is clean and nothing is beside or unsettled. It would use an atomic mirror of `Guards::clean`, kept like `PROTECTED`/`BESIDE`/`OPENING` and updated under the lock at the 9 places `clean` changes. The ordering to respect, given #817: the fast path reads `OPENING`/`TOLD`/`BESIDE` before the clean bits, and every place that clears a block's clean bit does so before its opening/told bits are cleared. I'll measure it against the `probe-795` test (1/4/8 threads) and then in preloaded test runs, using the refresh ms and the prep ms per 1,000 draws, before opening a PR.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-29 03:55 UTC · original

Update on my claim, with the guards' own counters. Diagnostics build of 568c5e5, same setup as above (RTX 5070, Ryzen 7 5800X, Series X profile, 1440p, DLSS Performance, frame generation off). Idle test run, full shader and pipeline preload first. Averages per frame over the last ~70% of a 6-minute run, all threads:

per frame
view ranges answered by their bits 484
view ranges answered by the guards whole 0
view ranges answered block by block 217
blocks made read-only 681
time changing protections (protect_here) 37.2 ms
waits for the guards' lock 239, 55.2 ms
write faults opened without the lock 686, 32.4 ms (on the title's threads)
write faults opened under the lock 4 (0.66 ms held)

So the guarded blocks go round a loop every frame: about 680 are made read-only during refreshes and about 690 are opened again by write faults. That costs ~125 ms summed per frame across threads, and ~32 ms of it lands on the title's own threads.

What this rules out:

  • The lock-free "all clean" fast path I proposed would never fire. Zero ranges are answered by the guards whole, because ranges known clean are already answered by their bits before they reach guard(). I'm dropping that idea.
  • VICTORY_GUARD_HOT=50 (keep re-written blocks open) is worse here. In preloaded runs alternating hot / reference / hot (6 min each), the refresh wall was 23.7 and 23.9 ms with it against 21.6 and 21.2 ms without, prep went from ~9.9 to ~10.7 ms per 1,000 draws, and base FPS from 14.6–15.0 to 13.4–13.9. Copying the resting blocks at every refresh costs more than the protection round trip saves.
  • VICTORY_WIDE_CHUNK=16: no change in the refresh wall (reported above).

What I'll try next, still only in watch.rs/host.rs: one guard pass per refresh flush instead of one per range per thread. Take the union of the flush's view ranges on the submitting thread, then protect merged runs once under a single lock hold, before the copies are spread to the refresh threads. That cuts the lock round trips (the 239 waits) and the number of VirtualProtect calls, while keeping the protect-before-copy order the current path relies on. I'll check it against the probe-795 test and preloaded test runs as before. If it doesn't move the refresh wall I'll say so here and release the claim.

**@⁠DoubleD17** on GitHub · 2026-11-29 03:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7250346959) Update on my claim, with the guards' own counters. Diagnostics build of `568c5e5`, same setup as above (RTX 5070, Ryzen 7 5800X, Series X profile, 1440p, DLSS Performance, frame generation off). Idle test run, full shader and pipeline preload first. Averages per frame over the last ~70% of a 6-minute run, all threads: | | per frame | |---|---:| | view ranges answered by their bits | 484 | | view ranges answered by the guards *whole* | **0** | | view ranges answered block by block | 217 | | blocks made read-only | **681** | | time changing protections (`protect_here`) | 37.2 ms | | waits for the guards' lock | 239, **55.2 ms** | | write faults opened without the lock | **686, 32.4 ms** (on the title's threads) | | write faults opened under the lock | 4 (0.66 ms held) | So the guarded blocks go round a loop every frame: about 680 are made read-only during refreshes and about 690 are opened again by write faults. That costs ~125 ms summed per frame across threads, and ~32 ms of it lands on the title's own threads. What this rules out: - **The lock-free "all clean" fast path I proposed would never fire.** Zero ranges are answered by the guards whole, because ranges known clean are already answered by their bits before they reach `guard()`. I'm dropping that idea. - **`VICTORY_GUARD_HOT=50`** (keep re-written blocks open) is worse here. In preloaded runs alternating hot / reference / hot (6 min each), the refresh wall was 23.7 and 23.9 ms with it against 21.6 and 21.2 ms without, prep went from ~9.9 to ~10.7 ms per 1,000 draws, and base FPS from 14.6–15.0 to 13.4–13.9. Copying the resting blocks at every refresh costs more than the protection round trip saves. - `VICTORY_WIDE_CHUNK=16`: no change in the refresh wall (reported above). What I'll try next, still only in `watch.rs`/`host.rs`: **one guard pass per refresh flush instead of one per range per thread.** Take the union of the flush's view ranges on the submitting thread, then protect merged runs once under a single lock hold, before the copies are spread to the refresh threads. That cuts the lock round trips (the 239 waits) and the number of `VirtualProtect` calls, while keeping the protect-before-copy order the current path relies on. I'll check it against the `probe-795` test and preloaded test runs as before. If it doesn't move the refresh wall I'll say so here and release the claim.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-29 05:10 UTC · original

Result of the batched guard pass: it wins in the probe and loses in test runs, so I'm not opening a PR, and I'm releasing the claim.

The change (local branch only): watch::guard_ahead, an ask_ahead for view memory. On the submitting thread, before a flush's copies are spread to the refresh threads, it takes the flush's guarded ranges and runs guard() once per run of ranges that overlap or touch (never across a gap). It notes what it finds written in the journal under one asking, and writes then answers those ranges from the journal until ask_ahead_done. All 590 victory-gpu lib tests pass (--test-threads=1), plus a new test with writes before the asking, after it, and in a block between two ranges.

probe-795, extended with a "G" case that does the batched pass first, on this machine (Ryzen 7 5800X):

guarded view F: per range G: guarded ahead
1 thread, wall 5.90 ms 4.83 ms
4 threads, wall / summed 13.99 / 54.9 ms 7.72 / 0.51 ms
8 threads, wall / summed 16.24 / 126.7 ms 8.32 / 0.55 ms

Test runs on 568c5e5 with full preload, frame generation off, 6 minutes idle each, the first run after the preload discarded, reference runs of main interleaved:

ref ref ref fix fix
refresh wall, ms/frame (median) 21.6 21.2 21.4 24.1 39.2
base FPS, mean 14.6 15.0 14.5 13.1 12.6
card idle, ms/frame 33.0 32.7 33.3 39.8 46.0

No access violations, no device removal, and DLSS stayed up the whole time.

Why I think it loses: the batched pass moves all the guarding onto the submitting thread, which is the one that paces the frame (#699). Before, the refresh threads did it in parallel, contended but overlapped. The probe has one flush per frame. A real frame has ~70 flushes, each with its own pass, and the work per pass doesn't shrink: the ~680 blocks made read-only and ~690 write faults per frame are the same. Batching removes the lock queueing, but it puts the protection changes serially on the critical path.

So what remains to cut is the protect → fault → reopen round trip itself, not the lock. VICTORY_GUARD_HOT=50 (no round trip for re-written blocks) lost too, because those blocks are copied again at every one of the ~70 flushes. A direction I haven't tried: keep re-written blocks open, but copy each one at most once per frame (or per submission) rather than once per flush. Releasing the claim. The numbers and the extended probe are here for whoever picks it up.

**@⁠DoubleD17** on GitHub · 2026-11-29 05:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7251091790) Result of the batched guard pass: **it wins in the probe and loses in test runs**, so I'm not opening a PR, and I'm releasing the claim. **The change** (local branch only): `watch::guard_ahead`, an `ask_ahead` for view memory. On the submitting thread, before a flush's copies are spread to the refresh threads, it takes the flush's guarded ranges and runs `guard()` once per run of ranges that overlap or touch (never across a gap). It notes what it finds written in the journal under one asking, and `writes` then answers those ranges from the journal until `ask_ahead_done`. All 590 `victory-gpu` lib tests pass (`--test-threads=1`), plus a new test with writes before the asking, after it, and in a block between two ranges. **`probe-795`**, extended with a "G" case that does the batched pass first, on this machine (Ryzen 7 5800X): | guarded view | F: per range | G: guarded ahead | |---|---:|---:| | 1 thread, wall | 5.90 ms | 4.83 ms | | 4 threads, wall / summed | 13.99 / 54.9 ms | 7.72 / 0.51 ms | | 8 threads, wall / summed | 16.24 / 126.7 ms | 8.32 / 0.55 ms | **Test runs** on `568c5e5` with full preload, frame generation off, 6 minutes idle each, the first run after the preload discarded, reference runs of `main` interleaved: | | ref | ref | ref | fix | fix | |---|---:|---:|---:|---:|---:| | refresh wall, ms/frame (median) | 21.6 | 21.2 | 21.4 | **24.1** | **39.2** | | base FPS, mean | 14.6 | 15.0 | 14.5 | 13.1 | 12.6 | | card idle, ms/frame | 33.0 | 32.7 | 33.3 | 39.8 | 46.0 | No access violations, no device removal, and DLSS stayed up the whole time. **Why I think it loses:** the batched pass moves all the guarding onto the submitting thread, which is the one that paces the frame (#699). Before, the refresh threads did it in parallel, contended but overlapped. The probe has one flush per frame. A real frame has ~70 flushes, each with its own pass, and the work per pass doesn't shrink: the ~680 blocks made read-only and ~690 write faults per frame are the same. Batching removes the lock queueing, but it puts the protection changes serially on the critical path. So what remains to cut is the protect → fault → reopen round trip itself, not the lock. `VICTORY_GUARD_HOT=50` (no round trip for re-written blocks) lost too, because those blocks are copied again at every one of the ~70 flushes. A direction I haven't tried: keep re-written blocks open, but copy each one at most once per frame (or per submission) rather than once per flush. Releasing the claim. The numbers and the extended probe are here for whoever picks it up.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 19:49 UTC · original

Closing this one because it was reported on a build from before v2026.11.28.03 (more than 4 releases ago) and has had no activity since v2026.11.29.01. A lot has changed since then.

If it still happens on the latest release, please open a new issue with the play log and crashes.log from that run. Thanks for reporting!

**@⁠trustno1-coder** on GitHub · 2026-11-29 19:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/795#issuecomment-7261580796) Closing this one because it was reported on a build from before v2026.11.28.03 (more than 4 releases ago) and has had no activity since v2026.11.29.01. A lot has changed since then. If it still happens on the [latest release](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/latest), please open a new issue with the play log and crashes.log from that run. Thanks for reporting!
This discussion has been locked. Commenting is limited to contributors.
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#795
No description provided.