perf(gpu): lock-free no-op refreshes, chunked refresh claiming, and AVX2 copy diff #614
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/614"
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 wike1701 on 2026-11-28T01:53:38Z.
Summary
Pure CPU hot-path optimization targeting the preparing /
efreshes bottleneck (~48–68 ms/frame on open-world captures, where ~8,100 of ~8,600 refreshes/frame copy nothing). Leaves GPU output and ordering byte-for-byte identical.
1. Lock-free no-op refresh fast path (watch.rs, shadow.rs, host.rs)
othing_new_with, stale_under_writes, window_use) read page generations lock-free; writers (copy_stale, merge_under_writes, landed) serialize on copy_lock and publish
ow with Ordering::Release only after ake_all finishes writing bytes.
anged_any: eliminates Shadow.pending, Shadow.copied, and Shadow.ranged mutex locks on the common whole-page read-only no-op path, while holding one JournalRead guard per 32-item chunk in wide_chunks (always dropped before Self::update).
2. Offload refresh coalescing to VICTORY_THIN workers (host.rs)
3. Faster real copy hot path (shadow.rs)
Verification
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CuteBooty on 2026-11-28T04:42:09Z.
A first in-game data point from an NVIDIA 8 GB card. The two runs are short, so please read it as "it runs", not as a verdict.
victory.exe run, diag profile with diagnostics;VICTORY_THIN=1,VICTORY_RELAY=2,VICTORY_JOIN_PARTS=8,VICTORY_SOFT_VIEWS=copies.8fc22547c+ two unrelated local commits. Build B: the same + this PR's commitcaf1a4ce5cherry-picked. One session each (3.2 and 4.7 minutes), same save, not the same spot.Measurements and this report were prepared with an AI assistant (Claude Code); the runs were played on my machine.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T04:44:08Z.
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 MiBdefault windows,VICTORY_GPU_BCPACK=0,VICTORY_WAIT_RESIDENT=0,VICTORY_TEXTURE_ROOM_PERCENT=70,VICTORY_LAND_SKIP=1).Full disclosure: tested on a fork branch based on
v2026.11.27.7(with local GPU patches,x86-64-v3/ThinLTO, PR #469ahead_holds, PR #516, PR #340, and PR #81; resolved the singlenothing_newconflict inwatch.rskeepingahead_holdsbinary search insidenothing_new_atomic).Result
VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib -- shadow:: watch:: host:: list::— 205 passed, 0 failed, 17 ignored (2.70 s).0..858 s,n=1103D samples):0frames>=250 ms,0GPU stalls>=50 ms,max = 203.2 ms,tex refreshes p50 = 11.5 ms(down from16.0 ms),write watch p50 = 1.7 ms(down from2.6 ms).7k–10k draws,p50=8,265):11.30 FPSp50 /12.60mean (88.6 ms,Prep 70.5 ms,copies 41.8 ms).>=10k draws,p50=10,444):13.50 FPSp50 (74.0 ms,Prep 57.1 ms,copies 31.1 ms).14m18s(frame=41453, heavy streaming transition6.4k -> 9.7krefreshes/frame):DXGI_ERROR_DEVICE_HUNG(0x887A0006), which has not occurred on prior 12-minute runs of the same branch without PR #614:ERROR victory_gpu::host: host GPU device removed after 16 submissions sent ahead (VICTORY_RELAY=1) of 213 lists; ... device removed: ... (0x887A0006)mem_auditbefore the hang was healthy (dxgi_ded_mb=11346,dxgi_shared_mb=8688,phys_free_mb=2165,MinFreeC=7.75 GB,0guest exceptions).Deferred::refreshed_spanin-placeStep::Refreshmutation across aliased shadows / interleaved copy steps andnothing_new_atomicsynchronization under heavyVICTORY_RELAY=1workloads.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Machad3x on 2026-11-28T07:09:10Z.
Test results for this PR on our fork. It is ported as 7a84d45a, in batch 9 together with refresh and asking cuts on the same path (only the pages a submission reads).
Setup: RTX 3080 Ti, driver 621.40, Windows 11 Pro build 26300, Ryzen 7 5700X. RT on. Each run is 240 s on the opening interior scene, with a valid (non-compile) rerun. Values are averages over the last 120 s.
Unit tests (victory-gpu): 483 passed. Thanks!
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T13:06:00Z.
Follow-up isolation test on the
0x887A0006(DXGI_ERROR_DEVICE_HUNG) reported earlier:We isolated only the read-only lock-free refresh path and AVX2 copy diff from this PR — omitting
Deferred::refreshed_span(host.rs) — and ran a full 20-minute 3D A/B on the exact same RTX 5080 + Ryzen 7 5700X Windows 11 setup:Shadow::takeword_runs+ batchedSENDatomics,watch::JOURNAL_KEPTfast path,JournalRead::nothing_new_atomic(usingahead_holds),Shadow::copied: Box<[AtomicU64]>withcopy_lock+pending_any/ranged_any, andshadow::wide_chunks(32)inBatch::refresh_front/refresh_ahead/flush_all.Deferred::refreshed_spanin-placeStep::Refreshcoalescing/shrinking.Isolation Result (20-Minute Run,
1200 s,50,243frames)0errors,0DeviceRemoved/DEVICE_HUNG,0exceptions,0GPU>=50ms,0F>=250ms,0F>=500ms, worst 3D frame191.1 ms,327/327(100%) Responding.ALL 3D(n=176 -> 167):13.3 -> 13.9 FPSp50 (+4.5%), mean13.35 -> 13.91 FPS(+4.2%),Prep 60.5 -> 58.1 ms.7k–10k draws/frame(n=37 -> 34):10.90 -> 11.05 FPSp50 (mean10.39 -> 11.06 FPS,+6.4%,copies 45.1 -> 40.2 ms).submitting prep:ww 7.1 -> 6.0 ms,refreshes p90 47.5 -> 42.5 ms,1s frame_times >100ms-19.7%(1,687 -> 1,354).This strongly isolates the
0x887A0006GPU hang toDeferred::refreshed_span(in-placeStep::Refreshmutation/skipping across steps inside a submission), while the lock-freenothing_new_with+wide_chunks+word_runsportions are clean and stable across a full 20-minute workload.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wike1701 on 2026-11-28T13:30:18Z.
Thank you @POMXARK for the thorough 20-minute A/B isolation run — that was super helpful! I have removed \Deferred::refreshed_span\ from this PR so it now contains only the clean, 20-minute-verified subset: lock-free \Shadow::copied\ + \copy_lock, \watch::JOURNAL_KEPT\ /
othing_new_atomic, \wide_chunks(32)\ claiming, and AVX2 \word_runs\ + batched \SEND\ atomics. Re-verified \cargo test -p victory-gpu --lib -- shadow:: watch:: host::\ (197 passed, 0 failed).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by RobertAndreiGit on 2026-11-28T14:34:49Z.
Tested the revised
ee008d0diff on stock63b902f, on a Ryzen 5 5600 / RTX 3060 Ti 8 GB under CachyOS Proton. It built and reached Chapter 1 gameplay. This was one partial run, not a matched stock-vs-patch A/B.VICTORY_CARD_AWAKE=turnssetting. No other source patches in the candidate.The opening tank view matched, but at three later capture marks (610, 720, 940) the candidate faced the balcony while stock faced the radio. The window closed and the title suspended at count 996, before the planned 2,220. So this confirms the revised subset runs on this Proton/8 GB setup and the refresh workload is present; it does not establish a speedup, regression, or long-run stability.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by unueberlegt on 2026-11-29T01:23:50Z.
Data point from an independent pass over #1521's first point (measured standalone before I saw this): instead of lock-free generations we kept
copiedas a mutex (its fold withrangedis upstream as0174844) and batched the journal side — oneJOURNALread guard per claim ofVICTORY_WIDE_CHUNKspans (16 worked best as the default) with a guard-reusingnothing_new_in(&Journal, …), and oneFLUSHES[2].fetch_add(noop)per claim. The read guards are shareable, so workers do not exclude each other; only the writers wait, at most one claim. RTX 5070 12 GB, Ryzen 9 9950X3D (16C/32T), Series X 2560x1440, prologue, steady windows, medians: refreshes 7.2 → 6.8 ms/frame, spans ~6,700/frame at ~83% no-op — the flush wall time there is bounded by the real copies, so the RMW savings show properly only where the submitting thread is the frame's wall (the issue's 8-core reporter). Your 32-item chunk is the same trade at a different point; we did not measure 32 against 16.GPU and profile: NVIDIA RTX 5070 12 GB, AMD Ryzen 9 9950X3D, 31 GB RAM, Windows 11 26300; release builds, steady-window medians.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.