Refresh cost on Series S is ~70% per-range write-watch "ask", not data copying #795
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by iamswiggity on 2026-11-28T06:07:38Z.
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:
memcpy, so ~94% of each update is overhead, not bytes).The slow asks are the ranges that fall through the flush's single batched
ask_aheadinto the per-rangeAsking::hold+kernel_writtenpath. 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
63b902f, fully warmed (88,775 pipelines, 0 failures).VICTORY_DLSS=1performance, frame gen 2x,VICTORY_PASSES_HOT=1, the default launcher env otherwise (VICTORY_LIGHT_REFRESHon,VICTORY_SOFT_VIEWS=copies, etc.).Measurements
Throwaway instrumentation (reverted after):
HostList::update(host.rs): accumulate per-frame summedus, count, and copied bytes for the update-copies.Shadow::update_free(shadow.rs): time thecrate::watch::writes(..)call vs the followingcopy_stale(..)separately, summed per frame.Representative per-frame lines (summed across the refresh threads):
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)
Host::refresh_front(host.rs) builds the batched ask from only the spans that passasked_ahead():Shadow::asked_ahead(shadow.rs) excludes guarded copies wheneverlight()is on:Each update then calls
crate::watch::writes(from, to, true)(viaShadow::update_free).writes(watch.rs) serves fast from the journal only if the range is fully inside anask_aheadregion, else from published bits, else it falls through to: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=0makes it worse, not better —lightis the optimization, not the cause.ask_aheadusesGetWriteWatch, 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
GetWriteWatchway.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:
ask_ahead, but for the guard mechanism) instead ofAsking::holdper range?Asking::holdlock 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.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-28T06:07:45Z.
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.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-28T11:39:10Z.
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 branchprobe-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 timeswrites(start, end, guarded)per range:ask_ahead;VICTORY_LIGHT_REFRESH;A diagnostics build also prints
lock_waitsper frame.Results at
63b902f, Ryzen 5 5600X, Windows build 26300. Medians of 24 frames; two default runs and one withVICTORY_LIGHT_REFRESH=0agree within about 10%.ask_aheadWith 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):
ASKINGWith 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 batchedask_ahead.Not covered:
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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-29T03:12:48Z.
/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_PROFILEover 60 s of an idle test run, 5 ms sampling. The frames were named from the build's PDB.What the profile says:
queue::behind::Lane::serve(waiting for work); ~4–6% waits insideshadow::wideon the refresh threads.Shadow::update, across all threads, 51% of the samples are inMutex::lock_contended, and 99.6% of those arewatch::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%.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.rsonly): a lock-free fast path inguard()for the common case where every block of the range is clean and nothing is beside or unsettled. It would use an atomic mirror ofGuards::clean, kept likePROTECTED/BESIDE/OPENINGand updated under the lock at the 9 placescleanchanges. The ordering to respect, given #817: the fast path readsOPENING/TOLD/BESIDEbefore 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 theprobe-795test (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.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-29T03:55:59Z.
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:protect_here)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:
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 ofVirtualProtectcalls, while keeping the protect-before-copy order the current path relies on. I'll check it against theprobe-795test and preloaded test runs as before. If it doesn't move the refresh wall I'll say so here and release the claim.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-29T05:10:11Z.
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, anask_aheadfor 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 runsguard()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, andwritesthen answers those ranges from the journal untilask_ahead_done. All 590victory-gpulib 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):Test runs on
568c5e5with full preload, frame generation off, 6 minutes idle each, the first run after the preload discarded, reference runs ofmaininterleaved: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.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T19:49:11Z.
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!