perf(victory-gpu): optimize indirect batch table, WriteLog, merge counters, and clamp shaders #10
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/MahanYTT--VIctory-MA!10
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-10"
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?
@MahanYTT on GitHub · 2026-12-04 18:27 UTC · original
MahanYTT:perf/indirect-batch-merge→mega-upgrade-v3· +595 −155 · 3 files · 1 commits · merged 2026-12-04 20:18 UTCSummary
Reduces per-execution CPU recording overhead and idle GPU clamp work across ~3,765 indirect executions/frame (
victory-ma-play-20261204-165800-18832.log):Why not root-constant-only merge signatures?
From the frame log (
3,765indirect executions/frame):2,478(65.8%) changed non-root-constant bindings,957(25.4%) changed kind/pipeline,267(7.1%) followed a recording title call, and only11(0.29%) changed root constants only (VICTORY_INDIRECT_MERGE=1is off by default). Adding root-constant-per-record signatures would affect <= 0.29% of executions, whereas the per-execution CPU path inbatch.rs,merge.rs, andindirect.rsruns on every execution.Optimizations
crates/victory-gpu/src/indirect/batch.rs:Table's per-batchVec<u32>+HashMap<(u32, u32, u32), u32>(two heap allocations +RandomState/SipHash per batch across hundreds of batches/frame) with a 16-entry inline table (INLINE_CAP = 16) that spills lazily to a 512-slot Fibonacci-hashed open-addressingOverflowtable with in-place slot replacement onTIMESsaturation.write_volatilestores per new job into a single 16-byte[u32; 4]write_volatilestore to write-combined upload memory.WriteLogfrom O(N) linear scans (up to 4,096 ranges) to sorted, coalesced disjoint intervals with O(1)[min_addr, max_end)bounding-box rejection, O(1) tail fast path, and O(log N) binary search innote()/touches().first >= count) inbatch::SOURCEso idle threadgroups in 256-thread batch dispatches skip LDS writes and bothGroupMemoryBarrierWithGroupSync()barriers, plus zero-cost budget fast path andasked > 0guard for mesh LDS atomics.crates/victory-gpu/src/indirect/merge.rs:merge::count()in thread-localLocalCountsflushing toCOUNTSevery 64 calls (and on thread exit viaDrop), cutting cross-core atomic RMWs and cache-line bouncing by 64x across multi-threaded command list recording even whenVICTORY_INDIRECT_MERGE=1is off.#[inline].crates/victory-gpu/src/indirect.rs:validate_layoutcalls inbound()andbound_ahead()viarecord_clamp_validated.open_batchwhen a recent buffer has an invalid GPU VA (keepingids,sources, andsource_bufsdensely packed).pre_clamp_barriersagainst emitting redundantUNORDERED_ACCESS -> UNORDERED_ACCESStransitions and guarded empty barrier slice calls.first >= eff_count) and zero-cost budget fast path inSOURCE.Verification
cargo clippy -p victory-gpu --target x86_64-pc-windows-msvc -- -D warnings(default,--tests, and--features diagnostics): 0 warnings, 0 errors.rustc --edition=2024 --testonbatch+mergeunit tests (including new inline/spill/saturation,WriteLogcoalescing, andmerge::countthread-local flush tests): 18 passed, 0 failed.