perf(gpu): port lazy GPU->CPU copy-back v2, O(dirty) CopiedPages, AVX2 SIMD & telemetry #357
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!357
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-357"
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?
@Vladimir-Human on GitHub · 2026-11-26 12:29 UTC · original
Vladimir-Human:perf/lazy-copyback-and-simd→main· +8381 −161 · 8 files · 2 commits · closed without mergingPorts the lazy GPU->CPU copy-back v2 engine, O(dirty)
CopiedPages, AVX2 diff/merge SIMD paths, and per-frame lazy copy-back telemetry fromfxceless/victory-fork#1178, adapted cleanly forLooperSalty/AnyXboxXwhile preserving all Neptune features (RwLockguards,VICTORY_WATCH_4K=1,windowuptransient buffers,VICTORY_WINDOW_REBAR,VICTORY_QUIET_BACK,VICTORY_INFLIGHT_FETCH,VICTORY_RELAY_OWN_QUEUE).Summary of Changes
VICTORY_LAZY_COPYBACK=1, default off —shadow.rs,host.rs,watch.rs,inplace.rs,xmem.rs,lib.rs):card_back,relay_card_back(bothpiecesandkeptforVICTORY_RELAY_OWN_QUEUE),relay_card_inflight(VICTORY_INFLIGHT_FETCH), andrelay_hand_back, materializing on demand via VEH only for pages the title CPU actually touches.window,rebar,transient(), and in-place shadows (place.is_some() || window || rebar || transient() || data.is_null()).host::copy_mapped(!title_dst),host::read_into) service deferred pages directly from VRAM via lock-freeLazyAccessHold+lazy_read_bypasson a dedicatedD3D12_COMMAND_LIST_TYPE_COPYqueue (zero VEH faults, zeroVirtualProtectchurn);host::copy_mapped(title_dst)andhost::write_mappedflush+hold before writing;inplace::write_section_ownreusesALIASESpersistent whole-section views for tear-freeMEM_MAPPEDmaterialization; contiguous runs coalesce into oneVirtualQuery-clippedVirtualProtectper uniform region; lock-free 2-levelLAZY_MAPPED_VIEWbitset keeps steady-stateMEM_MAPPEDwatch::known_view/watch::guardrefreshes lock-free.xmem::write_physicalandxmem::page_windowflush+hold shown pages viakernel_will_write_holdoutsidephysical()BEFORE physical mutation (preserving partial-page GPU complements and preventing post-writekernel_will_writeclobber);watch::written_through_viewandwatch::title_memory_writtenrelease deferred pages safely;watch::views_mappedflushes existing deferred aliases unconditionally before opening guards;lazy_submit_gpu_guard()serializesHost::submitExecuteCommandLists+Signal+submitted_fence+note_write_fence(late & sync) againstCOPY-queue readbacks (dropped before anyWaitForSingleObject, zero cost when inactive).CopiedPages& AVX2 SIMD (shadow.rs):Shadow::copiedtoCopiedPages(SmallRuns+ 64-pageuncopied_bitsO(dirty)plan_stale/plan_stale_filtered, preservingVICTORY_WATCH_4K=1stale_mask/note_4k/extend_runs).first_difference,last_difference,merge_piece(with equal-vector fast path),merge_sync_card,wc_sfence,copy_from_wc, andslices_equal_wc.frametime.rs,host.rs,shadow.rs):frametime.rsCSV (lazy_deferred_pages,lazy_veh_faults,lazy_self_bypass_hits,lazy_bytes_readback,lazy_materialize_ms,lazy_protect_ms) and per-windowMeter::framelogging whenVICTORY_LAZY_COPYBACK=1is active.shadow_lazy_tests.rs):.rsfiles remain well under the 512 KiB policy limit) + 2--ignoredhardware benchmarks.Verification
cargo run -p xtask -- policy --staged: ok (200 files ok, all files< 512 KiB)cargo clippy -p victory-gpu -p victory-hle --all-targets(default &--all-features): 0 warnings in touched/added linesVICTORY_D3D12_DEBUG=1(0 D3D12 debug errors):victory-gpushadow(default): 59 passed; 0 failed; 2 ignoredvictory-gpushadow::lazy_and_simd_tests(--all-features): 26 passed; 0 failed; 2 ignoredvictory-gpuwatch: 15/15,frametime: 1/1,inplace: 6/6victory-hlexmem: 14/14victory-gpulib (skipping only the 3 pre-existingc4c93bdbaseline failures): 207 passed; 0 failed (default), 220 passed; 0 failed (--features diagnostics)--releasebenchmarks:bench_lazy_copyback(64 MiB GPU-written carded VRAM):0% CPU reads:39.258 -> 1.225 ms/f(32.05x, readback64.00 -> 0.00 MB/f,0.0VEH faults)0.3% CPU + 10% layer reads:40.198 -> 8.861 ms/f(4.54x, readback64.00 -> 0.19 MB/f,3.0VEH faults,100.0self-bypass hits,0.02 msprotect)2% sparse CPU reads:38.860 -> 4.358 ms/f(8.92x, readback64.00 -> 1.25 MB/f,20.0VEH faults)bench_shadow_and_rebar:plan_stale(160 MiB, 4 dirty)11.3 ns/call; 64 MiB SIMDfirst+last 0.40 ms(168.3 GB/s),merge_piece 4.63 ms,merge_sync_card 6.03 ms,changed_runs 5.52 ms.@Skyfrye on GitHub · 2026-11-26 14:42 UTC · original
For information: I tried this PR in an integration build on
mainat2cc6593(after #358 and #377), stacked with #354, #345 and my #278, #279, #292, #307, #360-#362, #381 and #382. It no longer applies tomain. The conflicts are in what the code does, not just neighbouring lines: host.rs (7 conflicts): the fence mirror (submitted_fence) against #354'slast_signalled, the late-path signal andnote_write_fenceagainst #354's texture stamping, and the GpuWrite check insidestale_under_flights, which #361 rewrote as one pass (RefreshSpans);declared_writes(runs)is gone with #362. I left it out of that build rather than guess at the merge. A rebase on currentmainwould let it in the next one.🤖 Generated with Claude Code
eb8e7163e4tob89cc0a1a0@Vladimir-Human on GitHub · 2026-11-26 15:12 UTC · original
@Skyfrye Rebased strictly onto current
main(26c11d4, post-75f88de/ #358 / #377 / #367 / #383; new headb89cc0a, without pulling in unmerged PRs):host.rs(stale_under_flights): kept theStep::GpuWritehas_lazy_resync_under_writessettle guard alongside#383'sVICTORY_STEP_INDEX(if !indexed)Step::Refreshpath.shadow.rs& tests: syncedCardwith#340(note_carded/Card::me/FLAGGED+has_dirty/has_sent) andCard::prints, and preserved#377'sVICTORY_CLAMP_AFTER_WRITERhook.cargo xtask policy(215 files ok),cargo clippy -p victory-gpu -p victory-hle --lib --tests(0 new warnings), andVICTORY_D3D12_DEBUG=1tests (shadow::64/64 incl. alllazy_and_simd_tests,watch::16/16,frametime::1/1,inplace::6/6,victory-hle121/121; fullvictory-gpuruns show only the 3 pre-existingmainfailures indescriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewedandindirect::tests::warp_card_*).If stacked with
#354/#361/#362in an integration build:submitted_fence/note_write_fencevs#354:submitted_fenceis just a monotonicAtomicU64mirror ofself.fence's last signalled value—it can reuse#354'slast_signalleddirectly as long aslazy_submit_gpu_guard()spansExecuteCommandLists+Signal+note_write_fence(*submitted)on the late, sync, andcard_backpaths (alongside#354's texture stamping).stale_under_flightsvs#361: the singleStep::GpuWrite(shadow, address, len)check (shadow.writes_pending() && shadow.has_lazy_resync_under_writes(*address, *len)) drops directly into#361'sRefreshSpanspass without affectingRefreshspan collection.declared_writes(runs)vs#362:#357only iterates the submission's declared(shadow, range)write set to callshadow.note_write_fence(*submitted)afterSignaland to feedrelay_hand_back;#362's replacement write list can supply that same set.@Vladimir-Human on GitHub · 2026-11-26 18:50 UTC · original
Pushed follow-up
c62aea7toperf/lazy-copyback-and-simdsyncing the v2 VEH escape fix, split-4 KiB batch unprotect fix, hot-page cooldown / O(1) fast-reject, and upgraded regression tests ontothird_party/victory:LAZY_TABLE_EPOCHretry inwatch.rs::on_write(MAX_EPOCH_RETRIES = 32+committed_protect) andLAZY_FLUSH_TOTAL > 0 || LAZY_TABLE_EPOCH > 0on bothPageAccess::Accessiblepaths inlazy_on_fault.restore_rw_runwith full split-4 KiBunprotect_and_write_page/write_section_subregionfallback inflush_claimed_batchandlazy_release_range.fetch_maxinlazy_mark_hot,u32::MAX - 1timed-cooldown clamp,LAZY_RESYNCAcquireguard beforelazy_post_resync_state, and upgraded regression tests inshadow_lazy_tests.rs.third_party/victory(VICTORY_D3D12_DEBUG=1, WARP / unit & GPU-compute harness):cargo xtask policy: exit 0 (215 files ok).cargo clippy -p victory-gpu --features diagnostics --all-targets: 0 warnings inshadow.rs,shadow_lazy_tests.rs, or the touchedwatch.rslines.cargo test -p victory-gpu --features diagnostics -- lazy_copyback --test-threads=1: 26 passed; 0 failed; 1 ignored.cargo test -p victory-gpu --features diagnostics -- watch:: --test-threads=1: 16 passed; 0 failed.cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 279 passed; 3 failed; 6 ignored (only the 3 pre-existingorigin/mainfailures indescriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots, andindirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others).c62aea77e1toe47bee6875@Vladimir-Human on GitHub · 2026-11-26 19:11 UTC · original
Rebased onto
main(50936c0->e47bee6, resolvedframetime.rsalongside #420 and adaptedinplace.rsto theBTreeMap/HashMapview-table changes).Verified locally (
VICTORY_D3D12_DEBUG=1):cargo xtask policy(216 files ok),cargo clippy -p victory-gpu --features diagnostics --all-targets&-p victory-hle --all-targetsexit0;lazy_copyback26/26(1 ignored),frametime::4/4,watch::16/16,inplace::6/6passed.@Vladimir-Human on GitHub · 2026-11-26 19:19 UTC · original
Noting that #409 (
37d4686) replacedthird_party/victorywith the combinedavatarmanz + cool_foxbase (124files changed), putting this Neptune-based branch inCONFLICTINGright after the50936c0rebase.The same
lazy-copyback v2patch set is up to date and clean onPastiiJay/klbf-lab#59andfxceless/victory-fork#1178; happy to re-port onto37d4686+once the#409base settles if you want it here.@LooperSalty on GitHub · 2026-11-26 23:09 UTC · original
Closing after #454 moved
third_party/victoryto the Vice-Tay base (TaynanGT/Vice-Tay a252348).CopiedPages/VICTORY_LAZY_COPYBACKand the files it touches do not apply to the new base (about 8,400 lines to port), the mode is opt-in and no gain was measured. Vice-Tay already cuts the copy-back by keeping title buffers on the card.Thanks for the work. If you measure a gain on the new base, a new PR against
mainis welcome.🤖 Closed by Claude Code on behalf of the maintainer
Pull request closed