Search free runs in eight shards, best fit, and size the pool for a capped heap #96

Open
kalijerry wants to merge 1 commit from upstream-pr/96 into main
kalijerry commented 2026-11-26 03:22:13 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by kalijerry on 2026-11-26T03:22:13Z.


What this does

The dynamic descriptor pool was one lock and a bit scan from a cursor. Once the world had cut the free slots into pieces, every table that did not fit walked the whole ring under the lock every recording thread needs, and the shortest length that found nothing refused every longer table for the rest of the frame.

Measured on an RTX 3080 10 GB, 30 s warm sample, 0a43566 + this tree: 2,800 draws a frame dropped with thousands of slots free, 0.30-0.40 s a frame spent inside the search.

This PR keeps the free slots as runs in eight pools, each behind its own lock, and takes the smallest run that holds the table. A run given back joins its neighbours. Requests start at a shard that turns over.

It also sizes the heap for a capped adapter: take the largest view heap the card actually makes (1,835,008 on a 3080, instead of the 1,000,000 portable fallback) and give the pool room out of the title's own slots past the cap, keeping a quarter of the limit for direct title slots. Those tables are made afresh in the pool anyway; the old sizing left it with a few hundred slots, and refusals of 2-slot tables showed the pool was full, not only cut up.

Relation to #47

#47 (by @gomeaw) also replaces the scan with coalesced free ranges, single-threaded and keeping the old cursor order. The two are complementary and conflict textually in descriptor/host.rs:

  • #47 removes the search cost but keeps one lock for all recording threads and the too_long refusal shortcut.
  • This PR removes the shared lock (8 shards), and takes best-fit rather than first-fit so a small table cannot eat the only wide run.
  • The heap sizing here is the part #47 does not touch; without it a capped adapter can still run the pool dry.

Verification

  • cargo test -p victory-gpu --lib on Windows: 328 passed, including two new tests (smallest-run choice, neighbour joining) and the sharded-run/give accounting.
  • Live RTX 3080: dropped draws fall from 2,800/frame to single digits with the ray-tracing builder on; VICTORY_PLACED_ORDER fill waits drop to 13-17 ms from 16-25 ms.
  • cargo check --profile diag -p victory --features diagnostics clean.
<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5503404015 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/96). Originally posted by [kalijerry](https://github.com/kalijerry) on 2026-11-26T03:22:13Z. --- ## What this does The dynamic descriptor pool was one lock and a bit scan from a cursor. Once the world had cut the free slots into pieces, every table that did not fit walked the whole ring **under the lock every recording thread needs**, and the shortest length that found nothing refused every longer table for the rest of the frame. Measured on an RTX 3080 10 GB, 30 s warm sample, `0a43566` + this tree: **2,800 draws a frame dropped with thousands of slots free, 0.30-0.40 s a frame spent inside the search**. This PR keeps the free slots as runs in eight pools, each behind its own lock, and takes the smallest run that holds the table. A run given back joins its neighbours. Requests start at a shard that turns over. It also sizes the heap for a capped adapter: take the largest view heap the card actually makes (1,835,008 on a 3080, instead of the 1,000,000 portable fallback) and give the pool room out of the title's own slots past the cap, keeping a quarter of the limit for direct title slots. Those tables are made afresh in the pool anyway; the old sizing left it with a few hundred slots, and refusals of 2-slot tables showed the pool was full, not only cut up. ## Relation to #47 #47 (by @gomeaw) also replaces the scan with coalesced free ranges, single-threaded and keeping the old cursor order. The two are complementary and conflict textually in `descriptor/host.rs`: - #47 removes the search cost but keeps **one lock for all recording threads** and the `too_long` refusal shortcut. - This PR removes the shared lock (8 shards), and takes best-fit rather than first-fit so a small table cannot eat the only wide run. - The heap sizing here is the part #47 does not touch; without it a capped adapter can still run the pool dry. ## Verification - `cargo test -p victory-gpu --lib` on Windows: **328 passed**, including two new tests (smallest-run choice, neighbour joining) and the sharded-run/`give` accounting. - Live RTX 3080: dropped draws fall from 2,800/frame to single digits with the ray-tracing builder on; `VICTORY_PLACED_ORDER` fill waits drop to 13-17 ms from 16-25 ms. - `cargo check --profile diag -p victory --features diagnostics` clean.
avatarmanz commented 2026-11-26 07:36:01 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T07:36:01Z.


Left open: replaces the dynamic descriptor allocator for every card (overlaps #47 and #48); needs an in-game check on the 7900 XTX first.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185630684 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/96#issuecomment-7185630684). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:36:01Z. --- Left open: replaces the dynamic descriptor allocator for every card (overlaps #47 and #48); needs an in-game check on the 7900 XTX first.
Jesper-Andersson commented 2026-11-27 02:53:01 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Jesper-Andersson on 2026-11-27T02:53:01Z.


Test report from an RTX 2070 SUPER 8 GB (Turing, driver 621.14), Windows 11, 32 GB RAM, Series S + DLSS.

This card takes no view heap above 1,000,000 (views=1000000 raw_twins=false), so the larger-heap probe changes nothing here. The split does: count=1245184 fitted=249999 dynamic=750000.

Setup: main 014d52d plus #203 (DLSS), plus a local switch that turns off the early table release from 1e72861. Early release is off in both runs: with it on, this card showed grid-like shadows on walls. B adds this PR's defe56b, cherry-picked. It conflicted only in draw.rs, where main has since rewritten the table loop; I kept main's loop, so the TablesPastCap counter is not in this build. Both runs used the same worktree and route, about 3 min each in the world.

A: main B: + #96
dynamic tables asked / refused 255,742 / 43,621 (18.1 %) 318,544 / 0
slot search, ms per frame (mean / max) 14.2 / 58.3 7.5 / 16.0
indirect draws dropped (prepare failed) 29,983 (up to 2,472 a frame) 1
draws per frame (median) 3,638 5,007
ms per frame (median / p90) 351 / 1,877 388 / 483

On screen, B had less mesh flicker, and the smearing and brightness pumping were gone. Black skin and some black textures remained in both runs; I believe those come from elsewhere, not from descriptor slots.

The median frame is a little slower in B because it draws about 40 % more. The p90 is much lower.

This report was made with AI assistance (Claude Code).

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7208516036 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/96#issuecomment-7208516036). Originally posted by [Jesper-Andersson](https://github.com/Jesper-Andersson) on 2026-11-27T02:53:01Z. --- Test report from an RTX 2070 SUPER 8 GB (Turing, driver 621.14), Windows 11, 32 GB RAM, Series S + DLSS. This card takes no view heap above 1,000,000 (`views=1000000 raw_twins=false`), so the larger-heap probe changes nothing here. The split does: `count=1245184 fitted=249999 dynamic=750000`. Setup: `main` 014d52d plus #203 (DLSS), plus a local switch that turns off the early table release from 1e72861. Early release is off in both runs: with it on, this card showed grid-like shadows on walls. B adds this PR's defe56b, cherry-picked. It conflicted only in `draw.rs`, where `main` has since rewritten the table loop; I kept `main`'s loop, so the `TablesPastCap` counter is not in this build. Both runs used the same worktree and route, about 3 min each in the world. | | A: main | B: + #96 | |---|---|---| | dynamic tables asked / refused | 255,742 / 43,621 (18.1 %) | 318,544 / 0 | | slot search, ms per frame (mean / max) | 14.2 / 58.3 | 7.5 / 16.0 | | indirect draws dropped (`prepare failed`) | 29,983 (up to 2,472 a frame) | 1 | | draws per frame (median) | 3,638 | 5,007 | | ms per frame (median / p90) | 351 / 1,877 | 388 / 483 | On screen, B had less mesh flicker, and the smearing and brightness pumping were gone. Black skin and some black textures remained in both runs; I believe those come from elsewhere, not from descriptor slots. The median frame is a little slower in B because it draws about 40 % more. The p90 is much lower. This report was made with AI assistance (Claude Code).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/96:upstream-pr/96'
git switch 'upstream-pr/96'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/96'
git switch 'upstream-pr/96'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/96'
git switch 'upstream-pr/96'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/96'
git switch 'main'
git merge --squash 'upstream-pr/96'
git switch 'main'
git merge --ff-only 'upstream-pr/96'
git switch 'main'
git merge 'upstream-pr/96'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!96
No description provided.