gpu/descriptor: 2-level 64-bit bitmap DynamicSlots allocator and batched reclamation #704

Manually merged
github merged 1 commit from github-bot/gh-704 into main 2026-11-29 08:21:57 +00:00 AGit
Owner

@⁠mint17 on GitHub · 2026-11-28 03:53 UTC · original
mint17:perf/dynamic-slots-bitmap-batch-release → main · +1228 −67 · 4 files · 1 commits · merged 2026-11-29 08:16 UTC

Replaces the byte-per-slot Vec<bool> linear scan in HostHeap::dynamic and per-range release_dynamic lock loops in State::tables_done / Drop for State with a pure-Rust 2-level 64-bit bitmap allocator and batched reclamation (zero conflict with #646, #666, or #693).

Changes

  • 2-level 64-bit bitmap DynamicSlots (slots.rs): Level-0 u64 occupancy words + Level-1 summary bitmap skipping completely full 64-word (4,096-slot) chunks in one instruction, O(log n) bit-parallel within-word run search, O(1) cross-word fast path for n <= 64, exact next-fit cursor / wraparound / too_long watermark parity, and overflow-clamped release_batch.
  • Batched reclamation (descriptor.rs, descriptor/host.rs, draw.rs): release_dynamic_batch takes SHADER_HEAPS.read() once per command list (zero-alloc fast path for single-heap batches, sorted chunk_by for multi-heap batches, filtering stale heap IDs and title-slot indices < host.count()). Preserves PORTABLE_VIEWS, VICTORY_DYNAMIC_SLOTS, slot_evict, and diagnostics copystat counters verbatim.

Release Microbenchmark (cargo test --release --locked -p victory-gpu --lib bench_dynamic_slots_vs_vec_bool -- --ignored --nocapture)

Capacity Regime (30,000 alloc+release) Baseline (Vec<bool> + per-range) New (DynamicSlots + batch) Speedup
262,144 Normal 3,121 µs 1,100 µs 2.8×
262,144 Fragmented 18,915 µs 1,062 µs 17.8×
262,144 High occupancy 3,993 µs 1,054 µs 3.8×
1,048,576 Normal 2,529 µs 1,042 µs 2.4×
1,048,576 Fragmented 18,798 µs 1,083 µs 17.4×
1,048,576 High occupancy 3,999 µs 1,041 µs 3.8×

Verification

  • cargo test --locked -p victory-gpu --lib -- descriptor::slots dynamic_slots descriptor::host::tests -- --test-threads=1 (52 passed, 0 failed — includes 127,500+ op randomized Vec<bool> oracle parity tests across 13 capacities, wraparound / too_long tests, and multi-heap / wrong-ID / title-slot batch reclamation tests).
  • cargo test --locked -p victory-gpu --lib --features diagnostics -- descriptor::slots dynamic_slots -- --test-threads=1 (8 passed, 0 failed).
  • Zero Clippy warnings across all added/modified files (default + --all-features) and cargo test --locked -p xtask passed (6 passed, 0 failed, including asset policy).
  • Verified with synthetic unit tests, oracle tests, and microbenchmarks only (no game files).
**@⁠mint17** on GitHub · 2026-11-28 03:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/704) `mint17:perf/dynamic-slots-bitmap-batch-release` → `main` · +1228 −67 · 4 files · 1 commits · merged 2026-11-29 08:16 UTC Replaces the byte-per-slot `Vec<bool>` linear scan in `HostHeap::dynamic` and per-range `release_dynamic` lock loops in `State::tables_done` / `Drop for State` with a pure-Rust 2-level 64-bit bitmap allocator and batched reclamation (zero conflict with #646, #666, or #693). ### Changes - **2-level 64-bit bitmap `DynamicSlots` ([`slots.rs`](crates/victory-gpu/src/descriptor/slots.rs)):** Level-0 `u64` occupancy words + Level-1 summary bitmap skipping completely full 64-word (4,096-slot) chunks in one instruction, O(log n) bit-parallel within-word run search, O(1) cross-word fast path for `n <= 64`, exact next-fit cursor / wraparound / `too_long` watermark parity, and overflow-clamped `release_batch`. - **Batched reclamation (`descriptor.rs`, `descriptor/host.rs`, `draw.rs`):** `release_dynamic_batch` takes `SHADER_HEAPS.read()` once per command list (zero-alloc fast path for single-heap batches, sorted `chunk_by` for multi-heap batches, filtering stale heap IDs and title-slot indices `< host.count()`). Preserves `PORTABLE_VIEWS`, `VICTORY_DYNAMIC_SLOTS`, `slot_evict`, and `diagnostics` `copystat` counters verbatim. ### Release Microbenchmark (`cargo test --release --locked -p victory-gpu --lib bench_dynamic_slots_vs_vec_bool -- --ignored --nocapture`) | Capacity | Regime (30,000 alloc+release) | Baseline (`Vec<bool>` + per-range) | New (`DynamicSlots` + batch) | Speedup | | ---: | :--- | ---: | ---: | ---: | | 262,144 | Normal | 3,121 µs | 1,100 µs | **2.8×** | | 262,144 | Fragmented | 18,915 µs | 1,062 µs | **17.8×** | | 262,144 | High occupancy | 3,993 µs | 1,054 µs | **3.8×** | | 1,048,576 | Normal | 2,529 µs | 1,042 µs | **2.4×** | | 1,048,576 | Fragmented | 18,798 µs | 1,083 µs | **17.4×** | | 1,048,576 | High occupancy | 3,999 µs | 1,041 µs | **3.8×** | ### Verification - `cargo test --locked -p victory-gpu --lib -- descriptor::slots dynamic_slots descriptor::host::tests -- --test-threads=1` (52 passed, 0 failed — includes 127,500+ op randomized `Vec<bool>` oracle parity tests across 13 capacities, wraparound / `too_long` tests, and multi-heap / wrong-ID / title-slot batch reclamation tests). - `cargo test --locked -p victory-gpu --lib --features diagnostics -- descriptor::slots dynamic_slots -- --test-threads=1` (8 passed, 0 failed). - Zero Clippy warnings across all added/modified files (default + `--all-features`) and `cargo test --locked -p xtask` passed (6 passed, 0 failed, including asset policy). - Verified with synthetic unit tests, oracle tests, and microbenchmarks only (no game files).
Replace the byte-per-slot Vec<bool> linear scan in HostHeap::dynamic and
per-range release_dynamic lock loops in State::tables_done / Drop with a
pure-Rust 2-level 64-bit bitmap allocator and batched reclamation:

- Add crates/victory-gpu/src/descriptor/slots.rs (L0 u64 occupancy words +
  L1 non-full summary words, O(log n) bit-parallel within-word scan, O(1)
  cross-word fast path for n <= 64, next-fit cursor & too_long watermark,
  clamped release_batch).
- Add descriptor::release_dynamic_batch (single SHADER_HEAPS.read() lock,
  zero-alloc fast path for single-heap batches, sorted chunk_by multi-heap
  path, wrong/stale heap ID and title-slot bounds filtering) and switch
  State::tables_done / Drop for State to use it.
- Preserve VIctory-NVIDIA's PORTABLE_VIEWS, VICTORY_DYNAMIC_SLOTS,
  slot_evict, and diagnostics copystat counters verbatim.
- Add 127,500+ op Vec<bool> oracle parity tests across 13 capacities,
  wraparound/too_long tests, multi-heap batch reclamation tests, and an
  opt-in release microbenchmark (17.8x fragmented speedup at 262K slots,
  17.4x at 1M slots).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 03:54:48 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 04:29 UTC · original · approved these changes

LGTM — verified on Windows (RTX 5090):

  • cargo test -p victory-gpu --lib descriptor:: passed (67/67, including oracle_parity_randomized_all_capacities_and_edge_cases, find_zero_run_in_word_matches_naive_exhaustive_patterns, wrap_across_cursor_and_no_physical_wrap_parity, and release_dynamic_batch_handles_empty_single_multi_wrong_id_and_stale)
  • 0 new compiler warnings in touched files
  • cargo xtask policy passed (295 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-28 04:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/704#pullrequestreview-6095811549) · **approved these changes** LGTM — verified on Windows (RTX 5090): - `cargo test -p victory-gpu --lib descriptor::` passed (67/67, including `oracle_parity_randomized_all_capacities_and_edge_cases`, `find_zero_run_in_word_matches_naive_exhaustive_patterns`, `wrap_across_cursor_and_no_physical_wrap_parity`, and `release_dynamic_batch_handles_empty_single_multi_wrong_id_and_stale`) - 0 new compiler warnings in touched files - `cargo xtask policy` passed (`295 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot referenced this pull request from a commit 2026-11-29 08:20:38 +00:00
github manually merged commit 0ba6bf2f27 into main 2026-11-29 08:21:57 +00:00
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!704
No description provided.