HLE, GPU: coalesce xmem::report_written page runs, Arc<[Hull]> Viewed::ranges, and Batch Step::Heap/Step::Memory dedup #2211

Closed
RVZO6 wants to merge 1 commit from upstream-pr/2213 into main
RVZO6 commented 2026-11-25 08:00:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T08:00:19Z.


Streaming memory writes and bindless/title-memory submission batching currently do redundant per-page notifications, repeated hull vector/Arc cloning, and duplicate per-submission heap/memory refresh steps:

  1. xmem::report_written calls victory_gpu::kernel_will_write once per 64 KiB page instead of coalescing contiguous runs.
  2. bindless::Viewed::ranges() clones the full Vec<Hull> and every Arc<Shadow> on every submission even when the heap's views have not changed.
  3. host::Batch re-runs Step::Heap and Step::Memory for the same heap/generation across multiple command lists in the same submission even when no intervening title write occurred.

Claimed on #1633 (https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155570873).

The change

  • crates/victory-hle/src/modules/xmem.rs:
    • Add pure coalesce_pages (with overflow guards and a zero-alloc fast path for <= 1 page) so xmem::report_written notifies victory_gpu::kernel_will_write once per contiguous merged 64 KiB page run.
    • Add 4 unit tests: coalesce_pages_empty_and_single, coalesce_pages_merges_sorted_contiguous_run, coalesce_pages_sorts_dedups_and_splits_disjoint_runs, coalesce_pages_guards_overflow_near_max.
  • crates/victory-gpu/src/bindless.rs:
    • Cache buffer hulls as Option<Arc<[Hull]>> so Viewed::ranges() returns an O(1) Arc clone instead of cloning the Vec and every Arc<Shadow>.
    • Track a monotonic AtomicU64 generation (Viewed::generation()) bumped under Inner's lock when distinct buffer ranges change.
    • Add unit test viewed_ranges_reuses_arc_until_mutated.
  • crates/victory-gpu/src/host.rs:
    • Deduplicate Step::Heap and Step::Memory per submission in Batch keyed by (heap, generation) (using Viewed::generation() and shadow::generation()), clearing both maps on Batch::title_written().
    • Add unit test batch_deduplicates_heap_and_memory_steps.

Not a duplicate of

  • #2199 fixes overlapping source ranges in xmem::map_alias and does not touch xmem::report_written.
  • No open PR or CLAIMS.md entry caches Viewed::ranges() as Arc<[Hull]> or deduplicates Step::Heap/Step::Memory in host::Batch.

Tested

  • Fork windows-latest MSVC + Windows WARP SM 6.6 CI run 45570823602 (Clippy clean, Clippy, diagnostics build clean, Tests: 731 passed; 0 failed; 10 ignored, victory-hle: 147 passed; 0 failed, victory-gpu: 153 passed; 0 failed; 2 ignored + 1 passed, xtask: 6 passed; 0 failed):
    • modules::xmem::tests::coalesce_pages_empty_and_single ... ok
    • modules::xmem::tests::coalesce_pages_merges_sorted_contiguous_run ... ok
    • modules::xmem::tests::coalesce_pages_sorts_dedups_and_splits_disjoint_runs ... ok
    • modules::xmem::tests::coalesce_pages_guards_overflow_near_max ... ok
    • bindless::tests::viewed_ranges_reuses_arc_until_mutated ... ok
    • host::tests::batch_deduplicates_heap_and_memory_steps ... ok

Not run: the title; any hardware GPU. The title was not used in these tests.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

<!-- greyfinch-sync:Marvisak/VIctory:issue:6599932895 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2213). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-25T08:00:19Z. --- Streaming memory writes and bindless/title-memory submission batching currently do redundant per-page notifications, repeated hull vector/Arc cloning, and duplicate per-submission heap/memory refresh steps: 1. `xmem::report_written` calls `victory_gpu::kernel_will_write` once per 64 KiB page instead of coalescing contiguous runs. 2. `bindless::Viewed::ranges()` clones the full `Vec<Hull>` and every `Arc<Shadow>` on every submission even when the heap's views have not changed. 3. `host::Batch` re-runs `Step::Heap` and `Step::Memory` for the same heap/generation across multiple command lists in the same submission even when no intervening title write occurred. Claimed on #1633 (`https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155570873`). ## The change - `crates/victory-hle/src/modules/xmem.rs`: - Add pure `coalesce_pages` (with overflow guards and a zero-alloc fast path for `<= 1` page) so `xmem::report_written` notifies `victory_gpu::kernel_will_write` once per contiguous merged 64 KiB page run. - Add 4 unit tests: `coalesce_pages_empty_and_single`, `coalesce_pages_merges_sorted_contiguous_run`, `coalesce_pages_sorts_dedups_and_splits_disjoint_runs`, `coalesce_pages_guards_overflow_near_max`. - `crates/victory-gpu/src/bindless.rs`: - Cache buffer hulls as `Option<Arc<[Hull]>>` so `Viewed::ranges()` returns an O(1) `Arc` clone instead of cloning the `Vec` and every `Arc<Shadow>`. - Track a monotonic `AtomicU64` generation (`Viewed::generation()`) bumped under `Inner`'s lock when distinct buffer ranges change. - Add unit test `viewed_ranges_reuses_arc_until_mutated`. - `crates/victory-gpu/src/host.rs`: - Deduplicate `Step::Heap` and `Step::Memory` per submission in `Batch` keyed by `(heap, generation)` (using `Viewed::generation()` and `shadow::generation()`), clearing both maps on `Batch::title_written()`. - Add unit test `batch_deduplicates_heap_and_memory_steps`. ## Not a duplicate of - `#2199` fixes overlapping source ranges in `xmem::map_alias` and does not touch `xmem::report_written`. - No open PR or `CLAIMS.md` entry caches `Viewed::ranges()` as `Arc<[Hull]>` or deduplicates `Step::Heap`/`Step::Memory` in `host::Batch`. ## Tested - Fork `windows-latest` MSVC + Windows WARP SM 6.6 CI run [`45570823602`](https://github.com/RVZO6/VIctory/actions/runs/45570823602) (`Clippy` clean, `Clippy, diagnostics build` clean, `Tests`: **`731 passed; 0 failed; 10 ignored`**, `victory-hle`: **`147 passed; 0 failed`**, `victory-gpu`: **`153 passed; 0 failed; 2 ignored`** + `1 passed`, `xtask`: **`6 passed; 0 failed`**): - `modules::xmem::tests::coalesce_pages_empty_and_single ... ok` - `modules::xmem::tests::coalesce_pages_merges_sorted_contiguous_run ... ok` - `modules::xmem::tests::coalesce_pages_sorts_dedups_and_splits_disjoint_runs ... ok` - `modules::xmem::tests::coalesce_pages_guards_overflow_near_max ... ok` - `bindless::tests::viewed_ranges_reuses_arc_until_mutated ... ok` - `host::tests::batch_deduplicates_heap_and_memory_steps ... ok` **Not run:** the title; any hardware GPU. The title was not used in these tests. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
catminou4 commented 2026-11-25 08:06:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:03:11Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

xmem::report_written page runs coalesced, Arc<[Hull...]> — HLE+GPU mixed; relates to #2199's overlap fix and the WPM batching cluster.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053837595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2213#pullrequestreview-6053837595). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:03:11Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. xmem::report_written page runs coalesced, Arc<[Hull...]> — HLE+GPU mixed; relates to #2199's overlap fix and the WPM batching cluster.
DenRakEiw commented 2026-11-25 08:06:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:03:25Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib bindless:: — 4 passed, 0 failed
  • cargo clippy -p victory-gpu -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean coalescing of xmem::report_written page runs, Arc<[Hull]> for Viewed::ranges, and Batch step deduplication. Looks great.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6053839953 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2213#pullrequestreview-6053839953). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T08:03:25Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib bindless::` — 4 passed, 0 failed - `cargo clippy -p victory-gpu -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean coalescing of `xmem::report_written` page runs, `Arc<[Hull]>` for `Viewed::ranges`, and `Batch` step deduplication. Looks great. AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 14:07:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:29:38Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/bindless.rs, crates/victory-gpu/src/host.rs, crates/victory-hle/src/modules/xmem.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163856599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2213#issuecomment-7163856599). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:29:38Z. --- <!-- victory-triage v1 head=d6f41eceeb88ae39716055e528e08ba16f6023bd verdict=needs-rebase at=2026-11-25T16:14:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/bindless.rs`, `crates/victory-gpu/src/host.rs`, `crates/victory-hle/src/modules/xmem.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 18:01:53 +00:00
RVZO6 commented 2026-11-25 18:02:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T17:13:53Z.


Closing as superseded by main (2922141 incremental per-copy merged view ranges and 2921092 xmem page-window reporting).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169198831 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2213#issuecomment-7169198831). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-25T17:13:53Z. --- Closing as superseded by `main` (`2922141` incremental per-copy merged view ranges and `2921092` `xmem` page-window reporting).

Pull request closed

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
Marvisak/VIctory!2211
No description provided.