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

Closed
github-bot wants to merge 1 commit from gh-pr/2213/head into gh-pr/2213/base
Owner

@⁠RVZO6 on GitHub · 2026-11-25 08:00 UTC · original
RVZO6:rvzo/stream-batch-coalesce → main · +298 −32 · 3 files · 1 commits · closed without merging

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)

**@⁠RVZO6** on GitHub · 2026-11-25 08:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2213) `RVZO6:rvzo/stream-batch-coalesce` → `main` · +298 −32 · 3 files · 1 commits · closed without merging 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)
- Coalesce sorted, deduplicated contiguous 64 KiB page runs in xmem::report_written (via pure coalesce_pages with overflow checks and a zero-alloc fast path for <=1 page) so victory_gpu::kernel_will_write is notified once per merged run instead of once per page.
- Cache bindless::Viewed 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 bumped under Inner's lock when distinct buffer ranges change.
- Deduplicate Step::Heap and Step::Memory in host::Batch per submission keyed by heap/generation (using Viewed::generation() and shadow::generation()), clearing both maps on Batch::title_written().
- Add GPU-free unit tests covering coalesce_pages, Viewed::ranges Arc reuse/invalidation, and Batch heap/memory deduplication.

Assisted-by: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:37 +00:00
github-bot closed this pull request 2026-11-26 04:58:37 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:29 UTC · original · edited 2026-11-25 16:03 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 13:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2213#issuecomment-7163856599) · edited 2026-11-25 16:03 UTC <!-- 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)_
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-25 17:13 UTC · original

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

**@⁠RVZO6** on GitHub · 2026-11-25 17:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2213#issuecomment-7169198831) Closing as superseded by `main` (`2922141` incremental per-copy merged view ranges and `2921092` `xmem` page-window reporting).

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