Heap: dynamic slot search over a bitset, a word of 64 taken or free slots per step #1719

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

@⁠101Leafy on GitHub · 2026-11-28 23:43 UTC · original
101Leafy:nv/slot-bitset → main · +163 −27 · 3 files · 2 commits · open

The search for a run of free dynamic descriptor slots walked the taken flags one slot at a time over a Vec, so with a busy heap every table that asked for slots could step through most of the ring before it found a run or gave up.

The taken flags are now a bitset, and the search looks at a word of 64 slots per step: a word that is all taken or all free is passed over at once, and trailing_zeros finds where the next free or taken slot starts. It finds the same run as before, from the cursor on and then from the start up to cursor + n - 1, and release counts the slots it gives back the same way. A test checks it against the old slot by slot search on random fills.

There is no switch since nothing changes but the time the search takes.

**@⁠101Leafy** on GitHub · 2026-11-28 23:43 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1719) `101Leafy:nv/slot-bitset` → `main` · +163 −27 · 3 files · 2 commits · open The search for a run of free dynamic descriptor slots walked the taken flags one slot at a time over a Vec<bool>, so with a busy heap every table that asked for slots could step through most of the ring before it found a run or gave up. The taken flags are now a bitset, and the search looks at a word of 64 slots per step: a word that is all taken or all free is passed over at once, and trailing_zeros finds where the next free or taken slot starts. It finds the same run as before, from the cursor on and then from the start up to cursor + n - 1, and release counts the slots it gives back the same way. A test checks it against the old slot by slot search on random fills. There is no switch since nothing changes but the time the search takes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 23:47:04 +00:00
Author
Owner

@⁠stokeer on GitHub · 2026-11-29 01:27 UTC · original

This breaks the diagnostics build (cargo build --profile diag -p victory --features diagnostics):

error[E0599]: no method named `get` found for struct `taken::Taken` in the current scope
    --> crates\victory-gpu\src\descriptor\host.rs:2206:79

slot_story in descriptor/host.rs is built with diagnostics and calls Taken::get, which this PR makes #[cfg(test)]. Making it available to both fixes it:

#[cfg(any(test, feature = "diagnostics"))]
pub(crate) fn get(&self, at: usize) -> Option<bool> {

Measured on a Ryzen 7 5700 + RTX 3060 Ti 8 GB (merged on f9dfb76f with seven other open PRs): no frame-time change in the prologue cell, ~53 ms against ~51 ms without them.

**@⁠stokeer** on GitHub · 2026-11-29 01:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1719#issuecomment-7248794431) This breaks the diagnostics build (`cargo build --profile diag -p victory --features diagnostics`): ``` error[E0599]: no method named `get` found for struct `taken::Taken` in the current scope --> crates\victory-gpu\src\descriptor\host.rs:2206:79 ``` `slot_story` in `descriptor/host.rs` is built with `diagnostics` and calls `Taken::get`, which this PR makes `#[cfg(test)]`. Making it available to both fixes it: ```rust #[cfg(any(test, feature = "diagnostics"))] pub(crate) fn get(&self, at: usize) -> Option<bool> { ``` Measured on a Ryzen 7 5700 + RTX 3060 Ti 8 GB (merged on f9dfb76f with seven other open PRs): no frame-time change in the prologue cell, ~53 ms against ~51 ms without them.
github-bot force-pushed github-bot/gh-1719 from 6f44045920 to 2a0c971728 2026-11-29 01:47:41 +00:00 Compare
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

Tested on 9800X3D + RTX 5070 Ti 16 GB across 20+ min sessions + full GPU unit suite. Dynamic bitset slot search ran cleanly with zero heap allocation or slot-reuse issues.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1719#issuecomment-7251376031) Tested on 9800X3D + RTX 5070 Ti 16 GB across 20+ min sessions + full GPU unit suite. Dynamic bitset slot search ran cleanly with zero heap allocation or slot-reuse issues.
Author
Owner

@⁠101Leafy on GitHub · 2026-11-29 06:44 UTC · original

Thanks, fixed in b6e1546053: Taken::get is now built for diagnostics too, as you suggested.

**@⁠101Leafy** on GitHub · 2026-11-29 06:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1719#issuecomment-7252040511) Thanks, fixed in b6e1546053: `Taken::get` is now built for `diagnostics` too, as you suggested.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/descriptor/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1719/head:github-bot/gh-1719'
git switch 'github-bot/gh-1719'

Merge

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