Prefill nearby guest BVH directory entries after demand faults #240
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/lobomfz--VIctory-xmem!240
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-240"
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?
@tommiehansen on GitHub · 2026-12-02 20:24 UTC · original
tommiehansen:experiment/bvh-fault-lookahead→main· +58 −0 · 2 files · 2 commits · merged 2026-12-03 17:28 UTCBottleneck and change
A missing guest directory entry can cost the first shader read or write, even when title memory already has in-place backing. The demand handler reveals a 4 MiB cell only after a miss. With
VICTORY_BVH_LOOKAHEAD=1, it tries up to four following cells after all observed demand has been handled. An off run uses the original demand policy.This is a narrower follow-up to #25. That experiment reported a roughly 4–5 ms improvement in its own run and revealed much larger ranges. This patch makes no assumption that its smaller policy will reproduce that result.
Correctness and cost
Candidates stay in the demand's already-created 128 MiB mirror, stop before the empty directory sentinel, and require covered pages at the cell boundary. Existing entries are preserved. Each new entry goes through the normal
put_in_placeeligibility, alias checks, lazy reveal request, and publication path under the memory lock. The normal submission path still publishes the directory and reveals backing before use. Demand budgets, resource ownership, shaders, queue ordering and fence waits are unchanged. Extra entries can create extra reveal work and change the timing at which shader accesses succeed, so the experiment defaults to off.Evidence from the earlier eager-mapping experiment
PR #25 reported the following on RX 9070 XT, Series X, 2560×1440, RT enabled. The frame-time and VRAM figures come from its scripted eight-minute benchmark; the fault-category counts come from a separate four-minute diagnostic run.
Comparison with existing approaches
This PR deliberately limits additional work to at most 16 MiB of candidate cell ranges per qualifying demand, subject to eligibility and mirror boundaries. That is a mapping scope, not a promise of 16 MiB of new VRAM allocations.
Why this should be merged
The earlier experiment demonstrates that late directory publication can be a meaningful bottleneck. This narrower opt-in policy makes the trade-off between avoided late accesses and extra mapping work measurable while retaining the existing publication and eligibility rules. It does not repair out-of-range or otherwise invalid BVH pointers. The results from #25 cannot be attributed to this PR, and native RayQuery may reduce the relevant traversal workload.
Validation
The Windows target for
victoryandvictory-gpu, including diagnostics and test compilation, passed from macOS with a check-only mimalloc override and the pure Rust BLAKE3 path. Portable tests passed for every cell boundary and 65,536 randomized page addresses against a byte-address reference.git diff --checkpassed. Hardware benchmarking was unavailable.Could maintainers test RX 9060 XT 16 GB at native 1920×1080 and RX 9070 XT at native 2560×1440, with RT on and frame generation off? Compare
VICTORY_BVH_LOOKAHEAD=0and1on the same cold and warm routes. Record render frame-time percentiles, directory faults, pages shown ahead, and VRAM. Check image parity around scene cuts and shader-built structures. The expected benefit is fewer late accesses if faults cluster across cell boundaries. Extra directory and mapping work can offset it.