gpu: opt-in zero-allocation thin-stream peephole folding (VICTORY_THIN_PEEPHOLE=1) #4886
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!4886
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4885"
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?
@lyufeng000 on GitHub · 2026-12-01 12:47 UTC · original
lyufeng000:pr/thin-peephole→main· +1261 −86 · 1 files · 1 commits · openSummary
Split out from Stage 0 of #4856 per
@tikD1337's suggestion and A/B benchmarks as a clean, single-file, zero-extra-thread change (crates/victory-gpu/src/list/thin.rs).Strictly opt-in behind
VICTORY_THIN_PEEPHOLE=1(off by default), leaving the defaultlist::thinreplay path completely untouched.Architecture (
PeepholeWindow/translate_peephole)Stack-allocated, single-pass peephole optimizer placed ahead of
list::thinreplay:PIPELINE,ROOT,TOPOLOGY,STENCIL_REF,BLEND_FACTOR,SAMPLE_MASK,VIEWPORTS,SCISSORS,INDEX_BUFFER,TARGETS,HEAPS,SHADING_RATE), resetting committed history onRESETandCLEAR_STATE.TARGETSflushes any pending coalesced copy first to preserve copy-vs-target ordering.(kind, slot)or vertex-buffer range overwrites before a flush boundary.BARRIER/BARRIER_GROUPS(w[0] == 0) while strictly preserving upstream's bit-63 narrowBARRIER_GROUPSskip marker (w[0] == 1 << 63->state.synced()), and merges adjacentCOPY_BUFFER/COPY_MEMORYcalls under four gates (same kind/buffers, contiguous offsets,dst != srcnon-aliasing includingbuffer_baseoverlap check, and capped byte budget).EXTERNAL,UPLOAD, andCLOSEflush all pending state in original order before replay, and abandoned recordings stop immediately before emitting actions.Verification
cargo test --locked -p victory-gpu --lib list::thin::tests -- --test-threads=1): 10 passed; 0 failed (including all 4 newpeep_*tests).cargo clippy --locked -p victory-gpu --lib --tests): 0 warnings incrates/victory-gpu/src/list/thin.rs.Independent
--releaseA/B Benchmarks (from #4856 by@tikD1337)Measured on Ryzen 5 7600 (6C/12T) + RTX 4070 Ti SUPER 16 GB (Driver
621.1.0, ReBAR ON,VICTORY_SUBMIT_SPLIT=1,VICTORY_DLSS=1Quality, Series S mode, 105 s steady 3D runs, 0 crashes):>=200lists)card(GPU)submit_prep5.5k–6.5k5fabb46e,PC=1)VICTORY_THIN_PEEPHOLE=1solo (PC=1)THIN_PEEPHOLE=1+LOW_L0_DMAstack (PC=0)~10.9kheavy: 21.7 FPS vs 16.3)@tikD1337 on GitHub · 2026-12-01 13:10 UTC · original
Thank you for splitting this out, @lyufeng000 — and get some well-deserved rest!
Verified that
crates/victory-gpu/src/list/thin.rsat#4885head (1e4a174b) is byte-for-byte identical to the Stage 0 code from#4855(bc15e0a5) tested earlier onorigin/main(5fabb46e, Ryzen 5 7600 + RTX 4070 Ti SUPER, Win1126300, Driver621.1.0, DLSS Quality,105 ssteady 3D--releaseruns):VICTORY_THIN_PEEPHOLE=1(off by default) -> zero default-path risk.VICTORY_THIN_PEEPHOLE=1solo gave 27.00 FPS (37.04 ms) vs 23.24 FPS (43.03 ms) base (+16.2%,submit_prep 35.6 -> 28.9 ms,card 38.8 -> 34.2 ms),0crashes (peep_*4/4 PASS).POMXARK 01/03/04+#4527(VICTORY_PORT_CONSTANTS=0) hit 27.52 FPS (36.34 ms,5.5k–6.5k: 27.90 FPS,~10.9k: 21.7 FPS,card 21.1 ms),0crashes.(FWIW to reviewers: the red CI
checkrun is unrelated pre-existing clippy items inhost/menu.rsandhost/panel.rsonmain, nothing inlist/thin.rs.)@POMXARK on GitHub · 2026-12-01 15:26 UTC · original
VERDICT: KEPT IN TREE (opt-in
=0default) — Unit tests PASS (minor test update noted), clean paired A/B is neutral on our 3.3k-draw cutscene onceprocmemaliasing is removedTested head
1e4a174bcleanly on top ofv2026.11.30.03(e1251c31).Hardware & Setup
--releasebinary toggled via--set VICTORY_THIN_PEEPHOLE=0vs1withVICTORY_PROCESS_MEMORY=0(eliminating the 5sVirtualQuerystorm that previously aliased paired runs).Unit Test Note
v2026.11.30.03(with query PRs merged),list::thin::tests::bindings_record_no_workfailed (47 != 49) untilPlain::BEGIN_QUERYandPlain::END_QUERYwere added to theworklist inthin.rs. After that fix:list::thin::tests10/10 PASS.Same-Binary Paired A/B (
VICTORY_PROCESS_MEMORY=0, 45s 3D opening/diner cutscene)THIN_PEEPHOLE=0med (p75)THIN_PEEPHOLE=1med (p75)18.65(20.20)17.50(18.40)-1.15(higher draw count)53.65 ms(56.50)57.15 ms(59.10)+3.50 ms3,1843,424+240 (+7.5%)16.85 ms16.70 ms-0.15 ms (-0.9%, neutral)6.59 us/call6.55 us/call-0.6% (neutral)0241 / frame2/2PNG verified, 0 artifacts)Summary: The peephole folding itself is clean, zero-thread, and folds ~241 redundant state calls/frame without visual regressions. On our 3.3k-draw cutscene with
VICTORY_PROCESS_MEMORY=0it measures neutral per draw/call (-0.9%), whereas on heavier draw windows (~10.9kdraws, as @tikD1337 measured) it should scale better. Kept in our build as opt-in (=0default).Full applied PR & patch chain on top of
v2026.11.30.03(e1251c31)#4500(Blackwell upload strides),#4501(prebuild prologue irradiance-cache),#4496(water tiled lightVICTORY_WAVE_FOLDED_FIRST),#4506,#4545(wide non-XOR texture detile cache tiling),#4558,#4567,#4571,#4648(AVX2 landing),#4651(SAME_PRINT),#4659(TELEMETRY_OFF),#4885(VICTORY_THIN_PEEPHOLE, opt-in).POMXARK/victory-city-bench,patches/v2026.11.30.03/01..06, reviewed in Discussion #3556):01:COLD_WW_RO1 MiB chunks + out-of-GUARDS64-stripeVP_STRIPE02:VICTORY_STEPS_FAST=1+VICTORY_LISTED_TWINS=003:VICTORY_LOW_L0_DMA=1(0xb10000MEM_WRITE_WATCH 4K + L0→L1 GPU DMA)04:VICTORY_DESC_MIRROR_CAP=1+VICTORY_SOFT_BATCH=1(4 MiBLAZY_AT)05–06: Review hardening (ARMINGbitmap +reopen_striped_block+ real-path race test, droppedahead_intact, strict per-rangecard_l0_dma_allows).--dlss quality,VICTORY_PROCESS_MEMORY=0,VICTORY_PORT_CONSTANTS=0,VICTORY_WC_BAR=3,VICTORY_CARD_CPU_FILE=0,VICTORY_MAP_ONCE=1,VICTORY_SCRATCH_CARD=1,VICTORY_ASK_FIRST=1,VICTORY_SWEEP_OFF_THREAD=0,VICTORY_DUE_INDEX=0,VICTORY_GUARD_SHARDED=1,VICTORY_STEPS_FAST=1,VICTORY_LISTED_TWINS=0,VICTORY_LOW_L0_DMA=1,VICTORY_DESC_MIRROR_CAP=1,VICTORY_SOFT_BATCH=1.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.