perf(hwrt): batch structure invalidation and adapt address indexing #429
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!429
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-429"
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-04 02:22 UTC · original
tommiehansen:perf/rt-freed-gathered→main· +25675 −90 · 34 files · 38 commits · openFinal Standard benchmark — latest HWRT foundation (2026-12-05)
CI: all 6 jobs passed · head
b07015e· LOCKhart07rt-7-reuse @ 621120b· paired CPU Standard, eight ABBA blocks.All correctness digests identical. Native debug and release: 18/18 tests each. Shader checks passed. The foundation-only control found no significant regressions. #452 also passed its paired and native remap tests on this stack. The previous churn regression is resolved; marginal gate changes are inconclusive. Absolute costs above are per synthetic workload, not per gameplay frame.
Isolated current comparison. Still stacked: do not merge independently. Physical AMD gameplay timing remains unverified for this exact revision.
Historical Standard benchmark — 2026-12-05
Reproducible CI result · head
750e9b7441ec· Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm).Same head;
VICTORY_HW_RT_FREED_GATHEREDandVICTORY_HW_RT_FREED_INDEXboth 0 → 1. Dense and invalidation cases improve substantially, but churn and gate contention need attention. No hardware RT timing.Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS.
Needs merged first
rt-7-reuse @ c3a0500). Strip borrowed commits and rebase onto main before merge.What this does
batch structure invalidation and adapt address indexing.
Checks
VICTORY_HW_RTis opt-in; both sub-controls default on within HWRT. Verify disabled-path equivalence against landed foundation and decide sub-control defaults before merge.joined_eviction_matches_single_spans_on_randomized_registriesand index boundary tests. Rerun after dependency rebase; fail-before evidence pending.cargo xtask policyon the final revision; no new game assets or build output intended.Verified
Current review head:
2eb4706ec25c43ee41dacc263146de018ed82def. Existing measurements and commands are retained below at their original revisions. No fresh compile, policy or hardware test is claimed by this metadata review.Cost
Synthetic CPU invalidation −89.94%; previous insertion regression +46.22% on old revision, current GPU and gameplay effect unknown.
Detailed implementation and historical validation
Current integration — proposed HWRT stage 8
The updated implementation targets LOCKhart07's replacement HWRT stack starting at #468, not the retired integration plan in #342.
rt-7-reuse @ c3a0500codex/rt-8-freed-integration @ 750e9b7Historical integration head:
750e9b7; current head:2eb4706. The previous implementation (bb184d8) is preserved in an archive branch. Review the isolated diff above: GitHub's main-based diff includes the prerequisite HWRT stack until it lands. LOCKhart07 agreed to the proposed order:rt-7-reuse→ #429 → #452. #452 is now integrated directly on this PR (benchmarked revision455dfdb, current diagnostic follow-upc8edd2f). This is coordination with the stack author, not maintainer merge approval. The foundation is pinned toc3a0500; later shader-cache fixes in the upstream stack have not been included in this benchmarked revision.Why this matters
Each guest page free can scan the RT registry, decoded and validated index caches, and the submission ledger. During world streaming, repeated frees and build-overlap queries can make this expensive.
The updated integration preserves the replacement stack's lease-aging policy, overwrite reclamation and named diagnostics.
reuse_stepis a flush boundary, and registry, named and reuse invalidation use matching half-open ranges. BLAS removals advance the remap generation.Controls
Both optimizations default to enabled when
VICTORY_HW_RT=1is requested. They can be disabled independently:VICTORY_HW_RT_FREED_GATHERED0VICTORY_HW_RT_FREED_INDEX0Latest benchmark — replacement stack (
750e9b7)Apple M5, CPU-only, Benchmark Suite #322, Standard, four paired A/B/B/A blocks. Both controls off vs both on at the same integrated revision.
All listed correctness digests matched. The invalidation fixture saves approximately 1.76 ms of CPU time per synthetic sample; this is not a measured per-frame saving. The direct comparison against
c3a0500cannot run a common production freed workload because the foundation lacks the planner module. These results isolate the controls, not whole application builds.Run from a checkout of the Benchmark Suite (#322), not the game PR branch itself. The command records the comparison used for the reported results.
Previous gameplay evidence
An RX 7900 XTX Linux tester reported approximately 15–25 → 25–40 FPS while driving after adding the earlier #429 implementation to #374. This was a qualitative report, not a controlled benchmark, and does not establish FPS gains for the new integration. Exact graphics settings and the tested #429 revision were not reported.
Verification and limitations
victory-gpuandvictory-hlewith tests passed using the local check-only allocator shim.bb184d8found a clustered insertion/replacement regression of 5.209 → 7.667 µs (+46.22%). That result is historical and has not been remeasured on the replacement stack.750e9b7remain unverified.Historical benchmark details and reproduction commands.
Community testing welcome
Tests from all compatible AMD GPUs (RDNA 2–4) and other compatible hardware are welcome. Use the PR head (
2eb4706), setVICTORY_HW_RT=1, and keep all other HWRT switches and graphics settings fixed. Baseline:VICTORY_HW_RT_FREED_GATHERED=0 VICTORY_HW_RT_FREED_INDEX=0; candidate: set both to1. Separate batching/index tests are also useful.Prefer native resolution, no frame generation or upscaling, warmed caches and repeated A/B/B/A runs. Other configurations are welcome if settings remain consistent. Report GPU/driver, revision, graphics settings, average FPS, 1% lows, frame times, memory usage, RT loss counters and any visual or stability issues. Positive, neutral and negative results are equally useful.
Credit: batching adapted from Darner's range-collection implementation; HWRT foundation by @LOCKhart07.
Regression audit follow-up
The +4.76% contended gate row compared
750e9b7against itself with two feature switches toggled. Raw reports show the sameatomicGate on both sides; gate_benches does not read those switches. Therefore that result is a same-code noise/control measurement, not an established switch-induced regression (repeat control pending). Index churn +12.31% (CI +11.17% to +13.46%) is a genuine measured microbenchmark regression candidate. Experimentalffcbb94reduces direct partition lookup to one bounds check with address-boundary parity tests. Testing on a separate branch to preserve the #452 dependency stack; not yet integrated.Repeated Standard control (2026-12-05)
Eight-block switch-off/on comparison on the original
750e9b7head: invalidation −92.07%, dense index −99.68%, sparse index −78.81%, empty overlap −91.71%, with identical output digests. Index churn +12.69% reproduces the previous +12.31%; index iteration +8.45% is an additional regression candidate. Gate contention +0.85% is inconclusive (same gate implementation in both arms); earlier +4.76% is not reproduced. The separateffcbb94repair comparison is still pending. Raw CI. CPU microbenchmarks, not gameplay FPS.Index regression follow-up (2026-12-05)
750e9b7)ffcbb94)These are two separately paired 8-block comparisons, not a direct measurement of improvement across hosts. The direct original-index→first-repair comparison shows +2.17% churn, +9.56% phased churn and +7.34% scattered churn, so do not adopt that revision. Original control · First repair direct comparison · First repair flat control.
Second experimental revision
e8e025dstarts from the original PR head, isolates direct index insertions from cold layout transitions and overflow handling, and traverses direct and overflow shards separately. Added exact mutation/eviction/visit parity test. New three-way paired + native audit. Neither repair is merged into this PR or #452 pending regression-free evidence.Second index repair results (
e8e025d)All four audit jobs completed successfully. Correctness tests pass, but the performance gate remains open. Against the original indexed revision, churn −8.98%, phased churn −14.28%, scattered churn −15.98%, iteration −2.79%; dense aliased refill +2.01% (reported regression). Against the original flat revision, churn +3.66%, invalidation −92.22%, dense −99.69%. The same-revision flat/index control instead reports churn +16.30%, iteration −1.72%, invalidation −92.72%, dense −99.78%. Do not combine independent hosts' ratios or adopt the repair as regression-free. Audit. Both experimental revisions remain separate from #429/#452.
Third compact-index repair results (
4fbc8c9)Completed audit: all 5 jobs passed, including 17/17 native tests in debug and release. Four independent 8-block ABBA comparisons, identical correctness digests.
The same-head churn and iteration regressions remain; phased/scattered churn also regress against the preceding experimental candidate. A +6.42% gate contention result in the original-flat comparison is a same-code control and does not reproduce in the compact same-head comparison (−0.17%, inconclusive). Do not combine independent host ratios or integrate as regression-free. Current PR and #452 heads remain unchanged. CPU microbenchmarks, not gameplay or physical GPU timings.
Fourth repair — current head
2eb4706(2026-12-05)Eight-job Standard/native audit passed. 18/18 native tests in debug and release; 72 composite-key cases exact. Direct partitions use seeded integer hashing; flat and overflow maps retain their original hashing. Same-head off/on, eight paired blocks:
Identical correctness digests. Direct comparison with the third indexed candidate: churn −50.35%, refill −20.54%, iteration +2.95% (~0.6 µs per synthetic sweep). The fifth folded traversal candidate was rejected because iteration regressed +5.09% against its own flat control. Explicit registry maintenance visits are conditional, with 250 ms scan intervals; their microbenchmark cost is not a measured frame-time regression. Fourth repair is now published here; #452 integration is being independently tested on this audit. No gameplay or hardware RT performance claim. Prerequisite/merge restrictions remain unchanged.
@Kal0s-design on GitHub · 2026-12-04 02:34 UTC · original
Tested natively on Windows 11 (MSVC) with one NVIDIA desktop card plus WARP, looking only at a70bd85..7de401d.
a70bd85, with the same five known local failures on both sides. hwrt runs 67 tests on the PR and 64 on the base, none ignored, but none of them create a device or the manager. So setting VICTORY_HW_RT=1 VICTORY_HW_RT_FREED_GATHERED=1 for the suite doesn't actually exercise the gathered path, it only shows nothing else changes. No new clippy warnings in victory-gpu or victory-hle.Reading the code I found no RT table access that isn't behind a guarded entry point, and next_seq is only taken inside a guard or in invalidate_freed, so one seq per batch gives the same ledger as one per free. Lock order and the flush under the mapping guard look fine to me, and drops of removed entries don't reach back into a guard.
Things worth a look
AI-assisted: yes
@khift363 on GitHub · 2026-12-04 09:04 UTC · original
Did a dirty merge of this onto #374 and I've got to say, this is the biggest single improvement in FPS I've seen so far, especially while driving. Qualitative numbers, but, without this I get around 15 to 25 FPS while driving around, and with this I get 25 to 40 FPS. It's absolutely monstrous. Benefits slower scenes as well, but disproportionately helps driving. 7900 XTX on Linux.
@Luxuride on GitHub · 2026-12-04 10:58 UTC · original
There is clearly real work here, and the hardware ray-tracing numbers are the kind of thing this project needs. I want to raise one thing before it gets further, because it is much cheaper to fix now than after a rebase.
The shape: 30 commits, 36 files, +22,818/−138.
crates/victory-gpu/src/hwrt.rsalone is ~8,962 new lines,crates/victory-shader/src/emit/rayquery.rs~8,269,pool.rs1,190,hwrt/freed.rs1,142, plus 409 lines ofrun.conf.defaultand the removal of ~300 lines ofvehicle_notch. That is not one change with one risk; it is five or six subsystems in one review.The two concrete problems that creates:
pool.rs,watch.rs,list.rs,queue.rs,host.rs— the files the rest of the queue is fixing. Every independent fix that lands conflicts with this branch, and every conflict is resolved inside a diff nobody can re-read.A split that keeps the value and makes each piece reviewable, in dependency order:
VICTORY_HW_RTswitch (off by default), with the structure testsemit/rayquery.rs,structure.rs,lower.rs)pool.rs,memory.rs,host/send.rs)xboxbvhand the loader-side changesrun.conf.default(a 409-line config diff deserves its own PR regardless)Each of those is big enough to be interesting and small enough to be reviewed in one sitting, and each carries its own measurement. If the layers genuinely cannot be separated, that itself is worth saying up front — but from the commit list they look separable.
This project moves fast (about twenty merges in a day, ~85 open PRs). On that cadence the bottleneck is review throughput, not authoring speed, and a 22k-line PR consumes the former without producing the latter.
@Luxuride on GitHub · 2026-12-04 11:02 UTC · original
Since the question was how to split it, here is a concrete cut, taken from the diff itself (
main…perf/rt-freed-gathered). Each line below is a review unit with its own risk, its own test, and — importantly — its own merge order.gpu: pack the pool and memory paths for RTpool.rs,memory.rs,descriptor*.rs,list*.rs,queue.rs,watch.rs,host.rs,pipeline*.rs,shader_cache.rs,draw.rs(24 files)loader, app: drop the dead notch and rumble pathsvehicle_notch.rs,ps5_rumble.rs,apps/victory/src/{run,translate}.rs,loader(12 files)docs, config: the hardware RT switchesrun.conf.default(409 lines),docs/SETTINGS.md,README.mdhle: the structure-builder entry points for hardware RTmodules/{mod,xboxbvh,xmem}.rs(4 files)hwrt: host structures for hardware ray tracinghwrt.rs(8,962),hwrt/freed.rs(1,142),host/rtstamps.rsshader: lower the structure walks to hardware ray queriesemit/rayquery.rs(8,269),emit/{lower,mod,shader}.rs,structure.rs,emit/rayquery_tests.rs,bitcode/opt.rs,emit/intersect_tests.rs,size_tests.rs,lib.rs(12 files)Merge order and bases:
main. They are the smallest, they are the ones the rest of the queue collides with (pool.rs,watch.rs,queue.rs,list.rs), and 2 is almost entirely deletions — cheap review, immediate conflict relief.main— config and docs only, and a 409-linerun.conf.defaultdiff is unreadable inside a 22k-line PR by construction.main, then 5 based on 4, then 6 based on 5. The dependency is real: the shader lowering calls the structures 5 registers, and both are inert without the switch from 3.Two things to watch when it is cut this way:
hwrt.rsat ~9,000. On its own that is a legitimate PR — a new subsystem is allowed to be big — but it is only reviewable if the switch is off by default and the file reads as one thing, not three.Nothing here needs history surgery: the commits are already in these groups, so it is nine
git branch/git checkout <sha> -bcalls and onegh pr createeach, with--basepointing at the parent where the dependency is real.@tommiehansen on GitHub · 2026-12-04 11:17 UTC · original · edited 2026-12-04 15:46 UTC
@Luxuride Thanks for taking the time to look at this. As explained in my reply on #452, #429 builds on @LOCKhart07's hardware RT implementation in #342, which had not been merged when this comment was written. Most of the 22k-line diff is inherited from that dependency, rather than introduced by #429. Any decision to split #342 would primarily be for LOCKhart07 and the maintainer.
The performance results are already isolated for #429's own changes in the synthetic benchmarks. Additionally, @khift363 reported roughly 15–25 to 25–40 FPS while driving on an RX 7900 XTX after adding #429 to #374. While qualitative rather than a controlled benchmark, that report specifically evaluates the added patch.
As the prerequisite stack lands, the apparent diff size should become much more representative of the actual optimization. I appreciate your feedback and agree that keeping the individual changes reviewable is important.
Update (Dec 4): #342 is superseded by the seven-stage stack starting at #468. #429 now points to
750e9b7directly on pinnedrt-7-reuse @ c3a0500; review only its four-file change. #452 follows at455dfdb. LOCKhart07 agreed to that order. The earlier gameplay report is not validation of the replacement revision.@tommiehansen on GitHub · 2026-12-04 15:21 UTC · original · edited 2026-12-04 15:51 UTC
@LOCKhart07, the isolated #429 follow-up to
rt-7-reuseatc3a0500is750e9b7. It retains lease aging and your overwrite-reclamation diagnostics, and makesreuse_stepa free-flush boundary. Windows-target compilation and 16 portable tests passed. Could we coordinate treating this as the next stage after #468’s stack, with #452 following for unmarked remap snapshots? The original implementation is preserved inarchive/rt-freed-gathered-bb184d8.Update: The actual #429 PR branch now points to
750e9b7, and #452 has been integrated directly above it at455dfdb. Both PRs include isolated benchmark results. #452's current head isc8edd2f, with two diagnostic-only follow-ups to the benchmarked455dfdb. Thanks for confirming the proposed order and keeping the upstream stack history stable.hwrt: batch structure invalidation within page-mapping groups (on #342)to hwrt: batched structure invalidation and adaptive indexing (replacement RT stack)bb184d82f5to750e9b7441@LOCKhart07 on GitHub · 2026-12-04 15:31 UTC · original
@tommiehansen Works for me: your follow-up as the stage after
rt-7-reuse, then #452.One heads-up:
rt-1-liftgot two commits today (the translator's output is now identical to main with the switch off,TRANSLATOR_VERSIONis back to 20, and the switch is part of the shader cache key). The branches above received them as a merge, not a rebase, soc3a0500is still inrt-7-reuseand your750e9b7applies as it is. I won't rebase these branches while you're building on them.@DrArroway on GitHub · 2026-12-04 18:37 UTC · original
48-minute real-play validation on
AMD Radeon RX 6900 XT (1002:73bf)(RDNA 2, 16 GB,2560x1440FSR4 Quality + Direct FG) running#429(750e9b7, bothVICTORY_HW_RT_FREED_GATHEREDandVICTORY_HW_RT_FREED_INDEXon by default) +#452(c8edd2f) merged cleanly ontoLOCKhart07/VIctory-xmemrt-7-reuse(621120b) +main(2382b4c).0GPU errors,0kernel faults, and0across all 16hardware RT lossescounters over461,875,486BLAS instances (24,636overwritten BLASes =8,758 MBdropped with0wrong drops; host RT memory618 MBat exit, VRAM peak14,678 MB, shared12,595 MBat exit).#111/#358VICTORY_SKIP_BINK=1TV mini-game crash).hwrt: batched structure invalidation and adaptive indexing (replacement RT stack)to perf(hwrt): batch structure invalidation and adapt address indexing@tommiehansen on GitHub · 2026-12-05 10:21 UTC · original
Thanks for the reviews and real-play validation. The current isolated Standard CPU comparison shows 93.38% lower invalidation time, while disclosing index-churn and contention regressions. Now ready for review/testing; merge order remains LOCKhart07's replacement HWRT stack, then #429, then #452. Please review the isolated diff linked in the description.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.