Opt-in ListPipelineManifest and BatchPrune refresh no-op pruning (VICTORY_LIST_MANIFEST, VICTORY_BATCH_PRUNE) #4795

Closed
github-bot wants to merge 1 commit from github-bot/gh-4794 into main AGit
Owner

@⁠lyufeng000 on GitHub · 2026-12-01 08:54 UTC · original
lyufeng000:pr/manifest-batch-prune → main · +3660 −42 · 7 files · 1 commits · closed without merging

What it changes

Adds two independent, opt-in (default-off) CPU submission-thread optimizations (crate::asked_for!; apps/victory/src/play.rs defaults untouched, zero extra locks/atomics when disabled):

  1. VICTORY_LIST_MANIFEST=1 (crates/victory-gpu/src/host/manifest.rs) — builds an immutable Arc<ListPipelineManifest> once per closed HostList (or right after take_coming() under VICTORY_COMING_AT_SUBMIT), guarded by a lock-free has_manifest: AtomicBool:

    • refresh_spans: whole-list per-shadow_id union for copy_spans, pending_refresh_spans, will_meet, place::read_by, and exact no-lock rejection in card_steps::copied_reads.
    • compact_touches: execution-order view coalescing contiguous pure-Refresh sub-runs while preserving exact step_index and barriers across Copy, Fill { is_slot }, Placed { has_from }, GpuWrite, Run, Host, Texture, and Plane.
    • Avoids repeated list.deferred() mutex acquisitions and step walks in blocked_with, joinable, declared_writes, refresh_front, refresh_ahead, run_deferred_manifest, card_steps::does_of, card_steps::cut_for, and place::forwards.
  2. VICTORY_BATCH_PRUNE=1 (crates/victory-gpu/src/host/batch_prune.rs, watch.rs, shadow.rs, host.rs) — persistent shadow_id-keyed 32-byte clean-interval cache across submissions (inside SPARE_BATCH) backed by opt-in lock-free 64 KiB page-stripe write epochs (watch::fine_range_epoch):

    • Opt-in fine watch epochs: gated behind TRACK_FINE_EPOCHS: AtomicBool (enable_fine_epochs()); uses 16,384 × 64 KiB slots (FINE_SHIFT = 0) for spans < 16 MiB and 64 × 64 MiB coarse shards for >= 16 MiB spans. GLOBAL_UNMAP_GEN bumps only on unsized frees whose extent cannot be resolved locally; ranged remaps, unmaps, splits, and protections invalidate only affected stripes + aliases.
    • Compact 32-byte CleanWatchEntry: zero heap allocation for single-range shadows (2 entries per cache line); disjoint multi-range shadows spill to extra_ranges capped at 12 intervals without bridging unchecked gaps.
    • Correctness invariants & compatibility:
      • Sample fine_range_epoch strictly before nothing_new_with and admit cold-clean spans (no hot-dirty re-probing after Self::update).
      • Write-watched (watched == 1) hits require watch::is_asked_or_owned(ahead_snap, lo, hi) (is_kept() && ahead_contains or owned); guarded views require live watch::is_published(lo, hi); pending GPU writes force a miss.
      • Precise invalidation: GpuWrite, Placed, and picked.written call invalidate_shadow(shadow_id); CPU Step::Copy and Step::Placed keep ask_once active and invalidate locally via watch::wrote(dst, len) (with !is_kept() fallback to bump_fine_range_with_aliases) instead of flushing the whole clean_cache; only opaque Step::Run (ask_once_end) clears the entire clean_cache and ahead_snap.
      • Coexists with PR #3762 (sift_spans_pruned / fused wide_each_scoped), PR #3818 (nothing_new_with range memo), VICTORY_CARD_ALL=1, VICTORY_UAV_FOLD=1, and host/lazy.rs.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090 24 GB, Ryzen 9 9950X, Windows 11; Series X profile, 4K, DLSS Quality (preset K), DLSS Frame Generation 2x, software ambient 0.8 (no HW RT), VICTORY_PLACED_COPIED=0.
  • Before (upstream e1251c31, VICTORY_PLACED_COPIED=0, 742s active FG-on gameplay):
    • Overall mean: 23.03 Base FPS (med 22.0), find_ask 0.44 ms, scanned 8,803 / wide 3,358 per frame, GPU idle behind sub 6.83 ms, Submit prep 29.28 ms (sub_work 44.02 ms).
    • Matched Dirty [800, 1050) bucket (296s): 23.1 Base FPS, prep 26.51 ms, refreshes 9.36 ms, wide 2,518, GPU idle behind sub 9.10 ms.
    • Matched Dirty [1050, 1300) bucket (220s): 22.3 Base FPS, prep 31.45 ms, refreshes 11.80 ms, wide 4,028, GPU idle behind sub 5.74 ms.
  • After (VICTORY_LIST_MANIFEST=1 VICTORY_BATCH_PRUNE=1, VICTORY_PLACED_COPIED=0, 1,224s active FG-on gameplay, 0 ERRORs, 0 crashes):
    • Overall mean: 23.62 Base FPS (med 23.0, +2.6% despite heavier scenes: GPU 33.01 ms vs 31.79 ms), find_ask 0.26 ms (-40.9%), scanned 6,733 (-23.5%) / wide 1,461 (-56.5%), GPU idle behind sub 4.60 ms (-32.7%), sub_work 42.84 ms (-1.18 ms).
    • Matched Dirty [800, 1050) bucket (479s): 24.8 Base FPS (+7.4%), prep 25.17 ms (-1.34 ms), refreshes 8.99 ms (-0.37 ms), wide 1,207 (-52.1%), GPU idle behind sub 5.42 ms (-40.4%).
    • Matched Dirty [1050, 1300) bucket (379s): 23.1 Base FPS (+3.6%), prep 30.62 ms (-0.83 ms), refreshes 11.43 ms (-0.37 ms), wide 1,498 (-62.8%), GPU idle behind sub 3.79 ms (-34.0%).
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes).
  • cargo test passed for the crates it touches: yes (rebased onto 5fabb46e, all 7 files verified):
    • cargo xtask policy --staged → asset policy: 7 files ok (exit 0)
    • cargo test -p victory-gpu --lib --locked -- host::manifest host::batch_prune host::refresh_tests watch::fine_epoch_tests host::card_steps host::place (default switches OFF) → 52 passed; 0 failed (6 ignored benchmarks/manual)
    • VICTORY_LIST_MANIFEST=1 VICTORY_BATCH_PRUNE=1 cargo test -p victory-gpu --lib --locked -- host::manifest host::batch_prune host::refresh_tests watch::fine_epoch_tests host::card_steps host::place → 52 passed; 0 failed (6 ignored)
    • cargo clippy -p victory-gpu --all-targets --locked and --all-features → 0 warnings in all 7 added/modified files (the 5 warnings in victory-gpu are pre-existing on 5fabb46e in host/font.rs, host/menu.rs, and host/panel.rs from PR #4635).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4775, #4533, #4490
    • Distinct & complementary to #4774 (VICTORY_FLUSH_FAST_NOOP, which caches ahead_snap and checks last_clean on a single owned_snap) and #4532 (caches watch::ahead snapshot by generation): this PR adds immutable dual-view HostList manifests (VICTORY_LIST_MANIFEST) plus a persistent shadow_id-keyed 32-byte clean_cache driven by opt-in lock-free 64 KiB fine_range_epoch write/remap/aliasing invalidation (VICTORY_BATCH_PRUNE) while keeping play.rs defaults unchanged.
**@⁠lyufeng000** on GitHub · 2026-12-01 08:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4794) `lyufeng000:pr/manifest-batch-prune` → `main` · +3660 −42 · 7 files · 1 commits · closed without merging ## What it changes Adds two independent, **opt-in (default-off)** CPU submission-thread optimizations (`crate::asked_for!`; `apps/victory/src/play.rs` defaults untouched, zero extra locks/atomics when disabled): 1. **`VICTORY_LIST_MANIFEST=1` (`crates/victory-gpu/src/host/manifest.rs`)** — builds an immutable `Arc<ListPipelineManifest>` once per closed `HostList` (or right after `take_coming()` under `VICTORY_COMING_AT_SUBMIT`), guarded by a lock-free `has_manifest: AtomicBool`: - `refresh_spans`: whole-list per-`shadow_id` union for `copy_spans`, `pending_refresh_spans`, `will_meet`, `place::read_by`, and exact no-lock rejection in `card_steps::copied_reads`. - `compact_touches`: execution-order view coalescing contiguous pure-`Refresh` sub-runs while preserving exact `step_index` and barriers across `Copy`, `Fill { is_slot }`, `Placed { has_from }`, `GpuWrite`, `Run`, `Host`, `Texture`, and `Plane`. - Avoids repeated `list.deferred()` mutex acquisitions and step walks in `blocked_with`, `joinable`, `declared_writes`, `refresh_front`, `refresh_ahead`, `run_deferred_manifest`, `card_steps::does_of`, `card_steps::cut_for`, and `place::forwards`. 2. **`VICTORY_BATCH_PRUNE=1` (`crates/victory-gpu/src/host/batch_prune.rs`, `watch.rs`, `shadow.rs`, `host.rs`)** — persistent `shadow_id`-keyed 32-byte clean-interval cache across submissions (inside `SPARE_BATCH`) backed by opt-in lock-free 64 KiB page-stripe write epochs (`watch::fine_range_epoch`): - **Opt-in fine watch epochs**: gated behind `TRACK_FINE_EPOCHS: AtomicBool` (`enable_fine_epochs()`); uses 16,384 × 64 KiB slots (`FINE_SHIFT = 0`) for spans `< 16 MiB` and 64 × 64 MiB coarse shards for `>= 16 MiB` spans. `GLOBAL_UNMAP_GEN` bumps only on unsized frees whose extent cannot be resolved locally; ranged remaps, unmaps, splits, and protections invalidate only affected stripes + aliases. - **Compact 32-byte `CleanWatchEntry`**: zero heap allocation for single-range shadows (2 entries per cache line); disjoint multi-range shadows spill to `extra_ranges` capped at 12 intervals without bridging unchecked gaps. - **Correctness invariants & compatibility**: - Sample `fine_range_epoch` strictly *before* `nothing_new_with` and admit cold-clean spans (no hot-dirty re-probing after `Self::update`). - Write-watched (`watched == 1`) hits require `watch::is_asked_or_owned(ahead_snap, lo, hi)` (`is_kept() && ahead_contains` or `owned`); guarded views require live `watch::is_published(lo, hi)`; pending GPU writes force a miss. - Precise invalidation: `GpuWrite`, `Placed`, and `picked.written` call `invalidate_shadow(shadow_id)`; CPU `Step::Copy` and `Step::Placed` keep `ask_once` active and invalidate locally via `watch::wrote(dst, len)` (with `!is_kept()` fallback to `bump_fine_range_with_aliases`) instead of flushing the whole `clean_cache`; only opaque `Step::Run` (`ask_once_end`) clears the entire `clean_cache` and `ahead_snap`. - Coexists with PR #3762 (`sift_spans_pruned` / fused `wide_each_scoped`), PR #3818 (`nothing_new_with` range memo), `VICTORY_CARD_ALL=1`, `VICTORY_UAV_FOLD=1`, and `host/lazy.rs`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090 24 GB, Ryzen 9 9950X, Windows 11; Series X profile, 4K, DLSS Quality (preset K), DLSS Frame Generation 2x, software ambient 0.8 (no HW RT), `VICTORY_PLACED_COPIED=0`. - Before (upstream `e1251c31`, `VICTORY_PLACED_COPIED=0`, 742s active FG-on gameplay): - Overall mean: `23.03` Base FPS (med `22.0`), `find_ask` `0.44 ms`, `scanned` `8,803` / `wide` `3,358` per frame, `GPU idle behind sub` `6.83 ms`, `Submit prep` `29.28 ms` (`sub_work` `44.02 ms`). - Matched `Dirty [800, 1050)` bucket (296s): `23.1` Base FPS, `prep` `26.51 ms`, `refreshes` `9.36 ms`, `wide` `2,518`, `GPU idle behind sub` `9.10 ms`. - Matched `Dirty [1050, 1300)` bucket (220s): `22.3` Base FPS, `prep` `31.45 ms`, `refreshes` `11.80 ms`, `wide` `4,028`, `GPU idle behind sub` `5.74 ms`. - After (`VICTORY_LIST_MANIFEST=1 VICTORY_BATCH_PRUNE=1`, `VICTORY_PLACED_COPIED=0`, 1,224s active FG-on gameplay, 0 ERRORs, 0 crashes): - Overall mean: `23.62` Base FPS (med `23.0`, +2.6% despite heavier scenes: GPU `33.01 ms` vs `31.79 ms`), `find_ask` `0.26 ms` (**-40.9%**), `scanned` `6,733` (**-23.5%**) / `wide` `1,461` (**-56.5%**), `GPU idle behind sub` `4.60 ms` (**-32.7%**), `sub_work` `42.84 ms` (**-1.18 ms**). - Matched `Dirty [800, 1050)` bucket (479s): `24.8` Base FPS (**+7.4%**), `prep` `25.17 ms` (**-1.34 ms**), `refreshes` `8.99 ms` (**-0.37 ms**), `wide` `1,207` (**-52.1%**), `GPU idle behind sub` `5.42 ms` (**-40.4%**). - Matched `Dirty [1050, 1300)` bucket (379s): `23.1` Base FPS (**+3.6%**), `prep` `30.62 ms` (**-0.83 ms**), `refreshes` `11.43 ms` (**-0.37 ms**), `wide` `1,498` (**-62.8%**), `GPU idle behind sub` `3.79 ms` (**-34.0%**). - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes). - `cargo test` passed for the crates it touches: yes (rebased onto `5fabb46e`, all 7 files verified): - `cargo xtask policy --staged` → `asset policy: 7 files ok` (exit 0) - `cargo test -p victory-gpu --lib --locked -- host::manifest host::batch_prune host::refresh_tests watch::fine_epoch_tests host::card_steps host::place` (default switches OFF) → `52 passed; 0 failed` (6 ignored benchmarks/manual) - `VICTORY_LIST_MANIFEST=1 VICTORY_BATCH_PRUNE=1 cargo test -p victory-gpu --lib --locked -- host::manifest host::batch_prune host::refresh_tests watch::fine_epoch_tests host::card_steps host::place` → `52 passed; 0 failed` (6 ignored) - `cargo clippy -p victory-gpu --all-targets --locked` and `--all-features` → **0 warnings** in all 7 added/modified files (the 5 warnings in `victory-gpu` are pre-existing on `5fabb46e` in `host/font.rs`, `host/menu.rs`, and `host/panel.rs` from PR #4635). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4775, #4533, #4490 - Distinct & complementary to `#4774` (`VICTORY_FLUSH_FAST_NOOP`, which caches `ahead_snap` and checks `last_clean` on a single `owned_snap`) and `#4532` (caches `watch::ahead` snapshot by generation): this PR adds immutable dual-view `HostList` manifests (`VICTORY_LIST_MANIFEST`) plus a persistent `shadow_id`-keyed 32-byte `clean_cache` driven by opt-in lock-free 64 KiB `fine_range_epoch` write/remap/aliasing invalidation (`VICTORY_BATCH_PRUNE`) while keeping `play.rs` defaults unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 08:59:58 +00:00
github-bot closed this pull request 2026-12-01 18:36:32 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:32 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4794#issuecomment-7321099589) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4795
No description provided.