Find free descriptor tables that span the search cursor #251

Closed
github-bot wants to merge 3 commits from gh-pr/251/head into gh-pr/251/base
Owner

@⁠tcurtsinger on GitHub · 2026-11-24 01:50 UTC · original
tcurtsinger:fix/descriptor-search-cursor → main · +90 −19 · 1 files · 3 commits · closed without merging

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.

**@⁠tcurtsinger** on GitHub · 2026-11-24 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/251) `tcurtsinger:fix/descriptor-search-cursor` → `main` · +90 −19 · 1 files · 3 commits · closed without merging 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://git.gtahub.st/github/Marvisak--VIctory/issues/325).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:41 +00:00
github-bot closed this pull request 2026-11-26 03:56:41 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:46 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7123264148) 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.
Author
Owner

@⁠wbnm77 on GitHub · 2026-11-24 14:03 UTC · original

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.

**@⁠wbnm77** on GitHub · 2026-11-24 14:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7133768414) 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.
Author
Owner

@⁠tcurtsinger on GitHub · 2026-11-24 15:33 UTC · original

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.

**@⁠tcurtsinger** on GitHub · 2026-11-24 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/251#issuecomment-7136216807) 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.

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