descriptor: replace HostHeap::dynamic Vec<bool> scan with u64 bitset #444

Open
github-bot wants to merge 1 commit from github-bot/gh-444 into main AGit
Owner

@⁠Wiktorxd-1 on GitHub · 2026-11-27 22:35 UTC · original
Wiktorxd-1:perf/dynamic-slot-bitset → main · +128 −24 · 1 files · 1 commits · open

What this fixes

HostHeap::dynamic (crates/victory-gpu/src/descriptor/host.rs) tracks 262,144 to 1,048,576 dynamic descriptor slots behind a single Mutex shared by all VICTORY_THIN=1 recording threads. Previously it stored Vec<bool> (256 KiB–1 MiB) and scanned 1 byte at a time on every uncached descriptor table, root SRV, and root UAV allocation, and HostHeap::release iterated slots.iter() byte-by-byte.

Replacing Vec<bool> with a Vec<u64> bitset (4 KiB–16 KiB, 64 slots per u64):

  • shrinks the ring 16× so it fits in L1 cache;
  • skips 64 taken/free slots in a single instruction (taken == u64::MAX / taken == 0) and locates free runs via trailing_zeros() / trailing_ones();
  • clears and counts released slots via count_ones() and word masks in HostHeap::release;
  • preserves non-multiple-of-64 self.dynamic bounds (trailing padding bits in the final word are initialized to 1 and never cleared by release) and no-wrap-past-end semantics across cursor.

The commits

  1. Replace HostHeap::dynamic Vec<bool> scan with u64 bitset (find_free_run, set_bits, clear_and_count_bits).

Tests

  • cargo test --locked -p victory-gpu --lib descriptor::host::tests (47 passed; 0 failed, including dynamic_slots_are_held_until_released, dynamic_search_can_find_a_run_across_the_cursor, dynamic_slots_populate_and_clear_stride_table, dynamic_slots_are_given_back_only_to_the_heap_that_took_them)
  • cargo build --release --locked -p victory (succeeded)
  • Launched target\release\victory.exe via scripts\play-nvidia.ps1 (35s, warns=0, crashes.log=False).

Setup

NVIDIA GeForce RTX 5070, driver 621.14.0, Windows 11 (10.0.26300). Series S profile, DLSS Performance, Frame Generation 6x. My own dump: <game dir>. No game files are attached or quoted.

This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.

**@⁠Wiktorxd-1** on GitHub · 2026-11-27 22:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/444) `Wiktorxd-1:perf/dynamic-slot-bitset` → `main` · +128 −24 · 1 files · 1 commits · open ## What this fixes `HostHeap::dynamic` (`crates/victory-gpu/src/descriptor/host.rs`) tracks 262,144 to 1,048,576 dynamic descriptor slots behind a single `Mutex` shared by all `VICTORY_THIN=1` recording threads. Previously it stored `Vec<bool>` (256 KiB–1 MiB) and scanned 1 byte at a time on every uncached descriptor table, root SRV, and root UAV allocation, and `HostHeap::release` iterated `slots.iter()` byte-by-byte. Replacing `Vec<bool>` with a `Vec<u64>` bitset (4 KiB–16 KiB, 64 slots per `u64`): - shrinks the ring 16× so it fits in L1 cache; - skips 64 taken/free slots in a single instruction (`taken == u64::MAX` / `taken == 0`) and locates free runs via `trailing_zeros()` / `trailing_ones()`; - clears and counts released slots via `count_ones()` and word masks in `HostHeap::release`; - preserves non-multiple-of-64 `self.dynamic` bounds (trailing padding bits in the final word are initialized to `1` and never cleared by `release`) and no-wrap-past-end semantics across `cursor`. ## The commits 1. **Replace `HostHeap::dynamic` `Vec<bool>` scan with `u64` bitset** (`find_free_run`, `set_bits`, `clear_and_count_bits`). ## Tests - `cargo test --locked -p victory-gpu --lib descriptor::host::tests` (`47 passed; 0 failed`, including `dynamic_slots_are_held_until_released`, `dynamic_search_can_find_a_run_across_the_cursor`, `dynamic_slots_populate_and_clear_stride_table`, `dynamic_slots_are_given_back_only_to_the_heap_that_took_them`) - `cargo build --release --locked -p victory` (succeeded) - Launched `target\release\victory.exe` via `scripts\play-nvidia.ps1` (`35s`, `warns=0`, `crashes.log=False`). ## Setup NVIDIA GeForce RTX 5070, driver `621.14.0`, Windows 11 (`10.0.26300`). Series S profile, DLSS Performance, Frame Generation 6x. My own dump: `<game dir>`. No game files are attached or quoted. This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 22:38:41 +00:00
Author
Owner

@⁠Rafa7046 on GitHub · 2026-11-28 01:28 UTC · original

Measured on an RTX 5080 16 GB + Ryzen 9 9950X3D (Series X, 1440p, DLSS Performance, frame generation off, diagnostics build on 64d4931 with only this PR applied, pipelines made ahead with victory warm), same stretch each run: Lucia's arrest cutscenes, then Jason on the boat and a minute standing still.

Cutscenes, fps (median) Boat, fps preparing in the cutscenes
main, run 1 37.4 35.8 19.6 ms
main, run 2 35.0 34.7 21.4 ms
with #444 35.5 35.0 21.2 ms

Two runs of plain main differ by about 2.4 fps, so this is within the run-to-run spread on this machine: no measurable change in frame rate here, and no new warnings, faults or crashes in the log. On this card the frame is set by the submitting thread (about 21 ms of a 28 ms frame), which is probably why a saving of this size does not show.

Same machine and scene with and without the title's ray tracing: #535.

**@⁠Rafa7046** on GitHub · 2026-11-28 01:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/444#issuecomment-7231690115) Measured on an RTX 5080 16 GB + Ryzen 9 9950X3D (Series X, 1440p, DLSS Performance, frame generation off, diagnostics build on `64d4931` with only this PR applied, pipelines made ahead with `victory warm`), same stretch each run: Lucia's arrest cutscenes, then Jason on the boat and a minute standing still. | | Cutscenes, fps (median) | Boat, fps | `preparing` in the cutscenes | |---|---|---|---| | `main`, run 1 | 37.4 | 35.8 | 19.6 ms | | `main`, run 2 | 35.0 | 34.7 | 21.4 ms | | **with #444** | **35.5** | **35.0** | **21.2 ms** | Two runs of plain `main` differ by about 2.4 fps, so this is within the run-to-run spread on this machine: no measurable change in frame rate here, and no new warnings, faults or crashes in the log. On this card the frame is set by the submitting thread (about 21 ms of a 28 ms frame), which is probably why a saving of this size does not show. Same machine and scene with and without the title's ray tracing: #535.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-444'
git switch 'github-bot/gh-444'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-444'
git switch 'github-bot/gh-444'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-444'
git switch 'main'
git merge --squash 'github-bot/gh-444'
git switch 'main'
git merge --ff-only 'github-bot/gh-444'
git switch 'main'
git merge 'github-bot/gh-444'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.