perf(gpu): compare big card copies only where written lately #501
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!501
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-501"
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?
@ballsimulation on GitHub · 2026-11-27 23:38 UTC · original
ballsimulation:perf/lazy-card-compare→main· +451 −23 · 3 files · 1 commits · openSummary
Two opt-in switches, both off by default, that cut the cost of the title's 174 MB constants heap:
VICTORY_LAZY_COMPARE_MB=64: the GPU compares only the parts of the heap that shaders recently wrote, plus a rotating sweep of the rest.VICTORY_LAZY_NARROW=1: constant reads from the heap stop counting as blocked by in-flight work, except on those recently written parts.On main, with both on: frames 4–6% faster, and the submitting thread's planning of steps on the card drops from 7.4 to 1.7 ms.
Why
The skinning passes declare the whole heap written in every submission, through one view of it. That has two costs:
card_steps). That costs 7–12 ms per frame on the submitting thread.What changes
VICTORY_LAZY_COMPARE_MB=<MiB>For a card copy at least this large, a submission compares only:
VICTORY_LAZY_HOTcompares (default 64);VICTORY_LAZY_SWEEPskipped pieces in turn (default 128).These compares store their hashes (mode 2). Anything found is fetched and merged exactly as before. A log line every 5 s shows the counts.
VICTORY_LAZY_NARROW=1(needs the switch above)Where submission steps wait for flights, or are done on the card in flight order (
late_blocked,card_steps,cut_for, the relay's wait), such a copy counts as written only on its recently written pieces. Refreshes still see every declared write.Trade-off
A heap piece that shaders write for the first time reaches title memory only when the sweep finds it, about 2 frames later. Until then, CPU steps read the title's own bytes there.
Results
RTX 4070, Ryzen 9 7950X. Series X profile at native 2560x1440, no DLSS, frame rate uncapped. One build of main
64d4931bwith this change, the same save and walk, run with the switches off and then on. Median frame time by draws per frame:Caveats
🤖 Generated with Claude Code
@POMXARK on GitHub · 2026-11-28 00:29 UTC · original
Testing feedback on RTX 5080 16 GB / AMD Ryzen 7 5700X (8C/16T) / 32 GB RAM, Windows 11, Series X 1440p + DLSS Quality + DLSS MFG 4x, based on
v2026.11.27.8(64d4931) withVICTORY_LAZY_COMPARE_MB=64andVICTORY_LAZY_NARROW=1:Hit a guest access violation at 3m44s (
Frame: 5348, prison gameplay) that did not occur on prior 12-minute runs withoutVICTORY_LAZY_*:unhandled exception 0xc0000005 at victory-image-b99f876b74d4a77f.dll+0x4e9b54a (read 0xffffffffffffffff: outside the address space)rcx 0x31ff84a045495676(non-canonical pointer),rax 0x0,rbx 0xd0418f3a8,rdi 0xd04189938,r8/r9 0xffffffff00000000+0x4e9b54a -> +0x4e9b4bf -> +0x4a4a -> +0x4d9f49c -> +0x2484ac4 -> +0x321c5 -> +0x3346d -> +0x555e921Full disclosure: this was tested on a custom branch with additional local GPU patches on top of
v2026.11.27.8(also with PR #498 and PR #499 enabled), so it is not yet a cleanmain-only repro. Sharing the crash trace here since it looks consistent with the documented risk inlazy.rsaround delayed/missed first-time shader write-backs into the 174 MB constants heap whenVICTORY_LAZY_NARROW=1is enabled.@Machad3x on GitHub · 2026-11-28 01:19 UTC · original
Tested merged on top of main (RTX 3080 Ti, Ryzen 7 5700X, 1440p DLSS Quality, title ray tracing on). With the switch at its default (off) the run was fine. Review found one bug in
host/lazy.rshot_within:It joins a hot piece onto
out.last_mut()wheneverlast.1 >= a, without checkinglast.0 <= a.outalready holds unrelated ranges at that point (Line::joinedseeds it withtextures.to_vec(), and the line rebuild adds other ranges first). A hot piece that lies below an unrelated range above it gets swallowed:last.1 = max(last.1, b)changes nothing, so[a, b)is lost. WithVICTORY_LAZY_NARROW=1, the waits (late_blocked,card_steps,cut_for,relay_wait) then do not wait for the flight that writes those bytes, and a later list reads stale data.Fix we use (callers already sort and join afterwards):
plus a test
hot_piece_below_an_unrelated_range_stays.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.