perf(gpu): SEH AVX2 word_diff_copy, scoped WC-burst send::take, and fused copy_spans/refresh_front #3395
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3395"
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 qlfu on 2026-11-29T22:46:12Z.
Summary
Four verified CPU submitting-thread hot-path improvements measured in clean 90s Series X 1440p DLSS Balanced runs (Ryzen 7 5700X + RTX 4070 Ti 12 GB,
0 WARNs / 0 ERRORs):victory_safe_word_diff(safecopy.rs,shadow.rs): eliminates the 64 KiBTITLEbounce-buffer double-copy inShadow::take(watched == 1) with an 8-byteu64mask scan (emit_word_diff_masks) and zero-allocword_runs_and_update_into. Includes unit testword_diff_copy_matches_and_recovers_on_faultcovering exact partial progress onPAGE_NOACCESS.wide_each_scopedcombined scatter + copy insend::take+ 512 B WC burst scatter (host/send.rs,host.rs): threadsjoin_now = publishfromHost::submit->card_take->send::take, avoiding redundantcopy_besideheap allocations (Box/Arc/Mutex) when the caller joins immediately, and bursts 64 pairs (512 B = 8 WC cache lines) at a time into PCIe BAR underVICTORY_SEND_BAR=1.copy_spans+refresh_front+front_completefast-skip (host.rs): collectsfront_spansandfront_dueduring the existingcopy_spanswalk beforeask_once, eliminating the duplicate 25k-step traversal andlist.deferred()lock acquisitions inrefresh_front, and skipsBatch::addlookups inrun_deferredwhilefront_completeholds.Measured Results (90s idle-CPU gameplay, Series X 1440p DLSS Balanced,
0 W / 0 E)233659.log)012643.log)card_mem(mean)3.33 ms1.93 ms(002306)refreshes(mean)10.87 ms10.06 ms(002306)steps_oth(med)4.50 ms(002306)3.75 ms(012643)prep(med)27.70 ms26.15 ms26.09 / 41.826.39–26.46 / 44.7(65s011424:27.40 med / 28.55 mean / 44.9 max)Verification
git merge-tree --write-tree origin/main pr/perf-safecopy-scoped-send-fused-front: exit0cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- word_diff_copy --test-threads=1: passcargo +1.98.1-x86_64-pc-windows-msvc xtask policy --staged: passImported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T00:12:39Z.
Rebased cleanly onto
main(41adb551), combiningsend::takewith upstream#2509(parallel_copy_work) while preserving the BAR 64 KiB parallel threshold andjoin_now, keeping upstream#2530'sself.changed_runs(...)inshadow.rs, and guardingfront_spans_into/Touch::Partfor zero new warnings. Verifiedsafecopy::tests::word_diff_copy,host::send::tests::, and--features diagnostics.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T01:01:39Z.
We ran a test of this PR on an 8-core Zen 3: picture fine, but slower on this machine.
Setup:
41adb551(the merge only adds this PR's own commits), against41adb551itself;We also ran a picture check: a burst of 10 captures a second at the end of each run, looked at frame by frame.
41adb551The gain in the description was measured with prep around 27 ms. Here the submitting thread is at about 62 ms, bound elsewhere, so the AVX2 path may simply not be where this machine spends its time. If one of the three parts has a switch, we can split them.
AI Assisted
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T10:35:56Z.
@DoubleD17 Thanks a ton for testing this on stock
41adb551— your telemetry nailed two real regressions on stock defaults that were masked in our stacked testing:wide_each_scopedcontention inhost/send.rs:send::takewas switched fromcrate::land::each_under(dedicatedvictory-underpool) tocrate::shadow::wide_each_scoped. On stock41adb551,wide_each_scopedhas a singleq.scopedslot and falls back inline whenever another thread (such asrefresh_front) is already in a scoped pass — serializingsend::takeon the submitting/sending path. Restoredcrate::land::each_underfor both parallel copy+scatter and scatter-only paths.shadow.nothing_newwalk inhost.rs::refresh_frontwhenVICTORY_FRONT_SIFT=0(stock default): During the rebase onto41adb551, the defaultfront_sift == falsebranch fell back to a single-threadedspans.retain(|...| !shadow.nothing_new(...))loop over ~5,200 spans per frame (takingJOURNAL.read()per span) instead of checkingnothing_new_with(&self.ahead_snap, ...)inline in parallel inside the singlewide_each_scopedrefresh dispatch. Restored the lock-freeahead_snap+ parallel inline sift (check_inline).victory_safe_word_diff(128 B/iter with one combinedvpcmpeqd/vpandfast path + exact SEH fallback to the 32 B tail on mid-128B page faults, covered by an added shifted-page fault test inword_diff_copy_matches_and_recovers_on_fault).Pushed in the latest commit — if you have a chance to re-test on stock
41adb551, bothpreparingandrefreshesshould now be cleanly faster than baseline.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T15:05:20Z.
Skipped populating
Batch::aheadHashMap (~5,400 inserts/frame) inrefresh_frontwhenself.front_completeis true, sinceStep::Refreshskipsbatch.addwhilefront_completeholds andtitle_writtenclearsself.ahead. Verified:cargo check -p victory-gpu --all-targets --all-features --locked+host::tests(91 passed, 0 failed) + cleanmerge-treeonto41adb551.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:52:45Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
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.