Skip unrelated buffer slots in each spread heap scan #24

Merged
UwUCammie merged 1 commit from upstream-pr/24 into main 2026-11-26 08:17:50 +00:00
UwUCammie commented 2026-11-25 23:45:10 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by UwUCammie on 2026-11-25T23:45:10Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6616113237 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-25T23:45:10Z. --- 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.
gomeaw commented 2026-11-26 00:02:10 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by gomeaw on 2026-11-26T00:02:10Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:review:6066714642 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#pullrequestreview-6066714642). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-26T00:02:10Z. --- 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://github.com/avatarmanz/VIctory-7900XTX/issues/35)
Adika713 commented 2026-11-26 00:19:52 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Adika713 on 2026-11-26T00:19:52Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7178642953 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7178642953). Originally posted by [Adika713](https://github.com/Adika713) on 2026-11-26T00:19:52Z. --- 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.
iLucasRT commented 2026-11-26 03:57:04 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by iLucasRT on 2026-11-26T03:57:04Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7182163198 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7182163198). Originally posted by [iLucasRT](https://github.com/iLucasRT) on 2026-11-26T03:57:04Z. --- 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.
gomeaw commented 2026-11-26 07:41:05 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by gomeaw on 2026-11-26T07:41:05Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185721826 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7185721826). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-26T07:41:05Z. --- 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.
avatarmanz commented 2026-11-26 07:56:01 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185994921 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/24#issuecomment-7185994921). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:56:01Z. --- Merged into main in the next push (tests pass); thanks.
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!24
No description provided.