GPU: batch submission heap/memory steps and fast-scan bindless and page-table bitmaps #3487

Open
github-bot wants to merge 2 commits from github-bot/gh-3487 into main AGit
Owner

@⁠Desamodeth on GitHub · 2026-11-27 08:27 UTC · original
Desamodeth:opt/submission-heap-memory-steps → main · +786 −103 · 4 files · 2 commits · open

Reduces submission-time CPU overhead in Host::execute across three closely coupled loops (part of the unclaimed submission-step / title-memory hotspot noted in #3425):

Changes

  • Word-level watch::DIRTY scan for bindless buffer refresh (crates/victory-gpu/src/watch.rs, crates/victory-gpu/src/bindless.rs):
    • Added watch::dirty_word(word) to load one 64-tracker word of DIRTY at a time.
    • Stored Viewed's merged buffer hulls densely in Vec<Hull> (hull_pos: HashMap<(usize, bool), u32>) indexed by active_words: Vec<ActiveWord> ((word, mask, sorted (bit_offset, hull_idx))) and untracked_hulls: Vec<u32>. bindless::refresh checks 64 copies per atomic word load and indexes hulls directly with zero hash lookups (plus a straight-through path when a word is 100% dirty).
    • Added a monotonic Viewed::hull_generation() bumped only when Inner::count mutates hulls.
  • Submission-wide Step::Heap / Step::Memory deduplication & allocation-free Deferred scans (crates/victory-gpu/src/host.rs):
    • Track heaps_seen: Vec<(usize, u64)> ((viewed_ptr, hull_generation)) and memories_seen: Vec<(usize, u64)> ((heap_key, shadow::generation())) on Batch so multi-list submissions skip repeating bindless::refresh and memory::prepare across lists while nothing changed, clearing both in Batch::title_written() on Step::Copy (and re-running if hull or shadow generation changes).
    • Replaced per-list .flat_map(... .collect::<Vec<_>>()) allocations in Host::execute with a single flag-gated pass (has_heaps, has_textures) and skipped post-GPU deferred.copies scans when !has_gpu_writes.
  • Bounded & handed-off title-memory bitmap scans (crates/victory-gpu/src/memory.rs):
    • Bounded defer_missed and defer_after scans to active_words(&layout) (blocks.len().max(1) * (BLOCK / 32) capped at BITMAP_WORDS) using 4-word chunked zero skips (as_chunks::<4>() / as_chunks_mut::<4>()).
    • Handed off SCAN_ALL_ZERO from defer_missed to defer_after so clean lists skip the second bitmap scan and STATS lock; when marks are present, defer_after clears active words, skips STATS lock if all counters are zero, and marks PooledBitmap clean so PooledBitmap::drop skips re-scanning 256.5 KiB on pool return (unexecuted/direct bitmaps still run defensive full clearing).

Benchmarks (RTX 5070, Release, 12 interleaved runs: 6 main -> opt + 6 opt -> main)

  • Base origin/main: 63bcca43c6a00a758510398fa43096ce7e4f7df0
  • Branch HEAD: 834dfc66c517ae28ba2af368e85f6cf4abd35e16
  • Synthetic fixtures only (no game files). Microbenchmark timings below do not translate directly to game FPS.
Scenario main median [min..max] opt median [min..max] Delta Speedup
bindless::refresh 4,096 hulls, 0 dirty (240 calls) 1,169.9 us [812.3..1,341.8] 8.6 us [6.0..12.9] -99.3% 136.03x
bindless::refresh 4,096 hulls, 16 copies / 32 hulls dirty (240 calls) 1,079.4 us [819.5..1,320.3] 25.3 us [24.9..43.6] -97.7% 42.66x
bindless::refresh 4,096 hulls, 100% dirty worst case (20 calls) 132.3 us [86.1..154.1] 24.2 us [19.7..45.3] -81.7% 5.47x
Viewed::set insert+remove churn (24,576 ops, no refresh — unfavourable case) 4,994.6 us [3,196.1..5,670.3] 5,303.9 us [3,854.8..6,107.7] +6.2% 0.94x
Real Host::execute 16 lists (4,096-hull Viewed + 8 memory::bind + reset, 8 rounds) 7,839.9 us [6,452.1..9,770.9] 1,377.9 us [889.0..1,629.0] -82.4% 5.69x
Real Host::execute 8 lists with Step::Copy between every list (dedup worst case, 8 rounds) 1,994.4 us [1,647.4..2,539.2] 862.5 us [674.9..1,214.7] -56.8% 2.31x
Real Host::execute 16 memory::bind lists + execute + reset (12 rounds = 192 bitmaps) 16,786.5 us [12,436.0..21,736.9] 1,599.0 us [1,324.7..2,272.0] -90.5% 10.50x
memory::has_missed full 512-block layout (65,664 dwords), 0 marks (2,000 scans — active_words worst case) 93,897.7 us [61,991.4..130,422.7] 23,538.4 us [19,098.7..26,228.3] -74.9% 3.99x
memory::has_missed full 512-block layout, 16 scattered owned marks (2,000 scans) 119,621.1 us [72,875.0..132,004.3] 23,360.1 us [19,240.2..26,550.6] -80.5% 5.12x

Trade-offs

  • Maintaining hull_pos + ActiveWord adds +6.2% overhead (~12.6 ns/op) on pure Viewed::set hull insert/remove churn when no refresh happens, in exchange for 5.5x–136x faster bindless::refresh across clean, sparse, and 100%-dirty states.
  • active_words(&layout) assumes GPU shaders only index blocks < layout.blocks.len() from level-1 (guaranteed by write_table, which maps all unallocated 256 MiB regions to block 0).

Verification

  • cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings — clean
  • cargo clippy --locked -p victory-gpu --features diagnostics --lib --tests -- -D warnings — clean
  • cargo xtask policy — 191 files ok
  • RTX 5070 (--test-threads=1, bindless:: memory:: host:: watch::tests:: shadow::tests::, skipping only the 2 known NVIDIA FIND-9 heap-cap tests): 72 passed; 0 failed
  • WARP (VICTORY_D3D12_WARP=1, --features diagnostics, --test-threads=1, full set including both FIND-9 tests): 75 passed; 0 failed
  • Added regression tests:
    • bindless::tests::refresh_word_scan_matches_dirty_srv_uav_untracked_and_removals
    • host::withholding::batch_deduplicates_heap_and_memory_steps_until_title_write
    • memory::tests::active_words_scan_missed_and_clear_nonzero_words
    • memory::tests::clean_handoff_and_repeat_submission_preserve_bitmap_state

Coordination claim: #1633 (#1633).

AI-assisted with Gemini 4 Neon

**@⁠Desamodeth** on GitHub · 2026-11-27 08:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3487) `Desamodeth:opt/submission-heap-memory-steps` → `main` · +786 −103 · 4 files · 2 commits · open Reduces submission-time CPU overhead in `Host::execute` across three closely coupled loops (part of the unclaimed submission-step / title-memory hotspot noted in #3425): ### Changes - **Word-level `watch::DIRTY` scan for bindless buffer refresh** (`crates/victory-gpu/src/watch.rs`, `crates/victory-gpu/src/bindless.rs`): - Added `watch::dirty_word(word)` to load one 64-tracker word of `DIRTY` at a time. - Stored `Viewed`'s merged buffer hulls densely in `Vec<Hull>` (`hull_pos: HashMap<(usize, bool), u32>`) indexed by `active_words: Vec<ActiveWord>` (`(word, mask, sorted (bit_offset, hull_idx))`) and `untracked_hulls: Vec<u32>`. `bindless::refresh` checks 64 copies per atomic word load and indexes `hulls` directly with zero hash lookups (plus a straight-through path when a word is 100% dirty). - Added a monotonic `Viewed::hull_generation()` bumped only when `Inner::count` mutates `hulls`. - **Submission-wide `Step::Heap` / `Step::Memory` deduplication & allocation-free `Deferred` scans** (`crates/victory-gpu/src/host.rs`): - Track `heaps_seen: Vec<(usize, u64)>` (`(viewed_ptr, hull_generation)`) and `memories_seen: Vec<(usize, u64)>` (`(heap_key, shadow::generation())`) on `Batch` so multi-list submissions skip repeating `bindless::refresh` and `memory::prepare` across lists while nothing changed, clearing both in `Batch::title_written()` on `Step::Copy` (and re-running if hull or shadow generation changes). - Replaced per-list `.flat_map(... .collect::<Vec<_>>())` allocations in `Host::execute` with a single flag-gated pass (`has_heaps`, `has_textures`) and skipped post-GPU `deferred.copies` scans when `!has_gpu_writes`. - **Bounded & handed-off title-memory bitmap scans** (`crates/victory-gpu/src/memory.rs`): - Bounded `defer_missed` and `defer_after` scans to `active_words(&layout)` (`blocks.len().max(1) * (BLOCK / 32)` capped at `BITMAP_WORDS`) using 4-word chunked zero skips (`as_chunks::<4>()` / `as_chunks_mut::<4>()`). - Handed off `SCAN_ALL_ZERO` from `defer_missed` to `defer_after` so clean lists skip the second bitmap scan and `STATS` lock; when marks are present, `defer_after` clears active words, skips `STATS` lock if all counters are zero, and marks `PooledBitmap` clean so `PooledBitmap::drop` skips re-scanning 256.5 KiB on pool return (unexecuted/direct bitmaps still run defensive full clearing). ### Benchmarks (RTX 5070, Release, 12 interleaved runs: 6 `main -> opt` + 6 `opt -> main`) - Base `origin/main`: `63bcca43c6a00a758510398fa43096ce7e4f7df0` - Branch HEAD: `834dfc66c517ae28ba2af368e85f6cf4abd35e16` - Synthetic fixtures only (no game files). Microbenchmark timings below do not translate directly to game FPS. | Scenario | `main` median `[min..max]` | `opt` median `[min..max]` | Delta | Speedup | |---|---:|---:|---:|---:| | `bindless::refresh` 4,096 hulls, 0 dirty (240 calls) | `1,169.9 us` `[812.3..1,341.8]` | `8.6 us` `[6.0..12.9]` | `-99.3%` | `136.03x` | | `bindless::refresh` 4,096 hulls, 16 copies / 32 hulls dirty (240 calls) | `1,079.4 us` `[819.5..1,320.3]` | `25.3 us` `[24.9..43.6]` | `-97.7%` | `42.66x` | | `bindless::refresh` 4,096 hulls, 100% dirty worst case (20 calls) | `132.3 us` `[86.1..154.1]` | `24.2 us` `[19.7..45.3]` | `-81.7%` | `5.47x` | | `Viewed::set` insert+remove churn (24,576 ops, no refresh — unfavourable case) | `4,994.6 us` `[3,196.1..5,670.3]` | `5,303.9 us` `[3,854.8..6,107.7]` | `+6.2%` | `0.94x` | | Real `Host::execute` 16 lists (4,096-hull `Viewed` + 8 `memory::bind` + reset, 8 rounds) | `7,839.9 us` `[6,452.1..9,770.9]` | `1,377.9 us` `[889.0..1,629.0]` | `-82.4%` | `5.69x` | | Real `Host::execute` 8 lists with `Step::Copy` between every list (dedup worst case, 8 rounds) | `1,994.4 us` `[1,647.4..2,539.2]` | `862.5 us` `[674.9..1,214.7]` | `-56.8%` | `2.31x` | | Real `Host::execute` 16 `memory::bind` lists + execute + reset (12 rounds = 192 bitmaps) | `16,786.5 us` `[12,436.0..21,736.9]` | `1,599.0 us` `[1,324.7..2,272.0]` | `-90.5%` | `10.50x` | | `memory::has_missed` full 512-block layout (65,664 dwords), 0 marks (2,000 scans — `active_words` worst case) | `93,897.7 us` `[61,991.4..130,422.7]` | `23,538.4 us` `[19,098.7..26,228.3]` | `-74.9%` | `3.99x` | | `memory::has_missed` full 512-block layout, 16 scattered owned marks (2,000 scans) | `119,621.1 us` `[72,875.0..132,004.3]` | `23,360.1 us` `[19,240.2..26,550.6]` | `-80.5%` | `5.12x` | ### Trade-offs - Maintaining `hull_pos` + `ActiveWord` adds `+6.2%` overhead (~12.6 ns/op) on pure `Viewed::set` hull insert/remove churn when no refresh happens, in exchange for `5.5x`–`136x` faster `bindless::refresh` across clean, sparse, and 100%-dirty states. - `active_words(&layout)` assumes GPU shaders only index blocks `< layout.blocks.len()` from level-1 (guaranteed by `write_table`, which maps all unallocated 256 MiB regions to block 0). ### Verification - `cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings` — clean - `cargo clippy --locked -p victory-gpu --features diagnostics --lib --tests -- -D warnings` — clean - `cargo xtask policy` — `191 files ok` - RTX 5070 (`--test-threads=1`, `bindless:: memory:: host:: watch::tests:: shadow::tests::`, skipping only the 2 known NVIDIA `FIND-9` heap-cap tests): `72 passed; 0 failed` - WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics`, `--test-threads=1`, full set including both `FIND-9` tests): `75 passed; 0 failed` - Added regression tests: - `bindless::tests::refresh_word_scan_matches_dirty_srv_uav_untracked_and_removals` - `host::withholding::batch_deduplicates_heap_and_memory_steps_until_title_write` - `memory::tests::active_words_scan_missed_and_clear_nonzero_words` - `memory::tests::clean_handoff_and_repeat_submission_preserve_bitmap_state` Coordination claim: #1633 (https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). AI-assisted with Gemini 4 Neon
Reduces submission-time CPU overhead across four hot loops on `Host::execute`:
- `bindless::Viewed` / `refresh` (`watch::dirty_word`): store hulls densely in `Vec<Hull>` indexed by active `watch::DIRTY` 64-bit words (`ActiveWord`), checking 64 copies per atomic word load with zero hash lookups on refresh, and expose a monotonic `hull_generation`.
- `host::Batch` / `Host::execute`: deduplicate repeat `Step::Heap` and `Step::Memory` walks across lists in one submission until a `Step::Copy` title write or generation change; replace per-list `.flat_map(... .collect::<Vec<_>>())` allocations with flag-gated scans (`has_heaps`, `has_textures`, `has_gpu_writes`).
- `memory`: bound post-submission bitmap scans (`defer_missed`, `defer_after`) to `active_words(&layout)`, unroll 4-word zero skips (`as_chunks::<4>()`), hand off all-zero scans from `defer_missed` to `defer_after` (skipping the second pass and `STATS` lock when clean), and mark `PooledBitmap` clean so `Drop` skips re-scanning 256.5 KiB on pool return.

AI-assisted with Gemini 4 Neon
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 08:29:30 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 09:37 UTC · original

Independent Windows/WARP verification of #3487 at 834dfc66c517ae28ba2af368e85f6cf4abd35e16

Environment: Windows 11 Pro build 10.0.26200, rustc 1.98.1, no physical GPU: VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 (WARP only), dxil.dll 1.8.2502.11 from the Windows SDK 10.0.26100.0. (An older 10.0.19041 dxil.dll rejects SM 6.6 and crashes many victory-shader GPU tests with an access violation; I discarded those runs.) Base is main 63bcca43c6; all three PR heads (#3487, #3488, #3489) sit directly on it. --locked, separate worktrees for base and head. Claim: #1633

AI-assisted (Claude); I read the diff and the logs before posting. No game files were used. WARP is not hardware, so this says nothing about driver behaviour on AMD or NVIDIA.

Result: no regression found on WARP. cargo test -p victory-gpu --lib:

  • base: 231 passed, 0 failed, 1 ignored (3 runs).
  • head: 235 passed, 0 failed, 1 ignored in 1 of 3 runs. In the other 2 runs, 234 passed and 1 failed: frame::tests::waits_end_on_ticks_and_count_frames (a wall-clock tolerance test). It is not new: the same test also failed on base in one of my earlier runs (25.5 ms observed), and the PR does not touch frame.rs. I count it as a timing flake, not a head regression.
  • New tests on head, all pass: refresh_word_scan_matches_dirty_srv_uav_untracked_and_removals, batch_deduplicates_heap_and_memory_steps_until_title_write, active_words_scan_missed_and_clear_nonzero_words, clean_handoff_and_repeat_submission_preserve_bitmap_state.
  • Merged with #3488 (see below): 235 passed, 0 failed in 3 of 3 runs.

Timing: there is no existing bench for these paths (the only #[ignore] bench in victory-gpu is unrelated), and the world-scale numbers need the title and a GPU, so I did not time it. Suite wall time (2.0 s vs 2.2 s) is not a measurement of the change.

Risk worth a second look (read from the diff, not reproduced): in memory.rs, defer_after does scan_state.swap(SCAN_ALL_ZERO), which leaves the state at ALL_ZERO after every run. host.rs evaluates a list's missed checks with .any(|check| check()), which stops at the first true. If one list binds more than one heap and is executed again without reset(), a later check skipped by that short-circuit keeps the stale ALL_ZERO. Its defer_after then returns early, skips clearing and calls mark_clean(), so a bitmap that still has marks could go back to BITMAP_POOL. The first execution is safe (state starts UNKNOWN), and the new repeat-submission test covers only one bound heap. Resetting the state to UNKNOWN after the consumer, or not short-circuiting, would close it. I do not know whether the real path ever re-executes an unreset multi-bind list.

Minor: Batch::need_heap/need_memory skip a repeat walk until a Step::Copy title write. A game-thread write between two lists of one submission is now picked up by the next submission instead of the next list; that is the same window a racing write already had.

Overlap with #3488: both edit victory-gpu/src/watch.rs. They merge with no conflict (git merge-tree). The hunks are disjoint (this PR adds dirty_word, 5 lines; #3488 only widens the visibility of Tracked, track, take, clean, arm, saved) and I see no semantic interaction. The merged tree builds and passes: victory-gpu 235 passed / 0 failed, victory-hle 154 passed / 0 failed, 3 runs each.

**@⁠oni-swr** on GitHub · 2026-11-27 09:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/3487#issuecomment-7214900879) **Independent Windows/WARP verification of #3487 at `834dfc66c517ae28ba2af368e85f6cf4abd35e16`** Environment: Windows 11 Pro build 10.0.26200, rustc 1.98.1, no physical GPU: `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` (WARP only), `dxil.dll` 1.8.2502.11 from the Windows SDK 10.0.26100.0. (An older 10.0.19041 `dxil.dll` rejects SM 6.6 and crashes many `victory-shader` GPU tests with an access violation; I discarded those runs.) Base is `main` 63bcca43c6a00a758510398fa43096ce7e4f7df0; all three PR heads (#3487, #3488, #3489) sit directly on it. `--locked`, separate worktrees for base and head. Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 AI-assisted (Claude); I read the diff and the logs before posting. No game files were used. WARP is not hardware, so this says nothing about driver behaviour on AMD or NVIDIA. **Result: no regression found on WARP.** `cargo test -p victory-gpu --lib`: - base: 231 passed, 0 failed, 1 ignored (3 runs). - head: 235 passed, 0 failed, 1 ignored in 1 of 3 runs. In the other 2 runs, 234 passed and 1 failed: `frame::tests::waits_end_on_ticks_and_count_frames` (a wall-clock tolerance test). It is not new: the same test also failed on base in one of my earlier runs (25.5 ms observed), and the PR does not touch `frame.rs`. I count it as a timing flake, not a head regression. - New tests on head, all pass: `refresh_word_scan_matches_dirty_srv_uav_untracked_and_removals`, `batch_deduplicates_heap_and_memory_steps_until_title_write`, `active_words_scan_missed_and_clear_nonzero_words`, `clean_handoff_and_repeat_submission_preserve_bitmap_state`. - Merged with #3488 (see below): 235 passed, 0 failed in 3 of 3 runs. **Timing:** there is no existing bench for these paths (the only `#[ignore]` bench in `victory-gpu` is unrelated), and the world-scale numbers need the title and a GPU, so I did not time it. Suite wall time (2.0 s vs 2.2 s) is not a measurement of the change. **Risk worth a second look (read from the diff, not reproduced):** in `memory.rs`, `defer_after` does `scan_state.swap(SCAN_ALL_ZERO)`, which leaves the state at `ALL_ZERO` after every run. `host.rs` evaluates a list's `missed` checks with `.any(|check| check())`, which stops at the first `true`. If one list binds more than one heap and is executed again without `reset()`, a later check skipped by that short-circuit keeps the stale `ALL_ZERO`. Its `defer_after` then returns early, skips clearing and calls `mark_clean()`, so a bitmap that still has marks could go back to `BITMAP_POOL`. The first execution is safe (state starts `UNKNOWN`), and the new repeat-submission test covers only one bound heap. Resetting the state to `UNKNOWN` after the consumer, or not short-circuiting, would close it. I do not know whether the real path ever re-executes an unreset multi-bind list. Minor: `Batch::need_heap`/`need_memory` skip a repeat walk until a `Step::Copy` title write. A game-thread write between two lists of one submission is now picked up by the next submission instead of the next list; that is the same window a racing write already had. **Overlap with #3488:** both edit `victory-gpu/src/watch.rs`. They merge with no conflict (`git merge-tree`). The hunks are disjoint (this PR adds `dirty_word`, 5 lines; #3488 only widens the visibility of `Tracked`, `track`, `take`, `clean`, `arm`, `saved`) and I see no semantic interaction. The merged tree builds and passes: `victory-gpu` 235 passed / 0 failed, `victory-hle` 154 passed / 0 failed, 3 runs each.
A prior heap miss can skip the next binding's scan on replay. Reset its handoff to unknown after consumption so cleanup examines this execution's marks. Cover two bindings on one D3D12 list executed three times without reset.

AI-assisted with Codex Astra 6.2 High.
Author
Owner

@⁠KainanP on GitHub · 2026-11-27 11:55 UTC · original

One concern at head 6c10101e that I haven't seen raised yet. I read the code but did not run it.

The scan and the clear now stop at active_words(&layout(key)). That layout is read when the scan runs, not when the list ran. Marks past it are neither counted nor cleared, but the bitmap is still marked clean.

  • memory.rs:618: active_words = blocks.len().max(1) * BLOCK / 32.
  • memory.rs:703-713 (defer_missed) and :718-726 (defer_after) both take layout(key) at that moment. layout returns Shared.layout "as the last submission using it left it", or the default (0 blocks) once release(key) has dropped the entry.
  • Shared::rewrite (:529 on) rebuilds blocks from the copies that exist now. So the block count can go down between the list's run and its deferred scan: copies were let go and a later prepare rewrote the table, or the heap was released (Heap::drop → memory::release). bind's own comment says lists outlive that ("lists that name it hold it").
  • In both cases, a mark the shader set in a block at or past the new blocks.len() is outside the scanned prefix:
    • scan_missed returns (false, false) and stores SCAN_ALL_ZERO.
    • defer_after takes the fast path and calls mark_clean() (:721-722). Even on the slow path it walks only words, then calls mark_clean() (:769).
    • Drop for PooledBitmap (:197-202) then skips clear_nonzero_words, and the bitmap goes back to BITMAP_POOL with those bits still set.

Two consequences, compared with main (whose has_missed / defer_after walk all BITMAP_WORDS):

  1. This run. On main, such a mark hits l.blocks.get(block).is_none() → missed, so the list's writes are withheld. With this PR, missed is false, so the GpuWrite ranges go back to title memory although part of what the shader wrote was never accounted for.
  2. A later list. The stale word comes out of the pool in another list's bitmap. If that list's layout is large enough to cover it, the word is read as that list's own write. With an owner, that means a copy_back_page of a page nothing wrote. Without one, it is a spurious miss that withholds the submission.

Smallest fix I can see: keep the clear exact and limit only the scan shortcut. In defer_after, always clear up to the largest active_words this bitmap has ever been scanned with. Or keep a high-water mark per PooledBitmap and have Drop clear up to it. Either way, a bitmap is never marked clean beyond what was actually scanned. Another option: capture blocks.len() in prepare, when the table the GPU reads is written, and scan with that instead of the layout found at defer time.

AI use: Claude Code (Claude Opus 5.5).

**@⁠KainanP** on GitHub · 2026-11-27 11:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/3487#issuecomment-7217625492) One concern at head `6c10101e` that I haven't seen raised yet. I read the code but did not run it. **The scan and the clear now stop at `active_words(&layout(key))`. That layout is read when the scan runs, not when the list ran. Marks past it are neither counted nor cleared, but the bitmap is still marked clean.** - `memory.rs:618`: `active_words` = `blocks.len().max(1) * BLOCK / 32`. - `memory.rs:703-713` (`defer_missed`) and `:718-726` (`defer_after`) both take `layout(key)` at that moment. `layout` returns `Shared.layout` "as the last submission using it left it", or the default (0 blocks) once `release(key)` has dropped the entry. - `Shared::rewrite` (`:529` on) rebuilds `blocks` from the copies that exist now. So the block count can go down between the list's run and its deferred scan: copies were let go and a later `prepare` rewrote the table, or the heap was released (`Heap::drop` → `memory::release`). `bind`'s own comment says lists outlive that ("lists that name it hold it"). - In both cases, a mark the shader set in a block at or past the new `blocks.len()` is outside the scanned prefix: - `scan_missed` returns `(false, false)` and stores `SCAN_ALL_ZERO`. - `defer_after` takes the fast path and calls `mark_clean()` (`:721-722`). Even on the slow path it walks only `words`, then calls `mark_clean()` (`:769`). - `Drop for PooledBitmap` (`:197-202`) then skips `clear_nonzero_words`, and the bitmap goes back to `BITMAP_POOL` with those bits still set. Two consequences, compared with `main` (whose `has_missed` / `defer_after` walk all `BITMAP_WORDS`): 1. **This run.** On `main`, such a mark hits `l.blocks.get(block).is_none()` → `missed`, so the list's writes are withheld. With this PR, `missed` is false, so the GpuWrite ranges go back to title memory although part of what the shader wrote was never accounted for. 2. **A later list.** The stale word comes out of the pool in another list's bitmap. If that list's layout is large enough to cover it, the word is read as that list's own write. With an owner, that means a `copy_back_page` of a page nothing wrote. Without one, it is a spurious miss that withholds the submission. Smallest fix I can see: keep the clear exact and limit only the *scan* shortcut. In `defer_after`, always clear up to the largest `active_words` this bitmap has ever been scanned with. Or keep a high-water mark per `PooledBitmap` and have `Drop` clear up to it. Either way, a bitmap is never marked clean beyond what was actually scanned. Another option: capture `blocks.len()` in `prepare`, when the table the GPU reads is written, and scan with that instead of the layout found at defer time. _AI use: Claude Code (Claude Opus 5.5)._
This pull request can be merged automatically.
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/3487/head:github-bot/gh-3487'
git switch 'github-bot/gh-3487'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3487'
git switch 'github-bot/gh-3487'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3487'
git switch 'github-bot/gh-3487'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3487'
git switch 'main'
git merge --squash 'github-bot/gh-3487'
git switch 'main'
git merge --ff-only 'github-bot/gh-3487'
git switch 'main'
git merge 'github-bot/gh-3487'
git push origin 'main'
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!3487
No description provided.