gpu/shadow: opt-in VEH lazy GPU-to-CPU copy-back (4/4 of #51) #59

Open
github-bot wants to merge 1 commit from github-bot/gh-59 into beta AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 00:48 UTC · original
Vladimir-Human:perf/split-lazy-copyback-veh → beta · +3810 −66 · 3 files · 1 commits · open

Split 4/4 of #51 cleanly on top of beta (78ad5711, independent of #56, #57, and #58).

Summary of Changes (host.rs, watch.rs, shadow.rs)

  • Opt-in VEH lazy GPU-to-CPU copy-back (VICTORY_LAZY_COPYBACK=1, default OFF):
    • Defers 64 KiB aligned copy-back pieces (PAGE_NOACCESS) across GPU-to-GPU workloads so steady-state frames touch zero PCIe readback bytes, flushing individual pages on demand inside watch's vectored exception handler (on_fault) on first CPU read/write.
    • Supports both MEM_MAPPED physical views (atomic dual-view flush before restoring PAGE_READWRITE) and MEM_PRIVATE | MEM_WRITE_WATCH buffers (serialized via FlushWait), leaving unaligned/pinned/fence ranges eager.
    • Preserves DirectStorage / kernel title_memory_written partial-page complements, captures idempotent FlushedBaseline for in-flight relay/merge paths (card_merge_relay, relay_merge, stale_under_writes, merge_under_writes), and holds scoped lazy_flush_and_hold / Remapping barriers across remaps and host copies.
    • Maintains strict acyclic lock hierarchy (Level 0: watch/Shadow -> Level 1: LAZY_TABLE -> Level 2: LAZY_GPU -> Level 3: FlushWait).
  • Tests & opt-in microbenchmark: 11 shadow::lazy_copyback_tests::lazy_copyback_* unit and live-GPU coherence/stress/F1-F5 regression tests (scoped with lazy_opted_in test isolation so parallel non-lazy tests never inherit deferred state) + #[ignore] bench_lazy_copyback.

Verification (VICTORY_D3D12_DEBUG=1)

  • cargo test -p victory-gpu (run 1 & run 2 parallel, plus serial --test-threads=1) -> all passed
  • cargo test -p victory-gpu --all-features -> passed
  • cargo run -p xtask -- policy --staged -> asset policy: 3 files ok (host.rs = 367,393 B, watch.rs = 81,104 B, shadow.rs = 345,266 B)

Related: #51, #56, #57, #58

**@⁠Vladimir-Human** on GitHub · 2026-11-26 00:48 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/59) `Vladimir-Human:perf/split-lazy-copyback-veh` → `beta` · +3810 −66 · 3 files · 1 commits · open Split 4/4 of #51 cleanly on top of `beta` (`78ad5711`, independent of #56, #57, and #58). ### Summary of Changes (`host.rs`, `watch.rs`, `shadow.rs`) - **Opt-in VEH lazy GPU-to-CPU copy-back (`VICTORY_LAZY_COPYBACK=1`, default OFF)**: - Defers 64 KiB aligned copy-back pieces (`PAGE_NOACCESS`) across GPU-to-GPU workloads so steady-state frames touch zero PCIe readback bytes, flushing individual pages on demand inside `watch`'s vectored exception handler (`on_fault`) on first CPU read/write. - Supports both `MEM_MAPPED` physical views (atomic dual-view flush before restoring `PAGE_READWRITE`) and `MEM_PRIVATE | MEM_WRITE_WATCH` buffers (serialized via `FlushWait`), leaving unaligned/pinned/fence ranges eager. - Preserves DirectStorage / kernel `title_memory_written` partial-page complements, captures idempotent `FlushedBaseline` for in-flight relay/merge paths (`card_merge_relay`, `relay_merge`, `stale_under_writes`, `merge_under_writes`), and holds scoped `lazy_flush_and_hold` / `Remapping` barriers across remaps and host copies. - Maintains strict acyclic lock hierarchy (`Level 0: watch/Shadow -> Level 1: LAZY_TABLE -> Level 2: LAZY_GPU -> Level 3: FlushWait`). - **Tests & opt-in microbenchmark**: 11 `shadow::lazy_copyback_tests::lazy_copyback_*` unit and live-GPU coherence/stress/F1-F5 regression tests (scoped with `lazy_opted_in` test isolation so parallel non-lazy tests never inherit deferred state) + `#[ignore] bench_lazy_copyback`. ### Verification (`VICTORY_D3D12_DEBUG=1`) - `cargo test -p victory-gpu` (run 1 & run 2 parallel, plus serial `--test-threads=1`) -> all passed - `cargo test -p victory-gpu --all-features` -> passed - `cargo run -p xtask -- policy --staged` -> `asset policy: 3 files ok` (`host.rs` = 367,393 B, `watch.rs` = 81,104 B, `shadow.rs` = 345,266 B) Related: #51, #56, #57, #58
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:54:02 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/59/head:github-bot/gh-59'
git switch 'github-bot/gh-59'

Merge

Merge the changes and update on Forgejo.
git switch 'beta'
git merge --no-ff 'github-bot/gh-59'
git switch 'github-bot/gh-59'
git rebase 'beta'
git switch 'beta'
git merge --ff-only 'github-bot/gh-59'
git switch 'github-bot/gh-59'
git rebase 'beta'
git switch 'beta'
git merge --no-ff 'github-bot/gh-59'
git switch 'beta'
git merge --squash 'github-bot/gh-59'
git switch 'beta'
git merge --ff-only 'github-bot/gh-59'
git switch 'beta'
git merge 'github-bot/gh-59'
git push origin 'beta'
This discussion has been locked. Commenting is limited to contributors.
No description provided.