perf(gpu): use runtime-dispatched AVX2 non-temporal stores for large snapshot copies #1003
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1003
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1003"
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?
@adwen-007 on GitHub · 2026-11-28 10:57 UTC · original
adwen-007:pr/perf-avx2-snapshot-copy→main· +62 −1 · 1 files · 1 commits · merged 2026-11-29 08:16 UTCProblem
take_snapshots()copies large write-watched buffer snapshots on worker threads usingstd::ptr::copy_nonoverlapping. For large ranges (>= 64 KiB), regular stores allocate destination cache lines (read-for-ownership DRAM traffic) and evict hot CPU state from L2/L3 cache.Fix
copy_snapshot_avx2(#[target_feature(enable = "avx2")]gated bystd::arch::is_x86_feature_detected!("avx2")) using 4x unrolled_mm256_loadu_si256+_mm256_stream_si256(VMOVNTDQ) with 32-byte destination alignment and_mm_sfence()for copies >= 64 KiB.x86_64-pc-windows-msvcrelease builds (no-C target-cpu=nativerequired) and falls back tocopy_nonoverlappingon non-AVX2 CPUs or copies < 64 KiB.Verification
snapshotstime in thepreparing per framebreakdown dropped from ~28.6 msspikes to0.0–0.3 msacross 20-minute gameplay sessions (0errors).cargo check -p victory-gpuwithoutRUSTFLAGS(generic x86-64 target) and zero warnings onv2026.11.28.01.@Dukestar69 on GitHub · 2026-11-28 11:49 UTC · original · approved these changes
Tested locally merged onto
main(63b902f).crates/victory-gpu/src/shadow.rs;cargo xtask policypassed (294 files ok).len >= 64 KiB+is_x86_feature_detected!("avx2")) properly alignsdstto 32 bytes before unrolled_mm256_stream_si256, copies the tail safely, and issues_mm_sfence()before returning.cargo test -p victory-gpu --lib shadow::passed (36 passed; 0 failed; 2 ignored, includingcopies_cut_into_jobs_copy_the_same_bytes) with 0 compiler warnings.Clean cache-friendly snapshot copy optimization. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).