Optimize submission write-watch, card_steps planning, range-scoped Batch invalidation, and async landing #2647
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!2647
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2647"
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?
@piyonchu on GitHub · 2026-11-29 15:32 UTC · original
piyonchu:perf/submission-pipeline-batch-card-steps→main· +1756 −641 · 3 files · 1 commits · openWhat it changes
Addresses four CPU bottlenecks on the submission path (
#2588-style preparation andafter the sendingtail) without overlapping existing open PRs:Range-scoped invalidation & hot-path reductions in
BatchandDeferred(crates/victory-gpu/src/host.rs)Batch::title_written_range(dst, len)andDeferred::title_written_range(dst, len)forStep::CopyandStep::Placedinstead of calling whole-statetitle_written():fills,duetextures (staging_due+texture_ranges), andrefreshesoverlapping[dst, dst + len)are flushed/removed (refreshesupdated in-place viaswap_remove+indexfixup), whiletitle_writestracks sorted non-overlapping written ranges (join_ranges) so disjointaheadentries remain valid across the frame.last_add) inBatch::add,forward_cursormonotonic lookup inBatch::find_forward_fill, and deduplicatedBatch::copy_spanswhenasked_firstalready populatedbatch.spans(copy_spans_extendwhenownprepends).HELPER_ALIVE+helper_land()(VICTORY_HELPER_LAND=0opt-out) sosend_latecan offload non-blocking landing work (land()) tolate_helperunder a<= 32queued-list cap.card_stepsplanning &RefreshSpansindexing (crates/victory-gpu/src/host/card_steps.rs)CardStepsScratch(CARD_STEPS_SCRATCH, capacity capped at8192) andPlanScratch(plan_with_scratch) reusing per-thread allocations across submissions and replacing boxed iterator trait objects and full-slice rescans withcandidatespre-filtering andhas_placed && has_slot_fillgating forserved_fills_into/behindchecks.Step::Refreshsteps fromdoesviacollect_active_into, storing(from, to, shadow)inRefreshSpanswith lazy building:<= 4elsewhere()queries scan linearly with zero sort cost, and>= 5queries trigger one in-placesort_unstable+dedup+max_endprefix maxes forO(log R)queries.blocked_by+copied_readsinto one pass/lock inprecheck_runs, and switchedFillTolookup to direct indexing (fill_to_run).Zero-churn scratch reuse in write-watch asking (
crates/victory-gpu/src/watch.rs)kernel_written,ask_ahead,ask_rest,ask_run, andwriteswith thread-localAskScratch(ASK_SCRATCH, capacity capped at8192),merged_into, andkernel_written_into.How it was tested
host::card_steps::tests::refresh_spans_matches_linear_elsewherehost::card_steps::tests::active_only_plan_matches_full_does_with_refresheshost::batch::deferred_title_written_range_keeps_disjoint_entrieshost::batch::batch_range_writes_preserve_disjoint_ahead_and_flush_overlapping_work#[ignore = "benchmark"]microbenchmarks added and measured (cargo test --release --locked -j 4 -p victory-gpu --lib <name> -- --ignored --nocapture --test-threads=1):planning_20k_refreshes_before_vs_after:100 iters x 20000 refreshes + 300 active: 8.79ms before -> 5.22ms after (1.7x)batch_range_writes_before_vs_after:300 submits, 1500 ahead spans, 150 adds/sub: 123.16ms (495,000 re-queued) before -> 56.75ms (0 re-queued, 2.2x)cargo test --locked -j 4 -p victory-gpu --lib -- --test-threads=1: 919 passed, 0 failed, 59 ignored (yes)cargo check --lib -p victory-gpu --locked&cargo clippy -p victory-gpu --lib --tests --locked: passed with 0 warnings in touched codecargo xtask policy --staged:asset policy: 3 files okChecked for overlap
#2587(card_before/card_record/host/send.rs),#2512(VICTORY_JOIN_COPIES),#2530(parts_written(&[])/shadow.rs), or#2529(descriptor/host.rs/draw.rs).@BitWuehler on GitHub · 2026-11-29 16:41 UTC · original
Tested on Linux (CachyOS) / GE-Proton 11-14 (
vkd3d-proton master) / Ryzen 7 9800X3D / RTX 5080 16 GB (driver 620.73.04, ReBAR active) on top of829188e9(Series X profile, 1440p, DLSS Quality,VICTORY_WAVE_FOLDED=0,VICTORY_CODE_TABLE_AFTER=1,VICTORY_SAMPLED_MARKS=0):after_sendingdropped from 2.93 ms avg (34.4 ms max) to 0.40 ms avg (~7–9x reduction).(Test summary compiled with AI assistance.)
@icdmkg2 on GitHub · 2026-11-29 18:20 UTC · original
An in-game data point from an 8 GB laptop. It covers this PR together with four others, so it can't attribute the gain to this one alone.
Setup: RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24.
mainat55d06914, release build, Series S, DLSS performance,VICTORY_LEVELS_ON_DEMAND=0andVICTORY_COMMIT_FLOOR_MB=1024in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs.Combo:
main+ #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested.mainThat's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build,
VICTORY_CAPTURE_WORLD) matchedmain's brightness (mean luma 66.4 against 66.2), with no black holes.One thing for the diagnostics build: with these merged together,
--features diagnosticsno longer compiles. A localtiminginsubmitshadowshost::timing()at three call sites, andcopystat::log_heap_elsewhereuses anmbhelper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.@POMXARK on GitHub · 2026-11-30 10:39 UTC · original
Hi @piyonchu — sharing two orthogonal
git am-ready patches rebased ontov2026.11.29.05(41adb55) in #3556 (https://github.com/trustno1-coder/VIctory-NVIDIA/discussions/3556#discussioncomment-20023964) that complement #2647's submission write-watch work:xmem.rs(VICTORY_LOW_PRIVATE_WATCH): backs the185 MiB32-bit graphics reservation withMEM_PRIVATE | MEM_WRITE_WATCH(-86.6%VirtualProtect,-71.3%VEH, 4 KiB hardwareGetWriteWatchgranularity).watch.rs(VICTORY_WIDE_WATCH): parallelizesask_ahead/ask_onceacross disjoint reservations viawide_each_scoped.Not opening separate PRs — feel free to fold or test if helpful.
3f71782436to9599936aa4@piyonchu on GitHub · 2026-11-30 19:22 UTC · original
Rebased
#2647onto latestmain(e1251c31, head9599936a), integrating cleanly with upstream submission/watch changes (ask_once,not_write_watched/refusals,join_copies,Batch::front_dirty,constant_slots_batch, andlater_uav):Batch::join_copyincrates/victory-gpu/src/host.rsto invalidatetitle_written_range(next.0, next.2)per joined contiguous copy and keptnvidia/main's.get(at..at + len)guard forfind_forward_fill.AskScratch+merged_into+kernel_written_intoreuse incrates/victory-gpu/src/watch.rstoask_onceandask_run_allwhile preservingtell_watch,not_write_watched,refusals, andcovered_to.later_uavmulti-level barrier batching,constant_slots_batch, andlate::forget()incrates/victory-gpu/src/host/card_steps.rs.Thanks
@BitWuehler,@icdmkg2, and@POMXARKfor testing and feedback:--features diagnostics: verifiedcargo check --lib -p victory-gpu --features diagnostics --lockedcompiles cleanly on9599936a.@POMXARK: kept#2647scoped cleanly tovictory-gpusubmission-path scratch/planning/range-invalidation/helper_land(separately fromvictory-hle/xmem.rsandVICTORY_WIDE_WATCH) so each change can be reviewed and validated independently.Rebased checks (
9599936a)cargo check --lib -p victory-gpu --locked&cargo check --lib -p victory-gpu --features diagnostics --locked: passed (0 warnings in touched files)cargo clippy -p victory-gpu --lib --tests --locked: passed (0 warnings in touched files)cargo xtask policy --staged:asset policy: 3 files okcargo test --locked -j 4 -p victory-gpu --lib -- --test-threads=1: 1135 passed, 68 ignored, allwatch::*,host::*,host::card_steps::*, andhost::batch::*tests passed (only the 2 pre-existinge1251c31failures inlist::thin::tests::bindings_record_no_workandshader_cache::tests::every_switch_of_the_translator_is_in_the_key)cargo test --release --locked -j 4 -p victory-gpu --lib <name> -- --ignored --nocapture --test-threads=1):planning_20k_refreshes_before_vs_after: 6.9819ms -> 4.1214ms (1.7x)batch_range_writes_before_vs_after: 73.0686ms (495000 re-queued) -> 43.6873ms (0 re-queued, 1.7x)@paales on GitHub · 2026-11-30 21:45 UTC · original
Written by 🤖:
In-game numbers for the write-watch part of this PR. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s.
The whole PR conflicts with #4207 (its range-scoped invalidation), which my build has. So I applied only the
crates/victory-gpu/src/watch.rspart of9599936a, ontomain84bd61e2with #3918, #1727, #3553, #3043, #4207, #4138 and #720 (branchnexton paales/VIctory-NVIDIA).watch.rspartThe time to ask the write watch did not change measurably in this scene. Other changes between the runs were in other parts of the frame, and the write-watch figure is from the layer's own line ("preparing per frame, the submitting thread: … asking the write watch"). I did not measure the other three parts of this PR.
@BitWuehler on GitHub · 2026-12-01 00:41 UTC · original
Re-tested the rebased PR (
9599936a) on Linux (CachyOS) / GE-Proton 11-14 (vkd3d-proton master) / Ryzen 7 9800X3D / RTX 5080 16 GB (driver 620.73.04) on top of7d93ee07(Series X profile, 1440p, DLSS Balanced + DLSS Frame Generation 2x):main, 0 crashes and 0 host pipeline failures over a 22-minute session (188 in-world intervals, avg 5,191 draws/frame).frame_ms43.4 ms avg / 39.9 ms med / 156.1 ms max,prep_ms28.4 ms avg / 60.6 ms max,gpu_ms0.64 ms avg.(Test summary compiled with AI assistance.)
9599936aa4to5a028f2e59@piyonchu on GitHub · 2026-12-01 02:09 UTC · original
Rebased
#2647cleanly onto latestmain(f5c3d243, head5a028f2e) and added multi-view physical-alias invalidation:watch::elsewhere_blocks,with_write_ranges,title_written_ranges):Batch::title_written_rangeandDeferred::title_written_rangenow also invalidate any 64 KiB view alias blocks mapping the same physical pages (crate::watch::elsewhere_blocks) via stack fast-path&[(dst, end)]when unaliased (zero extra allocation when!view_guard()or no aliases exist). Added unit testhost::batch::title_written_ranges_invalidates_multiple_alias_spans.@paales: Thanks for isolating and measuring thewatch.rssubset — on currentmain, single-passask_oncealready runs once per submission (kernel wait dominates that metric at ~3.3–3.6 ms), sowatch.rs'sAskScratchchange mainly removes per-submissionVecchurn rather than kernel time, whereas the measurable latency reductions come fromcard_stepsplanning/RefreshSpans, range-scopedBatchinvalidation, andhelper_land. Note also#4206was opened after#2647and touches 30+ files;#2647keeps its range invalidation alias-safe (elsewhere_blocks) while staying strictly withinwatch.rs,host/card_steps.rs, andhost.rs.@BitWuehler: Thank you for the 22-minute Series X + DLSS FG 2x verification on9599936a.Verification on
5a028f2ecargo xtask policy --staged:asset policy: 2 files okcargo check --lib -p victory-gpu --locked&cargo check --lib -p victory-gpu --features diagnostics --locked: passed (0 warnings in touched files)cargo clippy -p victory-gpu --lib --tests --locked: passed (0 warnings in touched files)cargo test --locked -j 4 -p victory-gpu --lib -- --test-threads=1: 1100 passed, 0 failed, 68 ignoredcargo test --release --locked -j 4 -p victory-gpu --lib <name> -- --ignored --nocapture --test-threads=1):planning_20k_refreshes_before_vs_after: 7.9913ms -> 5.1906ms (1.5x)batch_range_writes_before_vs_after: 99.8658ms (495,000 re-queued) -> 51.9939ms (0 re-queued, 1.9x)View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.