Skip unrelated buffer slots in each spread heap scan #24

Manually merged
github merged 1 commit from github-bot/gh-24 into main 2026-11-26 08:21:46 +00:00 AGit
Owner

@⁠UwUCammie on GitHub · 2026-11-25 23:45 UTC · original
UwUCammie:perf/avatar-mask-heap-rescan → main · +40 −16 · 2 files · 1 commits · merged 2026-11-26 08:17 UTC

The default heap spread visits one sixteenth of the live buffer slots per pass, but it enumerates every live slot to find that sixteenth. With 83,000 live slots it tests roughly 78,000 indices per pass that it can skip.

Apply a repeating mask to each 64-slot word first, then enumerate the remaining set bits. The compiler checks that the partition count divides the word size. The full scan and draining changed slots retain their order and the atomic loads keep their existing ordering.

On a Ryzen 7 9700X, eight complete rounds through a synthetic 1.2-million-slot heap with 83,000 live slots took a median of 6.28 ms before and 1.42 ms after. With 128 live slots it measured 0.93 and 0.78 ms. Those are CPU enumeration times. The benchmark checks all sixteen result vectors for equality and alternates measurement order. Benchmark source and command

The existing set and drain test and the new partition regression test passed under Wine 11.22 on an RX 7900 XT system with RADV 26.3.1. The regression covers multiple complete words, a partial last word and an empty partition beyond the round.

**@⁠UwUCammie** on GitHub · 2026-11-25 23:45 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24) `UwUCammie:perf/avatar-mask-heap-rescan` → `main` · +40 −16 · 2 files · 1 commits · merged 2026-11-26 08:17 UTC The default heap spread visits one sixteenth of the live buffer slots per pass, but it enumerates every live slot to find that sixteenth. With 83,000 live slots it tests roughly 78,000 indices per pass that it can skip. Apply a repeating mask to each 64-slot word first, then enumerate the remaining set bits. The compiler checks that the partition count divides the word size. The full scan and draining changed slots retain their order and the atomic loads keep their existing ordering. On a Ryzen 7 9700X, eight complete rounds through a synthetic 1.2-million-slot heap with 83,000 live slots took a median of 6.28 ms before and 1.42 ms after. With 128 live slots it measured 0.93 and 0.78 ms. Those are CPU enumeration times. The benchmark checks all sixteen result vectors for equality and alternates measurement order. [Benchmark source and command](https://github.com/UwUCammie/VIctory-7900XTX/tree/bench/avatar-first-room-radv/benchmarks#descriptor-heap-rescan) The existing set and drain test and the new partition regression test passed under Wine 11.22 on an RX 7900 XT system with RADV 26.3.1. The regression covers multiple complete words, a partial last word and an empty partition beyond the round.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:26 +00:00
Author
Owner

@⁠Adika713 on GitHub · 2026-11-26 00:19 UTC · original

On 888bf1e (native Windows, RX 6950 XT / Ryzen 5 3600, rustc/cargo 1.98.1, serial tests), spread_scan_visits_each_live_slot_in_its_original_part passes 1/1. The descriptor-host subset passes 33/33 once the pre-existing views_are_made_beside_the_heap_and_copied_in failure is skipped; that same failure occurs 10/10 on unmodified main 0a43566 here. Full lib with that one test skipped: PR 326 passed, 0 failed, 34 ignored versus 325 passed, 0 failed, 34 ignored on main. I checked that the mask is applied only to the spread scan; take() still drains changed slots with the original order and atomics. I did not measure throughput or FPS on this host, so this is a correctness check, not a performance measurement. I made no repository change.

AI-assisted: OpenCode, model Big Pickle. No game data.

**@⁠Adika713** on GitHub · 2026-11-26 00:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7178642953) On `888bf1e` (native Windows, RX 6950 XT / Ryzen 5 3600, rustc/cargo 1.98.1, serial tests), `spread_scan_visits_each_live_slot_in_its_original_part` passes 1/1. The descriptor-host subset passes 33/33 once the pre-existing `views_are_made_beside_the_heap_and_copied_in` failure is skipped; that same failure occurs 10/10 on unmodified `main` `0a43566` here. Full lib with that one test skipped: PR `326 passed, 0 failed, 34 ignored` versus `325 passed, 0 failed, 34 ignored` on `main`. I checked that the mask is applied only to the spread scan; `take()` still drains changed slots with the original order and atomics. I did not measure throughput or FPS on this host, so this is a correctness check, not a performance measurement. I made no repository change. AI-assisted: OpenCode, model Big Pickle. No game data.
Author
Owner

@⁠gomeaw on GitHub · 2026-11-26 00:02 UTC · original · reviewed

I ran the descriptor-host tests from 888bf1e on native Windows. All 34 passed, including the new spread-partition test and the existing dynamic range and cursor regressions. The asset policy passed too. Windows run

I checked that the mask applies only to the spread scan. Draining changed slots keeps its original order and memory ordering. This is an independent CPU improvement alongside the dynamic-range search hotspot measured on RTX 5080. NVIDIA report

**@⁠gomeaw** on GitHub · 2026-11-26 00:02 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#pullrequestreview-6066714642) · **reviewed** I ran the descriptor-host tests from `888bf1e` on native Windows. All 34 passed, including the new spread-partition test and the existing dynamic range and cursor regressions. The asset policy passed too. [Windows run](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45724980886) I checked that the mask applies only to the spread scan. Draining changed slots keeps its original order and memory ordering. This is an independent CPU improvement alongside the dynamic-range search hotspot measured on RTX 5080. [NVIDIA report](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/issues/35)
Author
Owner

@⁠iLucasRT on GitHub · 2026-11-26 03:57 UTC · original

Tested on an RX 7900 XTX 24 GB, Ryzen 7 5800X3D, 64 GB RAM, Windows 11. The per-frame time of "looking at slots" in the heap pass:

median p90
without (YP3, 661 s) 21.6 ms 29.6 ms
with (YP4, 1419 s) 20.8 ms 26.4 ms

A small gain, about 4 % at the median and 11 % at p90. The sessions went through different places,
so this is only indicative. No correctness issues seen in 25 minutes.

**@⁠iLucasRT** on GitHub · 2026-11-26 03:57 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7182163198) Tested on an RX 7900 XTX 24 GB, Ryzen 7 5800X3D, 64 GB RAM, Windows 11. The per-frame time of "looking at slots" in the heap pass: | | median | p90 | |---|---|---| | without (YP3, 661 s) | 21.6 ms | 29.6 ms | | with (YP4, 1419 s) | 20.8 ms | 26.4 ms | A small gain, about 4 % at the median and 11 % at p90. The sessions went through different places, so this is only indicative. No correctness issues seen in 25 minutes.
Author
Owner

@⁠gomeaw on GitHub · 2026-11-26 07:41 UTC · original

I combined #24 with current main for the NVIDIA preview. Main added writes_of_other_views_leave_the_spans_as_under_their_lock after this branch. Its two heap.spanned.all(|_| true) calls need heap.spanned.all(u64::MAX) with #24's mask-taking API. The first combined Windows build failed with E0308 in those two calls. The preview adjustment keeps the regression's full-scan intent.

**@⁠gomeaw** on GitHub · 2026-11-26 07:41 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7185721826) I combined #24 with current main for the NVIDIA preview. Main added `writes_of_other_views_leave_the_spans_as_under_their_lock` after this branch. Its two `heap.spanned.all(|_| true)` calls need `heap.spanned.all(u64::MAX)` with #24's mask-taking API. The first combined Windows build failed with E0308 in those two calls. [The preview adjustment](https://github.com/gomeaw/VIctory-7900XTX/commit/fc0271b) keeps the regression's full-scan intent.
Author
Owner

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

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:56 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7185994921) Merged into main in the next push (tests pass); thanks.
github manually merged commit ab9f1b7256 into main 2026-11-26 08:21:46 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.