perf(gpu): reuse closed command lists’ wide refresh summaries #308

Open
github-bot wants to merge 9 commits from github-bot/gh-308 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-03 10:21 UTC · original
tommiehansen:perf/t07-record-refresh-front → main · +810 −68 · 5 files · 9 commits · open

Why

Wide submissions repeatedly walk closed deferred streams and schedule planner worker jobs even for reused command lists. The earlier 3–6 ms trace covers the entire refresh-front operation, not just this work.

What changes

With VICTORY_RECORD_REFRESH_FRONT=1, build ListFront at close after async splicing, retain mutation-generation keyed summaries, invalidate on every mutation/reset, and fold/deduplicate in submission order. Narrow, changed and unprepared lists use original fallback; off uses original algorithm.

Benchmark results

Reproducible CI result · head 8904c820e8b8 · Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm).

Workload Baseline (ms) Candidate (ms) Time change Verification
Submission front plan 0.202 0.064 −68.22% Identical

Same head; VICTORY_RECORD_REFRESH_FRONT=0 → 1. Other CPU controls show no significant change; hardware workloads unsupported.

Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS.

Earlier 16-list ×512-step fixture, one recording and four submissions with partial miss: 100.416→31.250 µs (−69.00%, 95% CI −69.15 to −68.85%), scans 64→18 including close. A repeat at b88c697 measured 101.188→31.625 µs (−68.84%).

Why this should be merged

Strong scoped planner savings include recording and repeat submission cost. No frame-time promise; reuse frequency and metadata cost matter.

Validation

Two portable production folding/reuse/mutation tests, Windows all-targets with/without diagnostics on earlier revisions; current-head pinned audit. Report actual recording plus submission and exact rendering on a matched route.

Compatibility and dependencies

Independent opt-in; preserve alias/write/texture coverage, barriers and queue ordering. #528 is a separate repository-policy issue.

Previous detailed description, historical measurements and checklist.

**@⁠tommiehansen** on GitHub · 2026-12-03 10:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308) `tommiehansen:perf/t07-record-refresh-front` → `main` · +810 −68 · 5 files · 9 commits · open ## Why Wide submissions repeatedly walk closed deferred streams and schedule planner worker jobs even for reused command lists. The earlier 3–6 ms trace covers the entire refresh-front operation, not just this work. ## What changes With VICTORY_RECORD_REFRESH_FRONT=1, build ListFront at close after async splicing, retain mutation-generation keyed summaries, invalidate on every mutation/reset, and fold/deduplicate in submission order. Narrow, changed and unprepared lists use original fallback; off uses original algorithm. ## Benchmark results [Reproducible CI result](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47503640056/job/145622974572) · head `8904c820e8b8` · Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm). | Workload | Baseline (ms) | Candidate (ms) | Time change | Verification | |---|---:|---:|---:|---| | Submission front plan | 0.202 | 0.064 | **−68.22%** | Identical | Same head; `VICTORY_RECORD_REFRESH_FRONT=0` → `1`. Other CPU controls show no significant change; hardware workloads unsupported. Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS. Earlier 16-list ×512-step fixture, one recording and four submissions with partial miss: 100.416→31.250 µs (−69.00%, 95% CI −69.15 to −68.85%), scans 64→18 including close. A repeat at b88c697 measured 101.188→31.625 µs (−68.84%). ## Why this should be merged Strong scoped planner savings include recording and repeat submission cost. No frame-time promise; reuse frequency and metadata cost matter. ## Validation Two portable production folding/reuse/mutation tests, Windows all-targets with/without diagnostics on earlier revisions; [current-head pinned audit](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47466412636). Report actual recording plus submission and exact rendering on a matched route. ## Compatibility and dependencies Independent opt-in; preserve alias/write/texture coverage, barriers and queue ordering. #528 is a separate repository-policy issue. [Previous detailed description, historical measurements and checklist](https://github.com/tommiehansen/VIctory-xmem/blob/04dd44857abe222961157663b89a4dfed4c7277c/archive/pr-descriptions-20261206.md).
Fold the same copy intervals and texture staging references when a host list closes. Wide submissions with complete summaries can skip deferred-step walks and the worker-job fanout while preserving list order and the original folding algorithm.

Keep the original planner for incomplete summaries and leave the recording-time path disabled by default. Reset drops the summary, late steps invalidate it by length, and write invalidation and texture coverage decisions remain in the submission path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 10:25:27 +00:00
Preserve every original production-code hunk and integrate the switch documentation alongside the newly added upstream settings. No behavior changes beyond the existing PR.
Extract refresh-front planning into host/front_plan.rs with single-pass ListFront compaction (combining shadow lookup and span construction into one ByKey map and deduplicating per-list texture references), a single-map join_list_fronts with a zero-hash single-list fast path, shared empty-list sentinel caching, narrow all-cached reuse, and partial-cache wide reuse (rebuilding only uncached lists). Verified natively via front_plan differential tests and via cross-target Windows victory-gpu checks (standard and diagnostics).
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-03 19:25 UTC · original

Updated PR #308 (merged current main 45591b0 including #220/#330/#332 + commit cb9fd4d):

Improvements in cb9fd4d

  • Single-pass planner (crates/victory-gpu/src/host/front_plan.rs):
    • Replaced the two-hash-table list_front and three-hash-table join_fronts with single-pass build_list_front and join_list_fronts (one ByKey map per stage, Arc stored directly with its bounding span, zero-length refreshes skipped early without hashing/cloning, and a zero-hash-map fast path for single non-empty list joins). This also speeds up uncached wide submissions (VICTORY_RECORD_REFRESH_FRONT=0).
    • Deduplicates texture staging references per list (seen_textures + last-key shortcut) before refresh_fronts.
  • Cache coverage & allocation reductions (VICTORY_RECORD_REFRESH_FRONT=1):
    • Partial-hit wide reuse (resolve_fronts): If 15/16 lists have valid summaries and 1 is appended/spliced, only the missing list is rebuilt (inline when missing.len() == 1, or via wide_each over missing.len() when >= 2) instead of falling back to recomputing all lists.
    • Narrow / single-list reuse: Narrow and single-list submissions reuse valid cached fronts directly instead of building them at close and discarding them at submit.
    • Zero-allocation empty close: Empty lists share a OnceLock<Arc<ListFront>> sentinel instead of allocating a new Arc<ListFront> on every close.

No duplication of #220 (by-address prefix caching), #330 (VICTORY_PARTS_ONE_CALL), or #332 (VICTORY_KEEP_HOST_BUFFERS).

CPU Benchmark Results (Apple M5 macOS ARM64, rustc -O, A/B/B/A 8 blocks, exact parity verified)

Both Combined (close + submit) and Submit-Only CPU times were measured directly against the production front_plan code:

vs origin/main (No-cache baseline → Improved PR #308)

Scenario Baseline (µs) Candidate (µs) Change
Wide 16×512 Uncached (single-pass join/list) 92.32 63.44 -31.29%
Wide 16×512 1× submit (Combined: close + submit) 92.34 63.66 -31.06%
Wide 16×512 4× replay (Combined: 1 close + 4 submits) 367.92 100.00 -72.82%
Wide 16×512 Submit-Only (all cached) 91.79 11.97 -86.95%
Narrow 1×512 1× submit (Combined: close + submit) 5.65 4.33 -23.42%
Narrow 1×512 4× replay (Combined: 1 close + 4 submits) 22.59 8.75 -61.25%

vs Previous PR #308 (3ab6d57 → Improved PR #308)

Scenario Old #308 (µs) New #308 (µs) Change
Wide 16×512 Submit-Only (all cached) 21.15 11.83 -44.05%
Wide 16×512 Submit-Only (15/16 hit, 1 miss) 91.61 15.11 -83.51%
Narrow 1×512 Submit-Only (cached) 5.62 1.20 -78.68%
Empty list close ×64 (shared EMPTY_FRONT) 0.61 0.47 -23.08%

Verification & Limitations

  • Native macOS ARM64 unit & randomized differential tests on production crates/victory-gpu/src/host/front_plan.rs (rustc --edition 2024 --test crates/victory-gpu/src/host/front_plan.rs): 2 passed, 0 failed.
  • Full cross-target cargo check -p victory-gpu --all-targets --target x86_64-pc-windows-msvc (using check-only libmimalloc-sys shim + blake3/pure), both standard and --features diagnostics: passed with 0 errors and 0 warnings.
  • cargo --offline xtask policy --staged: asset policy: 2 files ok.
  • Limitations: Synthetic CPU planning microbenchmarks on Apple M5 macOS ARM64 (host.rs submission execution, GPU copy refreshes, RADV/Wine execution, and gameplay frame times require external Windows/Linux AMD GPU hardware).
**@⁠tommiehansen** on GitHub · 2026-12-03 19:25 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7389686024) Updated PR #308 (merged current `main` `45591b0` including #220/#330/#332 + commit `cb9fd4d`): ### Improvements in `cb9fd4d` - **Single-pass planner (`crates/victory-gpu/src/host/front_plan.rs`):** - Replaced the two-hash-table `list_front` and three-hash-table `join_fronts` with single-pass `build_list_front` and `join_list_fronts` (one `ByKey` map per stage, `Arc` stored directly with its bounding span, zero-length refreshes skipped early without hashing/cloning, and a zero-hash-map fast path for single non-empty list joins). This also speeds up uncached wide submissions (`VICTORY_RECORD_REFRESH_FRONT=0`). - Deduplicates texture staging references per list (`seen_textures` + last-key shortcut) before `refresh_fronts`. - **Cache coverage & allocation reductions (`VICTORY_RECORD_REFRESH_FRONT=1`):** - **Partial-hit wide reuse (`resolve_fronts`):** If 15/16 lists have valid summaries and 1 is appended/spliced, only the missing list is rebuilt (inline when `missing.len() == 1`, or via `wide_each` over `missing.len()` when `>= 2`) instead of falling back to recomputing all lists. - **Narrow / single-list reuse:** Narrow and single-list submissions reuse valid cached fronts directly instead of building them at close and discarding them at submit. - **Zero-allocation empty close:** Empty lists share a `OnceLock<Arc<ListFront>>` sentinel instead of allocating a new `Arc<ListFront>` on every close. No duplication of #220 (by-address prefix caching), #330 (`VICTORY_PARTS_ONE_CALL`), or #332 (`VICTORY_KEEP_HOST_BUFFERS`). ### CPU Benchmark Results (Apple M5 macOS ARM64, `rustc -O`, A/B/B/A 8 blocks, exact parity verified) Both **Combined (close + submit)** and **Submit-Only** CPU times were measured directly against the production `front_plan` code: #### vs `origin/main` (No-cache baseline → Improved PR #308) | Scenario | Baseline (µs) | Candidate (µs) | Change | |---|---:|---:|---:| | Wide 16×512 Uncached (single-pass join/list) | 92.32 | 63.44 | **-31.29%** | | Wide 16×512 1× submit (Combined: close + submit) | 92.34 | 63.66 | **-31.06%** | | Wide 16×512 4× replay (Combined: 1 close + 4 submits) | 367.92 | 100.00 | **-72.82%** | | Wide 16×512 Submit-Only (all cached) | 91.79 | 11.97 | **-86.95%** | | Narrow 1×512 1× submit (Combined: close + submit) | 5.65 | 4.33 | **-23.42%** | | Narrow 1×512 4× replay (Combined: 1 close + 4 submits) | 22.59 | 8.75 | **-61.25%** | #### vs Previous PR #308 (`3ab6d57` → Improved PR #308) | Scenario | Old #308 (µs) | New #308 (µs) | Change | |---|---:|---:|---:| | Wide 16×512 Submit-Only (all cached) | 21.15 | 11.83 | **-44.05%** | | Wide 16×512 Submit-Only (15/16 hit, 1 miss) | 91.61 | 15.11 | **-83.51%** | | Narrow 1×512 Submit-Only (cached) | 5.62 | 1.20 | **-78.68%** | | Empty list close ×64 (shared `EMPTY_FRONT`) | 0.61 | 0.47 | **-23.08%** | ### Verification & Limitations - Native macOS ARM64 unit & randomized differential tests on production `crates/victory-gpu/src/host/front_plan.rs` (`rustc --edition 2024 --test crates/victory-gpu/src/host/front_plan.rs`): **2 passed, 0 failed**. - Full cross-target `cargo check -p victory-gpu --all-targets --target x86_64-pc-windows-msvc` (using check-only `libmimalloc-sys` shim + `blake3/pure`), both standard and `--features diagnostics`: **passed with 0 errors and 0 warnings**. - `cargo --offline xtask policy --staged`: **asset policy: 2 files ok**. - **Limitations:** Synthetic CPU planning microbenchmarks on Apple M5 macOS ARM64 (`host.rs` submission execution, GPU copy refreshes, RADV/Wine execution, and gameplay frame times require external Windows/Linux AMD GPU hardware).
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-03 19:37 UTC · original

Tested cb9fd4d natively on Windows 11 with MSVC and toolchain 1.98.1, building only victory-gpu. The D3D12 host tests in the suite ran on one NVIDIA desktop card.

One real problem first. host::front_spans_tests::a_changed_or_reused_list_cannot_share_its_previous_front fails every time on this head (0/20 in debug and in release, switch on or off). It panics at host.rs:6913 on !Arc::ptr_eq(&first, ...). The list in that test only has Copy/Fill steps, so its front is empty, and since cb9fd4d every empty front is the shared empty_list_front() Arc, so both summaries are the same pointer. The production code is fine here, it's the test that needs a Refresh step (or a check that doesn't rely on pointer identity). The standalone rustc run of front_plan.rs wouldn't have caught it because this test lives in host.rs.

On staleness, the per-list check is the same as before. Each list is either served from a summary whose step count still matches or rebuilt from its current steps (resolve_fronts), and narrow submissions only take the summary path when every list has a valid one, otherwise they use the inline loop as on main. Across the crate, steps are only written while recording, by the take_coming splice (which close() runs before prepare_refresh_front()), or by the in-place Copy merge, which the planner ignores. Submission only reads them and reset() replaces the whole Deferred. So partial and narrow reuse don't add a new way to get a stale front, as long as nothing starts rewriting Refresh or Texture steps in place after close.

I also compared the new single-pass planner against main's list_front + join_fronts + front_spans with a local randomized test (not pushed, up to 16 lists of 200 steps, 20,000 rounds). Without zero-length refreshes the spans and their order come out identical, and textures match once you account for texture_due already deduping per submission. With zero-length refreshes they differ, because main still widened a copy's span to include a zero-length point and the new code skips it. For example (c, 50, 0), (c, 10, 20) gives (10, 50) on main and (10, 30) here, and a copy touched only by zero-length refreshes at different addresses is dropped entirely. Every non-empty requested range is still covered, so this only refreshes less, but it means the wide path with the switch off isn't strictly the same as main. Nothing in defer_refresh rules out a zero-length refresh, though I didn't confirm one actually occurs in practice.

Results otherwise. Both front_plan tests passed 20/20 in debug and release with the switch off and on. The full lib suite with --test-threads=4, skipping descriptor::tests::views_die_with_their_resource, gave 331 passed, 6 failed and 23 ignored with the switch off and the same with it on. main at 00aa4d3 gave 338 passed, 5 failed and 23 ignored. The extra failure is the test above, and the other five also fail on main (watch::tests::the_rest_of_the_one_asking_has_a_number_of_its_own is intermittent there too). Clippy with --all-targets shows the same warnings as main. No existing test drives a real wide submission end to end, and nothing was run with game data.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-03 19:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7389993422) Tested cb9fd4d natively on Windows 11 with MSVC and toolchain 1.98.1, building only victory-gpu. The D3D12 host tests in the suite ran on one NVIDIA desktop card. One real problem first. `host::front_spans_tests::a_changed_or_reused_list_cannot_share_its_previous_front` fails every time on this head (0/20 in debug and in release, switch on or off). It panics at host.rs:6913 on `!Arc::ptr_eq(&first, ...)`. The list in that test only has `Copy`/`Fill` steps, so its front is empty, and since cb9fd4d every empty front is the shared `empty_list_front()` Arc, so both summaries are the same pointer. The production code is fine here, it's the test that needs a `Refresh` step (or a check that doesn't rely on pointer identity). The standalone rustc run of front_plan.rs wouldn't have caught it because this test lives in host.rs. On staleness, the per-list check is the same as before. Each list is either served from a summary whose step count still matches or rebuilt from its current steps (`resolve_fronts`), and narrow submissions only take the summary path when every list has a valid one, otherwise they use the inline loop as on main. Across the crate, steps are only written while recording, by the `take_coming` splice (which `close()` runs before `prepare_refresh_front()`), or by the in-place `Copy` merge, which the planner ignores. Submission only reads them and `reset()` replaces the whole `Deferred`. So partial and narrow reuse don't add a new way to get a stale front, as long as nothing starts rewriting `Refresh` or `Texture` steps in place after close. I also compared the new single-pass planner against main's `list_front` + `join_fronts` + `front_spans` with a local randomized test (not pushed, up to 16 lists of 200 steps, 20,000 rounds). Without zero-length refreshes the spans and their order come out identical, and textures match once you account for `texture_due` already deduping per submission. With zero-length refreshes they differ, because main still widened a copy's span to include a zero-length point and the new code skips it. For example `(c, 50, 0), (c, 10, 20)` gives `(10, 50)` on main and `(10, 30)` here, and a copy touched only by zero-length refreshes at different addresses is dropped entirely. Every non-empty requested range is still covered, so this only refreshes less, but it means the wide path with the switch off isn't strictly the same as main. Nothing in `defer_refresh` rules out a zero-length refresh, though I didn't confirm one actually occurs in practice. Results otherwise. Both front_plan tests passed 20/20 in debug and release with the switch off and on. The full lib suite with `--test-threads=4`, skipping `descriptor::tests::views_die_with_their_resource`, gave 331 passed, 6 failed and 23 ignored with the switch off and the same with it on. main at 00aa4d3 gave 338 passed, 5 failed and 23 ignored. The extra failure is the test above, and the other five also fail on main (`watch::tests::the_rest_of_the_one_asking_has_a_number_of_its_own` is intermittent there too). Clippy with `--all-targets` shows the same warnings as main. No existing test drives a real wide submission end to end, and nothing was run with game data. AI-assisted: yes
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-03 20:03 UTC · original

Thanks for the native Windows 11 test report and 20,000-round differential check, @⁠Kal0s-design! Both findings are fixed in ad0d01a:

  1. host::front_spans_tests::a_changed_or_reused_list_cannot_share_its_previous_front:
    • Updated the host.rs test after splice to verify invalidation (is_none()) followed by empty-front pointer sharing (second.is_empty() && Arc::ptr_eq(&first, &second)).
    • Added front_plan::tests::non_empty_changed_list_allocates_distinct_front_arc to verify that changing a non-empty list invalidates its cache and allocates a distinct Arc<ListFront> (!Arc::ptr_eq).
  2. Exact zero-length refresh parity (VICTORY_RECORD_REFRESH_FRONT=0 and =1):
    • Removed the early len == 0 skip in build_list_front so zero-length points participate in per-copy min(from) / max(to) merging within and across lists identically to origin/main's list_front + front_spans, while filtering from < to in join_list_fronts (single-list fast path and multi-list retain).
    • Updated reference_plan and added front_plan::tests::zero_length_refreshes_match_main_front_spans_semantics + 256-round randomized differential testing covering both single-list and multi-list zero-length refreshes.

Verification:

  • rustc --edition 2024 --test crates/victory-gpu/src/host/front_plan.rs: 4 passed, 0 failed (0 warnings).
  • Cross-target cargo check -p victory-gpu --lib and --all-targets --features diagnostics (x86_64-pc-windows-msvc): 0 errors, 0 warnings; cargo --offline xtask policy --staged passed (2 files ok).
  • Note: Native Windows execution of host::front_spans_tests could not run on macOS ARM64; only cross-target compilation and native front_plan.rs tests ran here.
**@⁠tommiehansen** on GitHub · 2026-12-03 20:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7390641291) Thanks for the native Windows 11 test report and 20,000-round differential check, @⁠Kal0s-design! Both findings are fixed in `ad0d01a`: 1. **`host::front_spans_tests::a_changed_or_reused_list_cannot_share_its_previous_front`:** - Updated the `host.rs` test after `splice` to verify invalidation (`is_none()`) followed by empty-front pointer sharing (`second.is_empty() && Arc::ptr_eq(&first, &second)`). - Added `front_plan::tests::non_empty_changed_list_allocates_distinct_front_arc` to verify that changing a non-empty list invalidates its cache and allocates a distinct `Arc<ListFront>` (`!Arc::ptr_eq`). 2. **Exact zero-length refresh parity (`VICTORY_RECORD_REFRESH_FRONT=0` and `=1`):** - Removed the early `len == 0` skip in `build_list_front` so zero-length points participate in per-copy `min(from)` / `max(to)` merging within and across lists identically to `origin/main`'s `list_front` + `front_spans`, while filtering `from < to` in `join_list_fronts` (single-list fast path and multi-list `retain`). - Updated `reference_plan` and added `front_plan::tests::zero_length_refreshes_match_main_front_spans_semantics` + 256-round randomized differential testing covering both single-list and multi-list zero-length refreshes. **Verification:** - `rustc --edition 2024 --test crates/victory-gpu/src/host/front_plan.rs`: **4 passed, 0 failed** (0 warnings). - Cross-target `cargo check -p victory-gpu --lib` and `--all-targets --features diagnostics` (`x86_64-pc-windows-msvc`): **0 errors, 0 warnings**; `cargo --offline xtask policy --staged` passed (2 files ok). - **Note:** Native Windows execution of `host::front_spans_tests` could not run on macOS ARM64; only cross-target compilation and native `front_plan.rs` tests ran here.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-03 20:32 UTC · original

Reran on ad0d01a.

The cache test passes 20/20 in debug and release, with VICTORY_RECORD_REFRESH_FRONT unset and set to 1. It isn't passing trivially. I tried a local mutation where CachedFront::get ignores the step count, and it then fails at the is_none() after the splice (so does non_empty_changed_list_allocates_distinct_front_arc). The name reads a little odd now that it asserts the two empty fronts do share, but that's cosmetic.

The two single-list cases from my last comment are fixed. (c,50,0),(c,10,20) now gives (10,50), and a copy touched only by zero-length refreshes at 100 and 300 comes out as (100,300) instead of disappearing. I ran a throwaway local differential (not pushed) with 1 to 16 lists of up to 200 steps, around 12% of steps zero-length, plus duplicates, touching ranges, textures and partly cached lists going through resolve_fronts. Over 20,000 rounds the new planner matches main's inline path (front_spans over all touches) exactly on spans, order and textures. A 200,000 round run also showed no differences.

Against main's wide path (list_front then join_fronts) it still differs in 8830 of 20,000 rounds, and only in rounds that have zero-length refreshes. Main's per-list front_spans drops zero-length points before the join, so it loses them when they sit in a different list from the real refresh. Your own multi case in zero_length_refreshes_match_main_front_spans_semantics shows it. On main's wide path that input gives [(1,10,30)], not [(1,10,50),(3,10,50)], so the "mirrors origin/main's list_front" comment only holds for one list. With the switch unset the new planner only runs for wide submissions, which is exactly where main used list_front/join_fronts, so this is a behaviour change by default. In every differing round I checked, the new spans contain main's wide spans (about 477k spans checked, none narrower). Main's inline path already behaves this way, so it might be fine. I just think it's worth saying in the description or having a maintainer decide which one is intended.

Full cargo test -p victory-gpu --lib (skipping views_die_with_their_resource) gives 334 passed, 5 failed, 23 ignored with the switch unset and set to 1, and the 5 failures are the same ones main has. Main shows 338 passed only because the branch adds 5 tests and is missing 9 newer ones from main. It merges cleanly. Clippy on -p victory-gpu --all-targets shows the same warnings as main, none new.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-03 20:32 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7391385010) Reran on ad0d01a. The cache test passes 20/20 in debug and release, with `VICTORY_RECORD_REFRESH_FRONT` unset and set to 1. It isn't passing trivially. I tried a local mutation where `CachedFront::get` ignores the step count, and it then fails at the `is_none()` after the splice (so does `non_empty_changed_list_allocates_distinct_front_arc`). The name reads a little odd now that it asserts the two empty fronts do share, but that's cosmetic. The two single-list cases from my last comment are fixed. `(c,50,0),(c,10,20)` now gives `(10,50)`, and a copy touched only by zero-length refreshes at 100 and 300 comes out as `(100,300)` instead of disappearing. I ran a throwaway local differential (not pushed) with 1 to 16 lists of up to 200 steps, around 12% of steps zero-length, plus duplicates, touching ranges, textures and partly cached lists going through `resolve_fronts`. Over 20,000 rounds the new planner matches main's inline path (`front_spans` over all touches) exactly on spans, order and textures. A 200,000 round run also showed no differences. Against main's wide path (`list_front` then `join_fronts`) it still differs in 8830 of 20,000 rounds, and only in rounds that have zero-length refreshes. Main's per-list `front_spans` drops zero-length points before the join, so it loses them when they sit in a different list from the real refresh. Your own `multi` case in `zero_length_refreshes_match_main_front_spans_semantics` shows it. On main's wide path that input gives `[(1,10,30)]`, not `[(1,10,50),(3,10,50)]`, so the "mirrors origin/main's list_front" comment only holds for one list. With the switch unset the new planner only runs for wide submissions, which is exactly where main used `list_front`/`join_fronts`, so this is a behaviour change by default. In every differing round I checked, the new spans contain main's wide spans (about 477k spans checked, none narrower). Main's inline path already behaves this way, so it might be fine. I just think it's worth saying in the description or having a maintainer decide which one is intended. Full `cargo test -p victory-gpu --lib` (skipping `views_die_with_their_resource`) gives 334 passed, 5 failed, 23 ignored with the switch unset and set to 1, and the 5 failures are the same ones main has. Main shows 338 passed only because the branch adds 5 tests and is missing 9 newer ones from main. It merges cleanly. Clippy on `-p victory-gpu --all-targets` shows the same warnings as main, none new. AI-assisted: yes
Match the upstream wide path by dropping point spans after each list’s fold and before joining across lists. Cached narrow submissions retain the inline path’s global fold. Cover the two semantics with the reviewer’s multi-list case and a randomized differential oracle.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-03 21:20 UTC · original

Reran everything on 6959e16.

The wide/narrow split fixes the gap I reported. I ran the same differential harness locally with the new planner on each path separately, comparing it to main's code for that path. It is not part of the PR. Each run used 200k random submissions. They had 1 to 16 lists, zero-length refreshes in both the same list and a different list from the real refresh, repeated steps, touching ranges, and textures.

  • wide, with fronts built fresh or partly taken from the cache through resolve_fronts: new join vs main's list_front + join_fronts, 0 differences. In 97,970 of those rounds main's two paths disagree with each other, so the cross-list zero-length case got plenty of coverage.
  • narrow with every list cached (switch=1): new narrow join vs main's inline front_spans, 0 differences.
  • narrow with any list uncached: returns to the inline path, whose code is unchanged from main.

The single cases match main too. (c,50,0),(c,10,20) in one list gives (10,50) on both paths. Your multi case gives [(1,10,30)] wide and [(1,10,50),(3,10,50)] narrow, same as main for each. A copy touched only by zero-length refreshes at 100 and 300 keeps (100,300) when they are in the same list as other refreshes. When they sit in separate lists it is dropped on the wide path, as on main.

The front_plan and front_spans tests passed 20/20 in debug and release, with the switch both unset and =1. The full victory-gpu lib suite (one known descriptor test skipped) has the same failing tests as main in both switch states. Nothing new. Clippy for victory-gpu shows no new warnings compared to main.

On caching, the cached fronts still keep the zero-length points, and they are only dropped when the lists are joined. So one cached entry works for either join, and the staleness reasoning from last time still holds.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-03 21:20 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7392651586) Reran everything on 6959e16. The wide/narrow split fixes the gap I reported. I ran the same differential harness locally with the new planner on each path separately, comparing it to main's code for that path. It is not part of the PR. Each run used 200k random submissions. They had 1 to 16 lists, zero-length refreshes in both the same list and a different list from the real refresh, repeated steps, touching ranges, and textures. - wide, with fronts built fresh or partly taken from the cache through resolve_fronts: new join vs main's list_front + join_fronts, 0 differences. In 97,970 of those rounds main's two paths disagree with each other, so the cross-list zero-length case got plenty of coverage. - narrow with every list cached (switch=1): new narrow join vs main's inline front_spans, 0 differences. - narrow with any list uncached: returns to the inline path, whose code is unchanged from main. The single cases match main too. (c,50,0),(c,10,20) in one list gives (10,50) on both paths. Your `multi` case gives [(1,10,30)] wide and [(1,10,50),(3,10,50)] narrow, same as main for each. A copy touched only by zero-length refreshes at 100 and 300 keeps (100,300) when they are in the same list as other refreshes. When they sit in separate lists it is dropped on the wide path, as on main. The front_plan and front_spans tests passed 20/20 in debug and release, with the switch both unset and =1. The full victory-gpu lib suite (one known descriptor test skipped) has the same failing tests as main in both switch states. Nothing new. Clippy for victory-gpu shows no new warnings compared to main. On caching, the cached fronts still keep the zero-length points, and they are only dropped when the lists are joined. So one cached entry works for either join, and the staleness reasoning from last time still holds. AI-assisted: yes
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 00:03 UTC · original

Thanks @⁠Kal0s-design for testing 6959e16 natively and verifying both the wide and narrow paths across the 200k random differential checks and 20/20 tests.

**@⁠tommiehansen** on GitHub · 2026-12-04 00:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7396328266) Thanks @⁠Kal0s-design for testing `6959e16` natively and verifying both the wide and narrow paths across the 200k random differential checks and 20/20 tests.
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:09 UTC · original

The extraction into front_plan.rs with a randomized differential oracle against the old planner is exactly how this should be done. Three things keep it from being a yes today.

  1. The cache key is a length. crates/victory-gpu/src/host/front_plan.rs:94 is (*recorded_steps == steps).then(...), so correctness rests on an unwritten invariant: a list's copies may only grow between reset and submission. Worse, the test at crates/victory-gpu/src/host.rs:6906 documents the opposite — it mutates deferred.copies[0] in place and asserts the stale front is still returned. It is safe only because that slot happens to hold a Copy and not a Refresh; the next person who splices a Refresh in place gets a wrong span and a wrong upload. Key the cache on a generation counter bumped on mutation, not on a count.
  2. Off by default, but rewrites the hot path. crates/victory-gpu/src/host.rs:6838 gates the cache on VICTORY_RECORD_REFRESH_FRONT=1, yet with it unset you still replace the hot path with the new resolve_fronts/join_fronts split. So the default path is unchanged-but-different for no measured gain. Say that in the body, or keep the old path when the switch is off.
  3. No number. Four commit messages say "verified natively" and "differential tests", none says a frame time. For a PR whose subject is "less submit-time work", that is the one missing piece.

Also: VICTORY_RECORD_REFRESH_FRONT is in docs/SETTINGS.md:33 but not in run.conf.default, where VICTORY_LATE_FENCE and VICTORY_BAKE_SOURCES_ONLY live.

The empty-span parity fix (6959e16) shows you did catch the trap that matters. Generation counter, one run.conf.default row, one number — then I would take it.

**@⁠Luxuride** on GitHub · 2026-12-04 12:09 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7411054741) The extraction into `front_plan.rs` with a randomized differential oracle against the old planner is exactly how this should be done. Three things keep it from being a yes today. 1. **The cache key is a length.** `crates/victory-gpu/src/host/front_plan.rs:94` is `(*recorded_steps == steps).then(...)`, so correctness rests on an unwritten invariant: a list's `copies` may only grow between reset and submission. Worse, the test at `crates/victory-gpu/src/host.rs:6906` documents the opposite — it mutates `deferred.copies[0]` in place and asserts the stale front is still returned. It is safe only because that slot happens to hold a `Copy` and not a `Refresh`; the next person who splices a `Refresh` in place gets a wrong span and a wrong upload. Key the cache on a generation counter bumped on mutation, not on a count. 2. **Off by default, but rewrites the hot path.** `crates/victory-gpu/src/host.rs:6838` gates the cache on `VICTORY_RECORD_REFRESH_FRONT=1`, yet with it unset you still replace the hot path with the new `resolve_fronts`/`join_fronts` split. So the default path is unchanged-but-different for no measured gain. Say that in the body, or keep the old path when the switch is off. 3. **No number.** Four commit messages say "verified natively" and "differential tests", none says a frame time. For a PR whose subject is "less submit-time work", that is the one missing piece. Also: `VICTORY_RECORD_REFRESH_FRONT` is in `docs/SETTINGS.md:33` but not in `run.conf.default`, where `VICTORY_LATE_FENCE` and `VICTORY_BAKE_SOURCES_ONLY` live. The empty-span parity fix (`6959e16`) shows you did catch the trap that matters. Generation counter, one `run.conf.default` row, one number — then I would take it.
Key each closed-front summary on the step stream generation, including mutable accesses that leave length unchanged. Retain the original wide and narrow folds when recording summaries is disabled. Share only the locked deferred step stream with the existing wide worker pool so workers hold ownership without raw list pointers. Cover replacement, removal, splice and reset invalidation and expose the existing opt-in switch in run.conf.default.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 15:12 UTC · original

@⁠Luxuride, the fixes are in 1f9ca51 (current head b88c697). Deferred step mutations now invalidate by generation, including same-length replacements. The switch-off path uses the original wide and narrow folds, and the switch is in run.conf.default. Five portable planner tests and the Windows-target check passed. The Standard production-planner fixture measured 101.188 → 31.625 µs (−68.84%, identical output), including one recording, four submissions and a partial miss. That is CPU-only; the PR now documents the reproduction and requests combined recording/submission timings in game.

**@⁠tommiehansen** on GitHub · 2026-12-04 15:12 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/308#issuecomment-7415494493) @⁠Luxuride, the fixes are in `1f9ca51` (current head `b88c697`). Deferred step mutations now invalidate by generation, including same-length replacements. The switch-off path uses the original wide and narrow folds, and the switch is in `run.conf.default`. Five portable planner tests and the Windows-target check passed. The Standard production-planner fixture measured 101.188 → 31.625 µs (−68.84%, identical output), including one recording, four submissions and a partial miss. That is CPU-only; the PR now documents the reproduction and requests combined recording/submission timings in game.
github-bot changed title from gpu: reuse closed command lists’ wide refresh summaries to perf(gpu): reuse closed command lists’ wide refresh summaries 2026-12-05 02:15:02 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/308/head:github-bot/gh-308'
git switch 'github-bot/gh-308'

Merge

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