perf(gpu/host): default-on lazy card compare and hot-piece narrowing #327

Merged
Androtim merged 1 commit from upstream-pr/327 into main 2026-12-02 12:17:55 +00:00
Androtim commented 2026-12-02 11:43:35 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T11:43:35Z.


Summary

Adapts default-on lazy card-memory compares and hot-piece flight-write narrowing (crates/victory-gpu/src/host/lazy.rs, ported cleanly from upsidedownstack/VIctory-Performance @ ad20a7e / GPL-3.0, 100% title-neutral & repo-neutral) with =0 kill-switches:

  • Default-on lazy card compares (VICTORY_LAZY_COMPARE_MB=64, =0 disables): On card copies >= 64 MiB, each submission only compares 64 KiB pieces that were recently found written (hot > 0, decaying over VICTORY_LAZY_HOT=64 compares), pending pieces uploaded by CPU (hold_back + forced), and a bounded rolling sweep of VICTORY_LAZY_SWEEP=128 cold pieces (preserving mode = 2 hashes for compared pieces only).
  • Default-on hot-piece narrowing (VICTORY_LAZY_NARROW=1, =0 disables): Maintains Line::narrow / Line::blocking() so read-blocking and card_steps checks against large card copies only wait on hot pieces while keeping line.written intact for bottom-of-pipe value waits and CPU-merge refreshes.
  • File size headroom: Moves list_upload_pool_tests out of crates/victory-gpu/src/host.rs into crates/victory-gpu/src/host/list_upload_pool_tests.rs (keeping host.rs at 651,696 bytes, under the 655,360 byte policy cap).

Verification

  • Static & Unit Tests: cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (324 files ok), cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu lazy (5 passed), list_upload_pool_tests (9 passed), dual workspace clippy --all-targets --locked -- -D warnings (default & --features diagnostics), objdump -p (standard Windows DLLs only).
  • Paired Same-Path Plain---release A/B vs main (1dffebf, Series X + DLSS quality, RTX 4060 Ti 8 GB, 0 crashes/DRED):
    • 1440p (90s, 20 windows): Median FPS 14.2 -> 14.7 fps (+0.5 fps), Mean FPS 12.19 -> 13.21 fps (+1.02 fps), preparing 26.1 -> 24.6 ms (-1.5 ms; preparing_core_ms avg 34.22 -> 27.62 ms, -6.60 ms), copyback 12.0 -> 10.3 ms (-1.7 ms), card pieces compared ~8,864 -> ~3,267/frame (-63%), used_max 6384 -> 6336 MB.
    • 4K DLSS quality (90s, 18 windows): Card pieces compared ~8,520 -> ~2,692/frame (-68%), preparing 20.1 -> 18.65 ms (-1.45 ms; preparing_core_ms med 35.60 -> 28.40 ms, -7.20 ms), copyback 14.75 -> 12.8 ms (-1.95 ms), working_set_mb max 21,083 -> 19,958 MB (-1,125 MB), shared_mb med 5,792 -> 5,645 MB (-147 MB), median FPS 6.35 -> 6.3 fps (4K GPU-bound).
  • 1440p 90s --features diagnostics Visual Gate (diag-pr-lazy-1440p-90s): PASS (6/6 gates) — world_windows=18, max_draws=14788, crashes=0, used_max=6229 MB / budget_min=6684 MB, final_waiting=4478, mapped_rate=0.53 ms/s, pngs=24 lit=20/24 luma=100.08 near_black=0.06% edge_energy=7.89 magenta=0.0%; 2,722 lazy compares/frame vs 8,368 full. Inspected frame-4357.png, frame-4365.png, frame-4371.png — clean geometry, textures, reflections, lighting, and character rendering.
<!-- greyfinch-sync:Androtim/MiniVI:issue:5605698309 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/327). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T11:43:35Z. --- ### Summary Adapts default-on **lazy card-memory compares** and **hot-piece flight-write narrowing** (`crates/victory-gpu/src/host/lazy.rs`, ported cleanly from `upsidedownstack/VIctory-Performance @ ad20a7e` / GPL-3.0, 100% title-neutral & repo-neutral) with `=0` kill-switches: - **Default-on lazy card compares (`VICTORY_LAZY_COMPARE_MB=64`, `=0` disables):** On card copies >= 64 MiB, each submission only compares 64 KiB pieces that were recently found written (`hot > 0`, decaying over `VICTORY_LAZY_HOT=64` compares), pending pieces uploaded by CPU (`hold_back` + `forced`), and a bounded rolling sweep of `VICTORY_LAZY_SWEEP=128` cold pieces (preserving `mode = 2` hashes for compared pieces only). - **Default-on hot-piece narrowing (`VICTORY_LAZY_NARROW=1`, `=0` disables):** Maintains `Line::narrow` / `Line::blocking()` so read-blocking and `card_steps` checks against large card copies only wait on hot pieces while keeping `line.written` intact for bottom-of-pipe value waits and CPU-merge refreshes. - **File size headroom:** Moves `list_upload_pool_tests` out of `crates/victory-gpu/src/host.rs` into `crates/victory-gpu/src/host/list_upload_pool_tests.rs` (keeping `host.rs` at `651,696` bytes, under the `655,360` byte policy cap). ### Verification - **Static & Unit Tests:** `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`324 files ok`), `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu lazy` (`5 passed`), `list_upload_pool_tests` (`9 passed`), dual workspace `clippy --all-targets --locked -- -D warnings` (default & `--features diagnostics`), `objdump -p` (standard Windows DLLs only). - **Paired Same-Path Plain-`--release` A/B vs `main` (`1dffebf`, Series X + DLSS quality, RTX 4060 Ti 8 GB, 0 crashes/DRED):** - **1440p (90s, 20 windows):** Median FPS `14.2 -> 14.7 fps` (`+0.5 fps`), Mean FPS `12.19 -> 13.21 fps` (`+1.02 fps`), `preparing` `26.1 -> 24.6 ms` (`-1.5 ms`; `preparing_core_ms avg` `34.22 -> 27.62 ms`, `-6.60 ms`), `copyback` `12.0 -> 10.3 ms` (`-1.7 ms`), card pieces compared `~8,864 -> ~3,267/frame` (`-63%`), `used_max` `6384 -> 6336 MB`. - **4K DLSS quality (90s, 18 windows):** Card pieces compared `~8,520 -> ~2,692/frame` (`-68%`), `preparing` `20.1 -> 18.65 ms` (`-1.45 ms`; `preparing_core_ms med` `35.60 -> 28.40 ms`, `-7.20 ms`), `copyback` `14.75 -> 12.8 ms` (`-1.95 ms`), `working_set_mb max` `21,083 -> 19,958 MB` (`-1,125 MB`), `shared_mb med` `5,792 -> 5,645 MB` (`-147 MB`), median FPS `6.35 -> 6.3 fps` (4K GPU-bound). - **1440p 90s `--features diagnostics` Visual Gate (`diag-pr-lazy-1440p-90s`):** **PASS (6/6 gates)** — `world_windows=18, max_draws=14788, crashes=0, used_max=6229 MB / budget_min=6684 MB, final_waiting=4478, mapped_rate=0.53 ms/s, pngs=24 lit=20/24 luma=100.08 near_black=0.06% edge_energy=7.89 magenta=0.0%`; `2,722` lazy compares/frame vs `8,368` full. Inspected `frame-4357.png`, `frame-4365.png`, `frame-4371.png` — clean geometry, textures, reflections, lighting, and character rendering.
Androtim commented 2026-12-02 11:49:00 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T11:49:00Z.


Autonomous architectural audit PASSED on 28fcbdf3 (allowlisted author Androtim):

  • Code review: Clean default-on lazy card compare (VICTORY_LAZY_COMPARE_MB=64, =0 disables) & hot-piece blocking narrowing (VICTORY_LAZY_NARROW=1, =0 disables) in crates/victory-gpu/src/host/lazy.rs + host.rs + card_steps.rs, preserving line.written for bottom-of-pipe/CPU-merge correctness and keeping host.rs below the policy cap (651,696 bytes).
  • Plain --release A/B (0 crashes / 0 DRED):
    • 1440p 90s: 14.2 -> 14.7 fps (+0.5 fps med, +1.02 fps mean), preparing 26.1 -> 24.6 ms (-1.5 ms; preparing_core_ms avg -6.60 ms), copyback 12.0 -> 10.3 ms (-1.7 ms), card pieces compared -63%, used_max 6,384 -> 6,336 MB (note: single-run final_waiting varied 3,672 -> 6,024 as faster streaming reached the 8 GB room=false boundary sooner, while 4K improved 12,975 -> 12,716 and diagnostics passed at 4,478).
    • 4K 90s: preparing 20.1 -> 18.65 ms (-1.45 ms; preparing_core_ms med -7.20 ms), copyback 14.75 -> 12.8 ms (-1.95 ms), card pieces compared -68%, working_set_mb max -1,125 MB, shared_mb med -147 MB, final_waiting 12,975 -> 12,716, 6.35 -> 6.3 fps (4K GPU-bound).
  • Diagnostics visual check (diag-pr-lazy-1440p-90s): All 6 gates PASS (luma=100.08, near_black=0.06%, edge_energy=7.89, magenta=0.0%); frame-4357.png and frame-4365.png inspected directly — crisp waterfront structures, reflections, foliage, sky, and HUD with zero visual regressions.

Status: Waiting on CI run 46874043020 (Clippy x2 green, Tests currently in progress). Will squash-merge automatically on the next cycle once green.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7344446324 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/327#issuecomment-7344446324). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T11:49:00Z. --- Autonomous architectural audit **PASSED** on `28fcbdf3` (allowlisted author `Androtim`): - **Code review:** Clean default-on lazy card compare (`VICTORY_LAZY_COMPARE_MB=64`, `=0` disables) & hot-piece blocking narrowing (`VICTORY_LAZY_NARROW=1`, `=0` disables) in `crates/victory-gpu/src/host/lazy.rs` + `host.rs` + `card_steps.rs`, preserving `line.written` for bottom-of-pipe/CPU-merge correctness and keeping `host.rs` below the policy cap (`651,696` bytes). - **Plain `--release` A/B (`0` crashes / `0` DRED):** - **1440p 90s:** `14.2 -> 14.7 fps` (`+0.5 fps` med, `+1.02 fps` mean), `preparing 26.1 -> 24.6 ms` (`-1.5 ms`; `preparing_core_ms avg -6.60 ms`), `copyback 12.0 -> 10.3 ms` (`-1.7 ms`), card pieces compared `-63%`, `used_max 6,384 -> 6,336 MB` *(note: single-run `final_waiting` varied `3,672 -> 6,024` as faster streaming reached the 8 GB `room=false` boundary sooner, while 4K improved `12,975 -> 12,716` and diagnostics passed at `4,478`)*. - **4K 90s:** `preparing 20.1 -> 18.65 ms` (`-1.45 ms`; `preparing_core_ms med -7.20 ms`), `copyback 14.75 -> 12.8 ms` (`-1.95 ms`), card pieces compared `-68%`, `working_set_mb max -1,125 MB`, `shared_mb med -147 MB`, `final_waiting 12,975 -> 12,716`, `6.35 -> 6.3 fps` (4K GPU-bound). - **Diagnostics visual check (`diag-pr-lazy-1440p-90s`):** All 6 gates PASS (`luma=100.08`, `near_black=0.06%`, `edge_energy=7.89`, `magenta=0.0%`); `frame-4357.png` and `frame-4365.png` inspected directly — crisp waterfront structures, reflections, foliage, sky, and HUD with zero visual regressions. **Status:** Waiting on CI run `46874043020` (`Clippy` x2 green, `Tests` currently in progress). Will squash-merge automatically on the next cycle once green.
Androtim commented 2026-12-02 12:03:45 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T12:03:45Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Technical Review — PR #327

Summary: Adds default-on lazy card-memory compares (VICTORY_LAZY_COMPARE_MB=64, =0 disables) and hot-piece flight-write narrowing (VICTORY_LAZY_NARROW=1, =0 disables) in crates/victory-gpu/src/host/lazy.rs, wired into crates/victory-gpu/src/host.rs and crates/victory-gpu/src/host/card_steps.rs, and extracts list_upload_pool_tests into crates/victory-gpu/src/host/list_upload_pool_tests.rs to stay under the host.rs file-size cap. CI is passing and static/policy checks are clean.

What was verified

  • Lazy compare & hold_back correctness (host.rs, host/lazy.rs):
    • On copies >= min() (64 MiB default), lazy::hold_back excludes pending pieces from the post-upload hash pass (mode = 0) and marks them forced, while is_whole first-time uploads still hash all pieces.
    • lazy::select schedules hot/forced pieces for declared ranges, and lazy::sweep drains any remaining forced pieces plus up to VICTORY_LAZY_SWEEP (128) rolling pending pieces across both declared and _synced copies.
    • Both batched and non-batched compare paths use mode = 2 whenever (r.lazy || flown) && !r.picked, preserving existing hashes for skipped pieces and updating hashes only for compared pieces.
    • CardPlan::lazy_found filters on r.lazy && r.compared (safe if work.differs overflows) and is invoked in both the relay landing path and Host::card_back.
  • Hot-piece narrowing (host.rs, host/card_steps.rs):
    • Line::narrow is maintained alongside Line::written on submission (join_narrow), on partial settle/rebuild, and on full settle clear.
    • late_blocked, relay_wait, card_steps::cut_for, and card_steps blocking checks use Line::blocking(), while line.written remains intact for bottom-of-pipe value waits and CPU-merge refreshes.
    • Lock ordering is sound: lazy::STATES is a leaf mutex and never acquires LINE or CARD_WORK.
  • Test extraction (host/list_upload_pool_tests.rs): Verbatim move of existing unit tests out of host.rs.

Minor non-blocking notes

  • lazy::STATES is keyed by shadow.id() and entries are not evicted on Shadow drop; negligible for a handful of long-lived >= 64 MiB copies, though worth keeping in mind if a title churns large shadow allocations.
  • mb << 20 in lazy::min() could use saturating_mul(1 << 20) to avoid shift overflow on extreme env values.

Verdict: needs-gpu-test

Logic, kill-switches, and CI look solid, with no blocking issues found. Because this changes default-on D3D12 host GPU compare and flight-write synchronization behavior (VICTORY_LAZY_COMPARE_MB=64, VICTORY_LAZY_NARROW=1), a local real-GPU smoke test is warranted before merging.

(Automated technical triage review — not formal maintainer approval.)


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7344787157 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/327#issuecomment-7344787157). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T12:03:45Z. --- <!-- minivi-triage v1 head=28fcbdf331d39d8d03eef542691741cbb8d5aca5 verdict=needs-gpu-test ci=passing at=2026-12-02T12:04:17Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Technical Review — PR #327 **Summary:** Adds default-on lazy card-memory compares (`VICTORY_LAZY_COMPARE_MB=64`, `=0` disables) and hot-piece flight-write narrowing (`VICTORY_LAZY_NARROW=1`, `=0` disables) in `crates/victory-gpu/src/host/lazy.rs`, wired into `crates/victory-gpu/src/host.rs` and `crates/victory-gpu/src/host/card_steps.rs`, and extracts `list_upload_pool_tests` into `crates/victory-gpu/src/host/list_upload_pool_tests.rs` to stay under the `host.rs` file-size cap. CI is passing and static/policy checks are clean. #### What was verified - **Lazy compare & `hold_back` correctness (`host.rs`, `host/lazy.rs`):** - On copies `>= min()` (`64 MiB` default), `lazy::hold_back` excludes `pending` pieces from the post-upload hash pass (`mode = 0`) and marks them `forced`, while `is_whole` first-time uploads still hash all pieces. - `lazy::select` schedules hot/forced pieces for declared ranges, and `lazy::sweep` drains any remaining forced pieces plus up to `VICTORY_LAZY_SWEEP` (`128`) rolling pending pieces across both declared and `_synced` copies. - Both batched and non-batched compare paths use `mode = 2` whenever `(r.lazy || flown) && !r.picked`, preserving existing hashes for skipped pieces and updating hashes only for compared pieces. - `CardPlan::lazy_found` filters on `r.lazy && r.compared` (safe if `work.differs` overflows) and is invoked in both the relay landing path and `Host::card_back`. - **Hot-piece narrowing (`host.rs`, `host/card_steps.rs`):** - `Line::narrow` is maintained alongside `Line::written` on submission (`join_narrow`), on partial settle/rebuild, and on full settle clear. - `late_blocked`, `relay_wait`, `card_steps::cut_for`, and `card_steps` blocking checks use `Line::blocking()`, while `line.written` remains intact for bottom-of-pipe value waits and CPU-merge refreshes. - Lock ordering is sound: `lazy::STATES` is a leaf mutex and never acquires `LINE` or `CARD_WORK`. - **Test extraction (`host/list_upload_pool_tests.rs`):** Verbatim move of existing unit tests out of `host.rs`. #### Minor non-blocking notes - `lazy::STATES` is keyed by `shadow.id()` and entries are not evicted on `Shadow` drop; negligible for a handful of long-lived `>= 64 MiB` copies, though worth keeping in mind if a title churns large shadow allocations. - `mb << 20` in `lazy::min()` could use `saturating_mul(1 << 20)` to avoid shift overflow on extreme env values. #### Verdict: `needs-gpu-test` Logic, kill-switches, and CI look solid, with no blocking issues found. Because this changes default-on D3D12 host GPU compare and flight-write synchronization behavior (`VICTORY_LAZY_COMPARE_MB=64`, `VICTORY_LAZY_NARROW=1`), a local real-GPU smoke test is warranted before merging. *(Automated technical triage review — not formal maintainer approval.)* --- _Generated with Antigravity CLI (`agy`)._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Androtim/MiniVI!327
No description provided.