perf(gpu): reservation-aware write-watch batching, lock-free view/non-watched bitsets & Wine/Proton compatibility #207
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!207
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-207"
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?
@jocost4 on GitHub · 2026-11-27 19:43 UTC · original
jocost4:perf/watch-batching-and-wine-compat→main· +289 −46 · 5 files · 1 commits · openSummary
A set of low-risk, zero-regression performance and Wine/Proton compatibility improvements for
victory-gpu(default Windows behavior is preserved everywhere; all tuning knobs are opt-in via environment variables):1. Write-watch & guard optimizations (
crates/victory-gpu/src/watch.rs)ask_once+RESERVATIONScache: CachesVirtualAllocreservation spans (AllocationBase..end) soask_onceonly mergesGetWriteWatchranges within the same reservation — eliminating cross-reservationGetWriteWatchfailures and binary splits.Asking::hold_many: ReplacesAsking::hold_all()(0..usize::MAX) inask_oncewith atomic range holding for only the queried spans, allowing unrelated memory (e.g. shader-visible descriptor heaps insync_heapsand texture refreshes) to proceed concurrently.KNOWN_VIEWandSINGLE_NOT_WATCHEDbitsets:KNOWN_VIEWmarks blocks confirmed asMEM_MAPPEDview memory insideprotect_here(cleared ong.foreignand alltitle_memory_*invalidations).SINGLE_NOT_WATCHEDonly marks isolated single 64 KiB blocks (last - first == 1) whereGetWriteWatchfailed (never poisoning adjacent write-watched blocks).writes(..., false)before acquiringAsking::hold, avoiding redundant lock/condvar churn on known view memory (e.g.texture.rs).placeholder()fallback: Falls back toVirtualQuery(MEM_RESERVE && PAGE_NOACCESS) whenNtQueryVirtualMemory(class = 7)returnsSTATUS_INVALID_INFO_CLASSunder Wine/Proton (zero impact on native Windows, whereNtQueryVirtualMemorysucceeds). Reduces hole queries from ~15,000/frame to ~8–48/frame under Proton.to <= endprogress guards inallocation_end/reservation_ofand callsforget_reservationsoutside theGUARDSlock intitle_memory_unmapping/title_memory_freed.VICTORY_AHEAD_GAP_KB(default8192= 8 MiB, unchanged on Windows; setting e.g.256on Wine/Proton avoids scanning megabytes of unused pages under Wine'svirtual.clock).2. Additional low-overhead improvements
crates/victory-gpu/src/shadow.rs: Short-circuitswide_eachforn == 0andn == 1to avoid worker pool wakeups for trivial work.crates/victory-gpu/src/host.rs: SetshbrBackgroundtoBLACK_BRUSHinmake_windowto avoid a white/blue uninitialized window flash before the firstPresent().crates/victory-gpu/src/draw.rs: Makes buffer-heap rescan cadence configurable viaVICTORY_HEAP_RESCAN_FRAMES(default16, unchanged).crates/victory-gpu/src/texture.rs: Makes guarded texture blind-write hash cadence configurable viaVICTORY_TEXTURE_HASH_EVERY(default8, unchanged).Verification
x86_64-pc-windows-msvc(cargo xwin check --release -p victory --target x86_64-pc-windows-msvc, 0 new warnings).preparingtime from ~200+ ms down to ~50–55 ms/frame (copies~11–12 ms,textures~5–6 ms,ask_once~14–19 ms,heaps_wait~4–5 ms) with GPU utilization reaching 88–92%.@domx4q on GitHub · 2026-11-27 21:42 UTC · original
Independent confirmation of the Wine/Proton placeholder fallback in this PR, from a separate setup.
Setup: i9-14900KF, RTX 4090 (driver 620.73), Proton with vkd3d-proton, Linux 7.3, headless gamescope, prologue (prison cell), 1080p -> 1440p DLSS Quality. Same save, same scene, 60 s average per run.
I hit the same problem independently. On Wine,
NtQueryVirtualMemory(..., MemoryRegionInformationEx)returnsSTATUS_INVALID_INFO_CLASS, sowatch::placeholder()never learns that a hole is a placeholder. In my profile that meant ~16,000 VirtualQuery calls per frame under the guards' lock (ntdll.so:get_basic_memory_infowas the hottest symbol in thevictory-widethreads).My local fix was slightly different: a small
BTreeMapof the runtime's ownMEM_RESERVE_PLACEHOLDERreservations, filled fromxmem.rsand cleared intitle_memory_freed, used only after the host has once answeredSTATUS_INVALID_INFO_CLASS. Result on top ofVICTORY_PIPELINE_WAIT_MS=0: 18.6 -> 20.5 fps, "preparing" ~45 -> ~31 ms/frame. Your version covers the same case, so I'm not opening a separate PR. I'm happy to post my diff if a second variant is useful for comparison.Not tested on Windows by me (the new path only runs when the host rejects the info class, which Windows doesn't).
@jocost4 on GitHub · 2026-11-28 00:34 UTC · original
Thanks for the independent numbers, @domx4q — good to see the same ~16k queries/frame bottleneck confirmed on a 4090 setup too.
Your
BTreeMapapproach fromxmem.rsis actually cleaner for distinguishing realMEM_RESERVE_PLACEHOLDERspans from plainPAGE_NOACCESSreservations (and avoids theVirtualQuerycall altogether onceSTATUS_INVALID_INFO_CLASSis seen). Feel free to drop your diff here if you'd like — happy to compare or fold it in if maintainers prefer that variant.@POMXARK on GitHub · 2026-11-28 02:11 UTC · original
Testing feedback on Windows 11, AMD Ryzen 7 5700X (8C/16T), NVIDIA RTX 5080 16 GB, 32 GB RAM, Series X 1440p + DLSS Quality + DLSS MFG 4× (
4 MiBwindows).Full disclosure: tested on a fork branch based on
v2026.11.27.7(with local GPU patches +x86-64-v3/ThinLTO), porting only thewatch.rschanges (reservation_of,Asking::hold_many,KNOWN_VIEW,SINGLE_NOT_WATCHED, fusedask_oncewith sortedahead_normalizepreserved for PR #469's binary search) pluswide_each(0/1)inshadow.rs(omitting the Wine/Proton knobs).Result
cargo test -p victory-gpu --lib watchtests passed cleanly (0.78s) after updating theask_resttest call toask_once.t=169s, Prison -> Office):14.0 FPS(~71 ms/frame) in Prison/Office, 12-minute run completes with0errors /0DeviceRemoved.watch.rs: 3D immediately degraded to0.2–6.3 FPS(158.9 -> 275.8 -> 1297.7 -> 4072.7 ms/frame,copiesup to67.2 msvs28.1 msbaseline,list::thin: 19464 in 12280.4 ms), followed byDXGI_ERROR_DEVICE_REMOVED(0x887A0005) att=169s:WARN victory_gpu::streamline: DLSS Frame Generation: a present failed hresult=0x887a0005ERROR victory_gpu::host: a submission sent ahead could not be followed by a signal ... (0x887A0005); device removedwatch.rsandshadow.rsimmediately restored clean 12-minute stability.Possible root causes to double-check on native Windows:
SINGLE_NOT_WATCHED/KNOWN_VIEWbitsets skippingGetWriteWatchif any 64 KiB block transitions state (e.g., uncommitted -> committed) without hitting one of thetitle_memory_*clear hooks, orAsking::hold_many(spans)allowing concurrentsync_heaps/ texture refreshes duringask_once, leading to stale buffer/descriptor reads on the GPU and a TDR (0x887A0005).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.