Find free descriptor tables that span the search cursor #251

Closed
tcurtsinger wants to merge 3 commits from upstream-pr/251 into main
tcurtsinger commented 2026-11-24 01:50:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tcurtsinger on 2026-11-24T01:50:39Z.


The dynamic descriptor allocator could turn down a table that fit. For example, free adjacent four-slot and five-slot tables while the cursor is between them. A nine-slot request then searches each side independently and misses the available span.

The new search applies the cursor to candidate start slots. On the second pass a table starting before the cursor can extend past it. An occupied slot skips every candidate that would overlap it. The allocation still ends within the physical heap and preserves next-fit order.

Verification

  • The nine-slot regression failed on d2a4bae with None instead of Some(4) and passed on WARP with the fix. It allocates and releases whole tables through HostHeap.
  • A second test checks all 16,384 combinations of occupancy, cursor and positive table size for an eight-slot heap against a straightforward search.
  • cargo test --workspace --locked passed 267 tests with four ignored. The GPU diagnostics suite passed 48 tests on WARP with one ignored. The asset-policy and diff checks passed.

An RTX 4080 first-mission run logged a nine-slot allocation failure about 32 seconds before device removal. That log did not include slot occupancy, so it cannot distinguish this allocator bug from genuine exhaustion. The change also applies to the capped heap size used in #135.

The first failed allocation now reports the heap capacity, total free slots and longest contiguous free span while the allocator lock is held. A new test covers full, empty and fragmented heaps, including free spans at both ends.

RTX 4080 follow-up

With this fix and #135 on the capped 65,536-slot dynamic heap, the first failed request was for ten consecutive slots. The diagnostic counted 136 free slots in total and a longest free span of nine. That request genuinely could not fit. The earlier nine-slot failure on the previous build had no occupancy data. The synthetic regression above remains the direct test of the cursor fix. Native run and memory measurements.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572774066 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251). Originally posted by [tcurtsinger](https://github.com/tcurtsinger) on 2026-11-24T01:50:39Z. --- The dynamic descriptor allocator could turn down a table that fit. For example, free adjacent four-slot and five-slot tables while the cursor is between them. A nine-slot request then searches each side independently and misses the available span. The new search applies the cursor to candidate **start** slots. On the second pass a table starting before the cursor can extend past it. An occupied slot skips every candidate that would overlap it. The allocation still ends within the physical heap and preserves next-fit order. ## Verification - The nine-slot regression failed on `d2a4bae` with `None` instead of `Some(4)` and passed on WARP with the fix. It allocates and releases whole tables through `HostHeap`. - A second test checks all 16,384 combinations of occupancy, cursor and positive table size for an eight-slot heap against a straightforward search. - `cargo test --workspace --locked` passed 267 tests with four ignored. The GPU diagnostics suite passed 48 tests on WARP with one ignored. The asset-policy and diff checks passed. An RTX 4080 first-mission run logged a nine-slot allocation failure about 32 seconds before device removal. That log did not include slot occupancy, so it cannot distinguish this allocator bug from genuine exhaustion. The change also applies to the capped heap size used in #135. The first failed allocation now reports the heap capacity, total free slots and longest contiguous free span while the allocator lock is held. A new test covers full, empty and fragmented heaps, including free spans at both ends. ### RTX 4080 follow-up With this fix and #135 on the capped 65,536-slot dynamic heap, the first failed request was for ten consecutive slots. The diagnostic counted 136 free slots in total and a longest free span of nine. That request genuinely could not fit. The earlier nine-slot failure on the previous build had no occupancy data. The synthetic regression above remains the direct test of the cursor fix. [Native run and memory measurements](https://github.com/Marvisak/VIctory/issues/325#issuecomment-7120215659).
jeremygold02 commented 2026-11-24 06:56:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:46:40Z.


Tested current PR head deb58a669560673b3ba6dc53903b52028b28ffe0.

  • cargo test --locked -p victory-gpu --lib descriptor::host::tests -- --test-threads=1: 4 passed, 43 filtered out. free_table_chooses_the_first_contiguous_fit_in_cursor_order checks all 256 occupancy patterns, every cursor, and request sizes 1–8 against the expected first contiguous fit; this includes cases where no fit exists. free_space_counts_separate_runs_at_the_heap_ends covers full, empty, and fragmented heaps. a_free_table_can_straddle_the_search_cursor exercises reuse when the cursor splits free tables and verifies the held tail still blocks an oversized request; the existing dynamic-slot test checks release behavior (allocator helpers, tests).

The exhaustive bitmap test is pure. The heap-integration tests return early if no host GPU is available, so the pass result alone does not establish that the host-heap branch ran.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7123264148 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7123264148). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T05:46:40Z. --- Tested current PR head `deb58a669560673b3ba6dc53903b52028b28ffe0`. - `cargo test --locked -p victory-gpu --lib descriptor::host::tests -- --test-threads=1`: 4 passed, 43 filtered out. `free_table_chooses_the_first_contiguous_fit_in_cursor_order` checks all 256 occupancy patterns, every cursor, and request sizes 1–8 against the expected first contiguous fit; this includes cases where no fit exists. `free_space_counts_separate_runs_at_the_heap_ends` covers full, empty, and fragmented heaps. `a_free_table_can_straddle_the_search_cursor` exercises reuse when the cursor splits free tables and verifies the held tail still blocks an oversized request; the existing dynamic-slot test checks release behavior ([allocator helpers](https://github.com/Marvisak/VIctory/blob/deb58a669560673b3ba6dc53903b52028b28ffe0/crates/victory-gpu/src/descriptor/host.rs#L369-L395), [tests](https://github.com/Marvisak/VIctory/blob/deb58a669560673b3ba6dc53903b52028b28ffe0/crates/victory-gpu/src/descriptor/host.rs#L879-L942)). The exhaustive bitmap test is pure. The heap-integration tests return early if no host GPU is available, so the pass result alone does not establish that the host-heap branch ran.
daemosofchaos commented 2026-11-24 13:16:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by daemosofchaos on 2026-11-24T13:16:02Z.

Review: COMMENTED


Independent Windows/WARP check on current main (ffe310eb): the nine-slot regression fails with None instead of Some(4) before the allocator change and passes with this PR's candidate-start search. The branch currently conflicts with main around the dynamic heap cap; I kept main's per-heap self.dynamic accounting and computed the regression's tail length from heap.dynamic rather than the fixed DYNAMIC constant, so it can also cover a smaller heap.

On that local port, the GPU diagnostics suite passed 56 tests (one benchmark ignored), including the 16,384-case search-order check. The workspace suite passed 345 tests with no failures (six ignored), and the asset-policy and diff checks passed. No title or game data was used. This verifies false exhaustion across the cursor, not the reported world-rendering hang.

— LocalFirst-AI

<!-- greyfinch-sync:Marvisak/VIctory:review:6039847830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251#pullrequestreview-6039847830). Originally posted by [daemosofchaos](https://github.com/daemosofchaos) on 2026-11-24T13:16:02Z. **Review:** COMMENTED --- Independent Windows/WARP check on current main (`ffe310eb`): the nine-slot regression fails with `None` instead of `Some(4)` before the allocator change and passes with this PR's candidate-start search. The branch currently conflicts with main around the dynamic heap cap; I kept main's per-heap `self.dynamic` accounting and computed the regression's tail length from `heap.dynamic` rather than the fixed `DYNAMIC` constant, so it can also cover a smaller heap. On that local port, the GPU diagnostics suite passed 56 tests (one benchmark ignored), including the 16,384-case search-order check. The workspace suite passed 345 tests with no failures (six ignored), and the asset-policy and diff checks passed. No title or game data was used. This verifies false exhaustion across the cursor, not the reported world-rendering hang. — LocalFirst-AI
mercuryVM commented 2026-11-24 13:24:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T13:24:11Z.

Review: APPROVED


Tested deb58a6 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 46 passed, including free_table_chooses_the_first_contiguous_fit_in_cursor_order, an exhaustive check over every 8-slot occupancy mask, cursor and size, against a brute-force first fit in cursor order.

  • Applying the cursor to start slots instead of to the scan fixes the missed span (a table that begins before the cursor and runs past it). Skipping to offset + 1 after an occupied slot keeps the search linear-ish.
  • The richer warning (cap, free, longest) tells fragmentation apart from real exhaustion, which is useful next to #336 and #688.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6039963994 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251#pullrequestreview-6039963994). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T13:24:11Z. **Review:** APPROVED --- Tested deb58a6 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-gpu -- --test-threads=1` 46 passed, including `free_table_chooses_the_first_contiguous_fit_in_cursor_order`, an exhaustive check over every 8-slot occupancy mask, cursor and size, against a brute-force first fit in cursor order. - Applying the cursor to start slots instead of to the scan fixes the missed span (a table that begins before the cursor and runs past it). Skipping to `offset + 1` after an occupied slot keeps the search linear-ish. - The richer warning (`cap`, `free`, `longest`) tells fragmentation apart from real exhaustion, which is useful next to #336 and #688. AI-assisted (Claude Code).
wbnm77 commented 2026-11-24 14:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wbnm77 on 2026-11-24T14:03:27Z.


On Windows 10 Pro 19045, RTX 5060 Ti driver 621.24 and Rust 1.98.1, cargo test --offline --locked -p victory-gpu descriptor::host::tests -- --nocapture --test-threads=1 passed 4 of 4 on the unmodified PR head deb58a669560673b3ba6dc53903b52028b28ffe0.

With the crossing test instrumented to require a real D3D12 heap, the nine-slot request returned None on merge base d2a4bae and passed on the PR head. The PR currently conflicts with ffe310e where #336 made the capacity per heap. A local rebase preserving the PR authorship and using heap.dynamic - 9 in the crossing fixture passed 6 of 6 in the same test group. I can share the rebase diff if useful. These were synthetic tests. Codex (GPT-6) assisted with testing, conflict resolution and this report.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133768414 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7133768414). Originally posted by [wbnm77](https://github.com/wbnm77) on 2026-11-24T14:03:27Z. --- On Windows 10 Pro 19045, RTX 5060 Ti driver 621.24 and Rust 1.98.1, `cargo test --offline --locked -p victory-gpu descriptor::host::tests -- --nocapture --test-threads=1` passed 4 of 4 on the unmodified PR head `deb58a669560673b3ba6dc53903b52028b28ffe0`. With the crossing test instrumented to require a real D3D12 heap, the nine-slot request returned `None` on merge base `d2a4bae` and passed on the PR head. The PR currently conflicts with `ffe310e` where #336 made the capacity per heap. A local rebase preserving the PR authorship and using `heap.dynamic - 9` in the crossing fixture passed 6 of 6 in the same test group. I can share the rebase diff if useful. These were synthetic tests. Codex (GPT-6) assisted with testing, conflict resolution and this report.
tcurtsinger commented 2026-11-24 16:05:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tcurtsinger on 2026-11-24T15:33:04Z.


Thanks for checking the crossing case on hardware and WARP. I merged current main (ffe310e) into this branch at f0eddd8. The allocator keeps #336’s per-heap capacity and searches candidate table starts across the cursor. The regression now sizes its held tail from heap.dynamic - 9. Once a host device is available, failure to create the test heap also fails the test.

I ran the same nine-slot regression on Windows D3D12 WARP. Main returned None for the available table at slot 4. All six descriptor tests passed on the updated PR, including the exhaustive search-order test.

The workspace passed 345 tests with default features and 349 with diagnostics. Six were ignored in each run. Both workspace Clippy configurations passed with warnings denied, along with the asset-policy and diff checks.

AI-assisted implementation and testing.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136216807 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7136216807). Originally posted by [tcurtsinger](https://github.com/tcurtsinger) on 2026-11-24T15:33:04Z. --- Thanks for checking the crossing case on hardware and WARP. I merged current main (`ffe310e`) into this branch at `f0eddd8`. The allocator keeps #336’s per-heap capacity and searches candidate table starts across the cursor. The regression now sizes its held tail from `heap.dynamic - 9`. Once a host device is available, failure to create the test heap also fails the test. I ran the same nine-slot regression on Windows D3D12 WARP. Main returned `None` for the available table at slot 4. All six descriptor tests passed on the updated PR, including the exhaustive search-order test. The workspace passed 345 tests with default features and 349 with diagnostics. Six were ignored in each run. Both workspace Clippy configurations passed with warnings denied, along with the asset-policy and diff checks. AI-assisted implementation and testing.
upstream-sync closed this pull request 2026-11-24 19:01:59 +00:00

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!251
No description provided.