perf(gpu): shard HostHeap::mirror across 256 descriptor stripes #16
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-25T16:32:53Z.
Replace
HostHeap's single globalmade: Mutex<Vec<u64>>andkept: Mutex<...>with a lock-freeAtomicU64fast-path + 256 cache-line-aligned descriptor stripes and canonical-orderstale != indexinvalidation (crates/victory-gpu/src/descriptor/host.rs), bringing KLBF Lab up to parity withvictory-perf/flamingoon high-draw scenes.What is in it (
crates/victory-gpu/src/descriptor/host.rs)made: Box<[AtomicU64]>):HostHeap::mirrorcheckstag == VIEW_TAG && key != 0 && self.made[index].load(Ordering::Acquire) == key && let Some(view) = view_at(i, generation), publishingkey(Ordering::Release) only aftermake()/null_for()andreplace_kept()complete.texture_views_remadeclearsmade[slot]under its stripe guard while rewriting views so concurrent fast-path readers never observe a half-updated descriptor.kept+ lock-freecopied: shards slow-pathCreate*View(make()) and kept resource slots across 256 cache-line-aligned stripes ((index & 255, index >> 8)), retiring displacedID3D12Resourcehandles viacrate::host::retirestrictly outsidekeptandslot_locks.copiedusesOnceLock<Box<[AtomicU64]>>CAS.stale != indexinvalidation:Spans::clashing_slots+HostHeap::note_buffer_checked(..., held_stripes)pre-checks missing stale stripes underplacedbefore mutating state;HostHeap::mirrormerges missing stripes intoneeded_stripesand acquires them strictly in ascending index order (0..255).mirror_release_acquire_later_and_forget_semantics,concurrent_cache_hit_and_distinct_create_view_storm,concurrent_same_slot_and_stale_invalidations_do_not_deadlock,concurrent_stale_invalidation_and_cbv_overwrite_never_clobbers_live_slot,concurrent_texture_views_remade_and_fast_path_stay_consistent, and 8-thread--releasebenchmarks.Verification (
f5a960c, Windows 11 Build 26300, NVIDIA GeForce RTX 4070 SUPER, Rust 1.98.1)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked --lib descriptor::host::tests:: -- --test-threads=1: 24 passed, 0 failed, 2 ignored (#[ignore]benches) (0D3D12 debug errors/warnings).cargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): 0 warnings incrates/victory-gpu/src/descriptor/host.rs(fails only on pre-existingorigin/klbf-amd/betalints in untouchedsgd5.rs:557,resource.rs:2667,draw.rs:2441,indirect.rs:1574).cargo test --workspace --locked: 585 passed, 1 pre-existing failed, 14 ignored (sole failure is pre-existingorigin/klbf-amd/betaxtaskpolicy::tests::repository_passes_policyon untouchedcrates/victory-shader/src/emit/lower.rs> 512 KiB anddocs/klbf/logo.svg).0ad4037) vs AFTER (f5a960c) 8-thread--releasebenchmark on RTX 4070 SUPER:bench_mirror_fast_path_8_threads[cbv_inline](400k hits): median50.639 -> 0.782 ms(64.8x faster,7.90 -> 511.51 Mops/s)bench_mirror_fast_path_8_threads[mixed_cbv_srv](400k hits): median52.075 -> 13.479 ms(3.86x faster,7.68 -> 29.68 Mops/s)bench_mirror_slow_path_create_views_8_threads(16,384 slots): median12.002 -> 6.569 ms(1.83x faster,1,365 -> 2,494 Kviews/s).Not tested
AI use
gemini-4-hydrogen-xhigh+gemini-4-neon-xhigh).Imported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-25T16:52:53Z.
I ran the four new concurrent descriptor tests on Windows with
VICTORY_D3D12_WARP=1and the diagnostics feature. All four passed. In the verification checkout I made the test setup fail if it could not create the host or descriptor heap, so a missing adapter could not silently skip the assertions. This covers the software backend. I did not measure performance.Windows WARP test output
Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T17:02:35Z.
Thanks a lot @Vladimir-Human! Noted. I'll test it on the RX 9070 XT in the next test build and report back here.
Imported from PastiiJay/klbf-lab. Originally posted by akimfomin on 2026-11-28T01:05:53Z.
PortBridge surfaced this work while checking Vice-Tay #390. I verified the two PR heads
f5a960cand59563b9directly. Git found no common ancestor for those refs. The patches touch the same descriptor file and overlap at the queue entry, but certify different steps: mirrored descriptor publication here and queued writes plus final bake in #390.I also saw your existing KLBF port at
6f98983and HandshakeHackin’s WARP checks. A complementary test for that port would keep the existing stale-view and CBV-overwrite controls, then take #390’s cross-shard queue case: update a texture after the advisory bake and require that the final bake binds the newer descriptor. It can use generated slots on WARP. If your team or agent wants an independent check on a follow-up, PortBridge #98 takes just its public PR, target SHA and expected behavior.Imported from PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-28T18:14:00Z.
Re-ported onto
stable-amd(v26.11.6) in #182 (https://github.com/PastiiJay/klbf-lab/pull/182).Pull request closed