Shard HostHeap TextureQueue to eliminate heap-wide lock convoys #390
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!390
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-390"
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?
@PetrSeifert on GitHub · 2026-11-28 00:25 UTC · original
PetrSeifert:perf/shard-texture-queue→main· +422 −204 · 1 files · 1 commits · openSummary
Replaces the single heap-wide
Mutex<TextureQueue>onHostHeapincrates/victory-gpu/src/descriptor/host.rswith 32 cache-line-paddedBTreeMapshards, a cache-line-padded atomicrevision, a separatepassmutex forTexturePass/ bake certification, and a lock-freeseen && queued.is_set(index)fast path inHostHeap::queue_texture.Motivation
On a 6C/12T Ryzen 5 7600 + RTX 4070 (
origin/main0148258, 500 msVICTORY_TIMELINEcapture in the opening cell scene spanning 11 host Presents),HostHeap::textureswas the #1 contended mutex in the process:victory-list-0..5,victory-heap-sync,victory-records-1..5,victory-views-1..3,victory-aside, and title threads), 122 waits, single stalls up to 11.13 ms (wake-one lock convoys under CPU oversubscription).HostHeap::queue_texture < HostHeap::note_buffer < HostHeap::mirror.Design & Correctness
(index >> 4) & 31): groups 16 adjacent slots per shard so contiguous table/remap walks touch few shards while concurrent workers spread across all 32 shards. Each shard keepsBTreeMapwith single-lookupEntryupserts (preserving deterministic diagnostic ordering and avoidingHashMapcapacity bloat after world load).writtenandchanged_*advance the atomicrevision(SeqCst) while holding the shard lock, before releasing it. For every shard, a concurrent write is either wholly beforesnapshot()'s visit (sosnapshot()sees it) or its revision bump lands afterTexturePass::begin()(sofinish_bake()rejects certification).queue_texturefast path: addsQueued::is_set(index)(returnsfalsewhen the bitmap is empty/unknown, unlike conservativeQueued::may(index)) soseen == trueobservations skip the shard lock when the slot is already queued.pass.Measurements (Ryzen 5 7600 6C/12T, RTX 4070 12 GB, 1080p, no RT)
Standalone A/B against
origin/main0148258with identical switches (6/2/2threads,VICTORY_PORT_GUARD=1,VICTORY_PORT_GUARD_PLAN=0,VICTORY_PORT_JOURNAL=1,VICTORY_STORE_BESIDE=1,VICTORY_COPY_BESIDE=1,VICTORY_BCPACK_TABLESset):500 ms
VICTORY_TIMELINE(diag + diagnostics, cell at 162s)origin/main(0148258)perf/shard-texture-queueTextureQueuewaits (500 ms)16.37 ms/f, 122 waits, max 11.13 ms)1.16 ms/f, 8 waits, max 3.01 ms)HostHeap::mirrorwaits5.84 ms/f)2.01 ms/f)a long list call(all threads)a landing's job(all threads)victory-list-0..5CPU run timewoken, not running yet(critical chain)Release build (
release + mimalloc + thin-LTO + cgu=1, full 185s intro + diner + cell video)prep40.17 ms -> 37.79 ms (-2.38 ms); mean FPS 19.13 -> 18.36 (within scene/streaming variance).prep32.76 ms -> 32.42 ms (-0.34 ms;copies11.60 -> 10.92 ms); mean FPS 24.17 (max 24.70) -> 23.77 (max 24.40) — within run-to-run noise on an oversubscribed 6-core CPU, where removing this convoy exposes the next contended locks (placed_texture,guards_shared) and the submit/landing/GPU critical chain.diagandreleasefull-run recordings inspected across diner and cell; zero visual regressions.Verification
cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default and--features diagnostics): clean.cargo test -p victory-gpu --lib -- --test-threads=1: 528/528 passed (default) and 595/595 passed (--features diagnostics), including new live concurrent race testsharded_texture_queue_handles_concurrent_writes_across_shards_and_invalidates_bake. (--test-threads=1used due to pre-existing parallel test flake inraw_title_copy_keeps_write_watch_and_resends_equal_bytes.)cargo run -p xtask -- policy --staged: passed (1 files ok).@akimfomin on GitHub · 2026-11-28 00:53 UTC · original
PortBridge checked
59563b9against Vice-Tay mainfe7c6e5and with the current #388 and #357 heads. Those trees are Git-clean. One compatibility test is especially useful for the new publication scheme: AnyXboxX #517 explicitly treats its early heap bake as advisory and still repeats a mandatory pass. In your concurrent shard fixture, can a descriptor rewrite between the early snapshot and final bake prove that the final submitted descriptor is the newer one, even when it lands on a different shard? This complements the enqueue race control with a producing-versus-consuming revision check.Exact comparisons and controls. If it helps this workflow, your team or agent can submit another public PR URL, target SHA and behavior to preserve via PortBridge. This is an optional, no-install check.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.