GPU: a listed view is looked up once a slot, not three times #268

Open
Joly0 wants to merge 1 commit from upstream-pr/268 into stable-amd
Joly0 commented 2026-11-29 17:03:27 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by Joly0 on 2026-11-29T17:03:27Z.


HostHeap::make_listed_in asked its per-recording map of made views three times for every slot it fills (contains_key, get, get_mut). It runs for about 110,000 slots a frame on the title's recording threads, so this changes it to one entry lookup. The slots are worked out from the thread heap's start and step, so the entry's borrow doesn't get in the way. The heap field stays (as _heap) to keep that range alive. Nothing else changes: the same views are made, copied and kept.

Measured on v26.11.14 (the commit applies cleanly there and on stable-amd): RX 7800 XT, Ryzen 9 7945HX, 32 GB, Profile S with FSR and frame generation, 2-minute bench, VICTORY_LIST_CALLS=1, two runs of each in the order base, change, change, base:

per ExecuteIndirect call base this PR
"a view made before found and copied" (make_listed) 3.75 / 3.72 µs 3.58 / 3.58 µs
whole prepare (median) 17.25 / 17.10 µs 17.00 / 17.05 µs

The slot copy part is 4 % cheaper in both runs. The whole call is about 1 % cheaper, which is too small to show in fps.

Checks: cargo clippy -p victory-gpu --all-targets -- -D warnings with and without --features diagnostics. cargo test -p victory-gpu --features diagnostics on WARP passes, apart from pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws, which fails on WARP on unchanged stable-amd too.

🤖 Generated with Claude Code

<!-- greyfinch-sync:PastiiJay/klbf-lab:issue:5553018509 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/268). Originally posted by [Joly0](https://github.com/Joly0) on 2026-11-29T17:03:27Z. --- `HostHeap::make_listed_in` asked its per-recording map of made views three times for every slot it fills (`contains_key`, `get`, `get_mut`). It runs for about 110,000 slots a frame on the title's recording threads, so this changes it to one `entry` lookup. The slots are worked out from the thread heap's start and step, so the entry's borrow doesn't get in the way. The heap field stays (as `_heap`) to keep that range alive. Nothing else changes: the same views are made, copied and kept. **Measured** on v26.11.14 (the commit applies cleanly there and on `stable-amd`): RX 7800 XT, Ryzen 9 7945HX, 32 GB, Profile S with FSR and frame generation, 2-minute bench, `VICTORY_LIST_CALLS=1`, two runs of each in the order base, change, change, base: | per ExecuteIndirect call | base | this PR | |---|---|---| | "a view made before found and copied" (`make_listed`) | 3.75 / 3.72 µs | 3.58 / 3.58 µs | | whole prepare (median) | 17.25 / 17.10 µs | 17.00 / 17.05 µs | The slot copy part is 4 % cheaper in both runs. The whole call is about 1 % cheaper, which is too small to show in fps. **Checks:** `cargo clippy -p victory-gpu --all-targets -- -D warnings` with and without `--features diagnostics`. `cargo test -p victory-gpu --features diagnostics` on WARP passes, apart from `pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws`, which fails on WARP on unchanged `stable-amd` too. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PastiiJay commented 2026-11-29 17:06:18 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-29T17:06:18Z.


thanks @Joly0, a small one with a clear win on the hot path, nice. it's passed on for the next round.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7259425195 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/268#issuecomment-7259425195). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-29T17:06:18Z. --- thanks @Joly0, a small one with a clear win on the hot path, nice. it's passed on for the next round.
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/268:upstream-pr/268'
git switch 'upstream-pr/268'

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 'stable-amd'
git merge --no-ff 'upstream-pr/268'
git switch 'upstream-pr/268'
git rebase 'stable-amd'
git switch 'stable-amd'
git merge --ff-only 'upstream-pr/268'
git switch 'upstream-pr/268'
git rebase 'stable-amd'
git switch 'stable-amd'
git merge --no-ff 'upstream-pr/268'
git switch 'stable-amd'
git merge --squash 'upstream-pr/268'
git switch 'stable-amd'
git merge --ff-only 'upstream-pr/268'
git switch 'stable-amd'
git merge 'upstream-pr/268'
git push origin 'stable-amd'
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
PastiiJay/klbf-lab!268
No description provided.