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

Merged
mint17 merged 1 commit from upstream-pr/704 into main 2026-11-29 08:16:58 +00:00
mint17 commented 2026-11-28 03:53:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mint17 on 2026-11-28T03:53:30Z.


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).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5536413925 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/704). Originally posted by [mint17](https://github.com/mint17) on 2026-11-28T03:53:30Z. --- 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).
Dukestar69 commented 2026-11-28 04:29:01 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T04:29:01Z.

Review: APPROVED


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).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6095811549 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/704#pullrequestreview-6095811549). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T04:29:01Z. **Review:** APPROVED --- 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).
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
trustno1-coder/VIctory-NVIDIA!704
No description provided.