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

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

@⁠kalijerry on GitHub · 2026-11-26 03:22 UTC · original
kalijerry:fix/sharded-dynamic-slots → main · +381 −94 · 3 files · 1 commits · open

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.
**@⁠kalijerry** on GitHub · 2026-11-26 03:22 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/96) `kalijerry:fix/sharded-dynamic-slots` → `main` · +381 −94 · 3 files · 1 commits · open ## 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.
The dynamic slot 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: 2,800 draws a frame dropped while thousands of slots were
free, 0.3-0.4 s a frame spent searching.

Keep the free slots as runs in eight sharded pools, each behind its own
lock, and take the smallest run that holds the table. A run given back
joins its neighbours, so a pool cut into pieces is whole again. Requests
start at a shard that turns over, so threads spread instead of queueing.

Also take the largest view heap the card makes (1,835,008 on an RTX 3080)
instead of the portable 1,000,000, and give the pool room out of the
title's own slots when the title reaches past the host's cap, keeping a
quarter of the limit for direct title slots. Tables past the cap are made
afresh in the pool anyway; on a capped heap the old sizing left the pool
with a few hundred slots, and refusals of 2-slot tables showed it full.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:32:07 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:36 UTC · original

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

**@⁠avatarmanz** on GitHub · 2026-11-26 07:36 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/96#issuecomment-7185630684) Left open: replaces the dynamic descriptor allocator for every card (overlaps #47 and #48); needs an in-game check on the 7900 XTX first.
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-27 02:53 UTC · original

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).

**@⁠Jesper-Andersson** on GitHub · 2026-11-27 02:53 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/96#issuecomment-7208516036) 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 has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.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/96/head:github-bot/gh-96'
git switch 'github-bot/gh-96'

Merge

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