perf(hwrt): reuse immutable BLAS remap snapshots #452
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!452
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-452"
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 10:55 UTC · original
tommiehansen:perf/rt-remap-snapshots→main· +27505 −90 · 35 files · 43 commits · openFinal Standard benchmark — latest HWRT foundation (2026-12-05)
CI: all 6 jobs passed · head
4bd7270· #429b07015eand LOCKhart07621120b· paired CPU Standard, eight ABBA blocks.Identical correctness digests; native remap and freed tests passed in debug and release, shader checks passed. Isolated current comparison. These are CPU benchmark results, not gameplay FPS. Still stacked; do not merge independently.
Historical Standard benchmark — 2026-12-05
Reproducible CI result · head
c8edd2f74d4e· Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm).Same head;
VICTORY_HW_RT_REMAP_SNAPSHOTS=0→1. No GPU hardware performance measurement.Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS.
Needs merged first
Strip all borrowed HWRT commits after the prerequisites land; rebase onto main before merging.
What this does
reuse immutable BLAS remap snapshots.
Checks
455dfdb, not current diagnostic head; rerun and verify fail-before/pass-after after rebase.cargo xtask policyon the final revision; no new game assets or build output intended.Verified
Current review head:
1a2d16f518f6bab39ba05cda243bd1e3bafccb7c. See the latest stack audit below; historical measurements retain their original revision.Cost
Historical unchanged-remap CPU time −87.66%; retained snapshots capped at 16 MiB per allocation. GPU timing and exceptional hit parity unverified.
Detailed implementation and historical validation
Current integration — proposed HWRT stage 9
c3a0500750e9b7c8edd2fIsolated diff: 3 files, +1,920 / −90. The actual PR head contains the integrated revision (
455dfdb) and two diagnostic-only follow-ups (dbf61f4,c8edd2f), on top of #429. The foundation is pinned toc3a0500; later upstream stack changes have not been included in this benchmarked revision. The old head is archived. LOCKhart07 agreed to this integration order; upstream merge approval and subsequent foundation updates remain separate.What changes
Reuse immutable GPU-readable BLAS remap snapshots rather than uploading an unchanged console-to-host BLAS table for every TLAS remap.
Ledger::versionwhen no BLAS is unmade and the upload allocation is at most 16 MiB. Incomplete and oversized tables are not retained in the snapshot cache. Free invalidation and overwrite reclamation advance the ledger version.bind_no_wait(), preserving old arguments and references on unexpected in-flight reuse or allocation failure. No lock-held wait for submission completion. Retains the new stack's lease-aging policy.Opt in with
VICTORY_HW_RT_REMAP_SNAPSHOTS=1underVICTORY_HW_RT=1; default is off. To measure snapshot reuse, keepVICTORY_HW_RT_NAMED=0.Default path and exceptional cases
Disabling snapshot reuse does not revert every code change. Both modes use the revised binding/lifetime handling, retirement and telemetry; unmarked incomplete CPU tables rebuild rather than reusing a potentially incomplete table. Identical TLAS reference sets avoid redundant replacement/retirement. Marked tables use the new packing/upload path in both modes.
Duplicate execution of the same list within one submission retains the first table. Unexpected prior in-flight reuse asserts in debug; release preserves the existing table and extends its tracked lifetime. OOM also preserves an existing binding (a fresh cell has no previous refs). These fallbacks protect resource lifetimes but can retain stale mappings; they do not prove hit correctness under exceptional conditions. In-flight violations and OOM are counted.
Latest benchmark — integrated revision
455dfdbApple M5, Benchmark Suite #322, CPU-only Standard, four A/B/B/A blocks (eight runs per arm), snapshot reuse off vs on at the same revision.
All six remap correctness digests matched; no statistically significant regression in these workloads. The paired percentages are reported by the harness, not recalculated from rounded medians. The same run's comparable
rt_freed_*workloads also matched digests without significant regressions.These are CPU timings per synthetic workload, not FPS or GPU frame times. The harness executes
TableCacheandRemapRun::bind()with modeled upload resources; it does not exercise productionbind_no_wait()under live submission locks. That path has portable unit coverage. The marked path has payload/lifetime tests and a separate CPU timing fixture, but no reported paired comparison against the original marked uploader.Run from a separate checkout of the Benchmark Suite (#322). The reported run used the local harness (
53cc1a6, including corrected retired-buffer accounting); this local harness revision is not confirmed available on the published #322 branch. Exact timing reproduction with a different harness revision is not guaranteed.Verification and limitations
The reported tests and benchmarks apply to
455dfdb. The follow-upsdbf61f4andc8edd2fchange only reporting inreport_line(). Their isolated diffs were reviewed, but compilation and benchmarks have not been rerun on the new head.c49d34b, not the new integration.dbf61f4selects the active cache forleft_out(mgr.marks.is_some()).c8edd2falso emits the remap report for marked-only uploads, using copied bytes as the activity signal and labelling the unmarked upload counter separately. Copied bytes and allocation/retention totals cover both paths. The production wait counter should remain zero. Loss counters do not establish hit-for-hit correctness.Community testing welcome
All compatible AMD GPUs (RDNA 2–4) and other compatible hardware are welcome. Test the current PR head with RT enabled, warmed caches and identical settings/save/route. Prefer native resolution, no frame generation or upscaling; other consistently reported configurations are useful too.
VICTORY_HW_RT_NAMEDVICTORY_HW_RT_REMAP_SNAPSHOTSKeep the other HWRT switches fixed in each comparison; report whether
VICTORY_HW_RT_REUSEis enabled. Record average FPS, 1% lows, frame times, VRAM and remap telemetry (particularly retained bytes, copied bytes, in-flight violations and OOM), visual parity and stability during extended streaming. For marked-path performance overhead specifically, compare against parent750e9b7with the same marked settings. Positive, neutral and negative results are all valuable.Credit: HWRT foundation by @LOCKhart07; thanks to @Kal0s-design for reviewing synchronization and lifetime behavior.
Updated #429 prerequisite — 2026-12-05
Six-job pinned stack audit passed, including native correctness. Same-head snapshots off/on: unchanged −93.41%, overlapping submissions −90.18%, sparse changes −67.49%, sustained streaming −11.54%, growth/shrinkage −65.30%; streaming invalidation −9.60% inconclusive. All correctness digests identical. Versus the previous snapshot stack, index churn −54.77%, dense refill −26.56%, iteration −6.12%; sparse invalidation +2.25%, batched invalidation +2.60% (roughly 1 and 8 µs per synthetic case respectively). Remap timing comparisons between revisions were inconclusive; remap implementation is unchanged. The merge dependency on #429 and the replacement HWRT foundation remains. No gameplay FPS claim.
@Luxuride on GitHub · 2026-12-04 10:58 UTC · original
This one is a stack, not a change, and the diff a reviewer gets does not show that.
perf/rt-remap-snapshotscontains all 30 commits ofperf/rt-freed-gathered, plus one:f9dc2c3 hwrt: reuse immutable BLAS remap snapshots by ledger version. The real content of this PR is that one commit — 3 files, +877/−150 (hwrt/remap.rs784 new lines,hwrt.rsrewritten around it, onedocs/SETTINGS.mdrow). What GitHub shows againstmainis +23,545/−138 over 37 files, i.e. the entire lower PR again.Two consequences, both avoidable:
main, so as lower layers merge, every upper layer needs a rebase and a re-diff, and merging order becomes a coordination problem rather than a queue.Options, in order of preference:
perf/rt-freed-gatheredso its diff is the one commit, and let it land after its base. Stack depth 2 is fine and reviewable.The work itself looks reasonable — a ledger-versioned immutable remap snapshot is a good shape, and 784 lines is a reviewable size on its own. The problem is only the packaging.
@Luxuride on GitHub · 2026-12-04 10:58 UTC · original
Tommie — separate from the technical note above, since you are clearly carrying a lot of this project's work right now (ten open PRs, and three of them are the largest on the tracker: ~23.5k, ~22.8k and ~20.6k added lines). I am not a maintainer here, just another contributor, so take this as one author's opinion about how to make that work land, not as a rule anyone imposed.
What happens to a PR of that size on a project merging ~20 PRs a day, with ~30 open:
pool.rs,watch.rs,queue.rs,list.rs,host.rs— the files everything else is fixing. Every merge into those files turns into a conflict inside a diff nobody can re-read, so the stack gets rebased constantly and re-reviewed never.Five habits that cost you almost no extra work and fix most of that:
main, so the diff GitHub shows is the increment. Retarget tomainwithgh pr edit --base mainafter the parent merges.main. That is what makes a one-commit change show up as 23k lines, as this PR currently does.None of this is about the quality of the work, which looks real. It is about the fact that on a high-activity repository the scarce resource is reviewer attention, and a huge PR spends a lot of it without buying a decision. Happy to help review the split if you want a second pair of eyes on the dependency order.
@Luxuride on GitHub · 2026-12-04 11:02 UTC · original
The specific split for this one is smaller than for its base, because there is only one commit of new work in it:
f9dc2c3. Measured against the parent branch it is 3 files, +877/−150 —crates/victory-gpu/src/hwrt/remap.rs(784 new),crates/victory-gpu/src/hwrt.rs(rewritten around it), onedocs/SETTINGS.mdrow.Step 1 — retarget, do not split. Point this PR at
perf/rt-freed-gatheredinstead ofmain:That single change turns the diff from 23,545 lines into 877, and the review from "is this whole subsystem good" into "is a ledger-versioned immutable remap snapshot the right cache key". When the base lands,
gh pr edit 452 --base mainand the PR is immediately mergeable. This is the whole fix for the packaging problem.Step 2 — if you want the change itself in two reviews, split the commit along the seam it already has:
hwrt: a remap snapshot module behind its own type—hwrt/remap.rsalone, plus the tests it carries. A new file, self-contained, reviewable on its own: what the ledger version is, when a snapshot is immutable, what invalidates it.hwrt: read remaps from the ledger's snapshot— thehwrt.rsrewrite that replaces the per-invalidation remap with the module from the first PR. This is the behaviour change, and it is where the "does the count of remaps go down" argument belongs.Two commits cut that way keep the dependency honest (the second is meaningless without the first) and make the second one's diff what a reviewer should actually be reading: the call sites, not the 784 new lines underneath them.
Step 3 — order. This sits on the hardware-RT structures, so it should follow the parent's own split: pool/memory and the dead-code removals first (they are the ones that collide with the queue), then config, then structures, then this. Landing a remap-snapshot change before the structures that produce the ledger it keys on would be a rebase for nothing.
If it helps, the same
--basemechanics work for every layer of the stack: base each PR on its parent, and GitHub then shows exactly one increment per PR. That is the difference between a reviewer reading 30 commits once and reading them thirty times.@Kal0s-design on GitHub · 2026-12-04 11:08 UTC · original
Checked
f9dc2c3, only the bb184d8..f9dc2c3 part, natively on Windows with one NVIDIA desktop card plus WARP. Looks correct to me.Staleness first. The CPU table was already cached by
Ledger::versionbefore this PR, so the snapshot adds no new trust in that key, it just stops re-copying the same bytes. I still walked every ledger change.Ledger::put(hwrt.rs:2670-2685) bumps whenever a BLAS is involved and the serial or kind changes, and every production placement uses the host structure's own serial fromnext_serial()(5038, 5192, 5264, 5536, 6584, 7139). So rebuilds into another buffer, copies and compactions all bump. Frees go throughcatch_up, which bumps when a BLAS goes (2584-2594). The host address is aOnceLock(2040), so it can't change under an entry. A BLAS whose buffer is made later bymem_of(4308-4332) without a bump is left out and counted, exactly as before this PR.Ledger::newis only called in the manager constructor (4172), and the version starts at 1 and only goes up by one, so wraparound or reuse after a reset isn't a concern.I also wrote a local test, not pushed, that drives a real
Ledger<u64>throughTableCache::prepare_remapand compares the snapshot with a fresh build at every step. It covers a refit of the same structure, a rebuild at the same address, add, free, address reuse by a new BLAS, a BLAS replaced by a TLAS, and TLAS writes and frees elsewhere. Every step matched the fresh table, and hits only happened where nothing named changed.Lifetime.
RemapCelland itsREMAP_ARGSslot are made together at translation (6338-6348, 6386-6388), and both are dropped only inHostList::reset, after the list's last submission finished (host.rs:5148-5189). Nothing else writes the args after translation. The same-Arc skip inRemapRun::bind(remap.rs:293-300) compares against an Arc the run itself still holds (remap.rs:261), so that allocation can't be freed and reused, and there's no ABA. Replaced snapshots go throughhost::retirewithBURY_LAG(host.rs:364-387). A list re-run after the cache moved on gets the new snapshot and rewrites its args, the same in-flight caseREMAP_REWRITTENalready counted. Reusing an unchanged snapshot now skips that write, which is safer if anything.Opt-out.
VICTORY_HW_RT_REMAP_SNAPSHOTS=0takes theOwnedpath (remap.rs:233-243, 316-335), which copies a fresh piece and writes the args on every remap like before. Two things stay changed in both modes though. The table pool's spare cap drops fromLEASE_SPARE(256 MiB) to 16 MiB (hwrt.rs:838 vs 4170), and the scratch shrink (remap.rs:54-59) runs either way. Probably harmless, but "=0" isn't quite the old code.Tests were
cargo test -p victory-gpu --lib hwrt -- --test-threads=2with VICTORY_D3D12_DEBUG=1. On the NVIDIA card, WARP via VICTORY_BENCH_WARP=1, and WARP via--features diagnosticswith VICTORY_D3D12_WARP=1, each with snapshots on and with =0, I got 86/86 PR tests passing plus my local one. Same with VICTORY_HW_RT=1 VICTORY_BVH_BUILDER=1. To be fair, none of the hwrt tests open a device or reachwrite_table(its only call is hwrt.rs:5262), so the adapter and the env setting don't change what runs. The real coverage is the five mock tests in remap.rs plus the ledger test above. Nothing measured on GPU in game.Small thing.
RemapStatsis counted but nothing in this tree reads it outside tests, so the hit rate isn't visible in a real run. Adding it to the hwrt report line would make that easy to check.AI-assisted: yes
@tommiehansen on GitHub · 2026-12-04 11:11 UTC · original · edited 2026-12-04 15:46 UTC
@Luxuride Thanks for the detailed feedback and the offer to help. I agree that keeping incremental changes easy to review is important.
The main complication here is that both #429 and #452 depend on @LOCKhart07's hardware RT implementation in #342, which was awaiting merge when this comment was written. Most of the roughly 23k added lines shown by GitHub belong to that prerequisite stack, rather than to my individual optimizations.
The branches are already layered, but the parent branches live in separate forks and
perf/rt-freed-gathereddoes not exist in the upstream repository, so retargeting the upstream PR withgh pr edit --baseis not currently an option. The isolated comparison links and merge order are already included in the descriptions.I think both optimizations are worth keeping available for review and testing:
The original merge plan was to land the shared HWRT foundation first, then refresh the dependent branches in order.
I appreciate the feedback and your interest in helping. The goal is the same: focused, measurable optimizations that can be reviewed and merged safely.
Update (Dec 4): #342 has been superseded by the stack starting at #468. The actual PR heads now use
c3a0500→ #429 (750e9b7) → #452 (455dfdb), as agreed with LOCKhart07. Review #452's isolated three-file diff. Current CPU results are in the PR descriptions; the original figures above are historical.@tommiehansen on GitHub · 2026-12-04 11:28 UTC · original · edited 2026-12-04 15:46 UTC
Pushed commit
c49b6c8hardening PR #452 and updated the PR description with a prominent isolated diff link right at the top:bb184d8...c49b6c8.@Luxuride — Understood on why
--basemakes stacked PRs much cleaner to review on GitHub; once the prerequisite HWRT stack / #429 land upstream (so the parent branch exists inlobomfz/VIctory-xmem), we can switch the PR base immediately, and in the meantime the directbb184d8...c49b6c8compare link isolates only the 4 files touched by #452.@Kal0s-design — Thanks for the thorough code walk and Windows/NVIDIA + WARP test pass!
c49b6c8also addresses both items you noted alongside additional lifetime hardening:HwRtManager::tablestoLeasePool::new()(256 MiBspare cap) so=0/ off matches the pre-PR pool capacity.RemapBufmemory accounting and added remap telemetry for snapshot activity and upload memory; the subsequent review identified unwired binding counters.VICTORY_HW_RT_REMAP_SNAPSHOTS=1to opt-in (offby default) pending real game GPU validation.RemapRun::bindwaits on unretired prior submissions viahost::wait_submissionbefore writing args and preserves the first table on same-submission duplicate command lists (same_sub_conflict);unmade > 0incomplete mappings are not cached; upload OOM preserves previousBlasRefsand args while the prior mapping can be stale; removed raw pointers from the upload callback; borrowed&mem.keptduringledger.map.visitand short-circuitedtlas_stepviaArc::ptr_eq.#374(VICTORY_HW_RT_NAMED) compatibility againste95cab7(Windows MSVCcargo checkexited 0) without pulling#374into#452, and re-verified on Windows MSVCclippy(0 warnings in modified files), 6 unit harness tests, and updated CPU Standard/Full paired benchmarks in#322(−87.6%/−89.0%unchanged,−69.1%/−70.9%overlapping,−47.4%/−51.1%sparse,−38.1%/−37.2%growth/shrinkage, zero regressions, identical digests; live game GPU validation still needed).Historical revision — superseded: the lock-held wait described above was removed after Kal0s-design identified the relay deadlock hazard. The latest
455dfdbuses non-blocking binding, preserves the replacement stack'sLeasePool::aging(demote_on()), and limits snapshot reuse to unmarked tables. See the current isolated diff.@Kal0s-design on GitHub · 2026-12-04 11:37 UTC · original
Re-checked
c49b6c8, just the changes sincef9dc2c3. Looks good to me. A few notes.The new wait in
RemapRun::bindruns on the submitting thread, insiderun_deferred. At that point it holds the submission lock, the list'sdeferredlock (host.rs:6510, the step runs at host.rs:6588), the ledger lock (hwrt.rs:5281) and the cell lock. I couldn't find a path that reaches the wait at remap.rs:433. Title lists only reach the card throughdetach(list.rs:563, called from queue/behind.rs), which moves the host list into a single submission. The cell lives on that host list (hwrt.rs:6444-6445) and is cleared when the list is reset (host.rs:5172). One submit call also gets exactly one number (host.rs:4542). So only the same-submission branch is live. On the relay's landing path I didn't find anything that takes the ledger,blas_tableor cell locks. hwrt registers noafter_gpuobservers, and the drops inburyonly take the pool and sizes locks. If a host list could ever be re-sent while its earlier flight is still in the air, though, that wait would hang. The relay locks the same list'sdeferredinread_backs(host.rs:3799) before it storesFINISHED(host.rs:4210). Adebug_assertor a comment there could help.same_sub_conflictmakes both runs of a list named twice in one ExecuteCommandLists read the first table, and the TLAS gets that table's refs.bb184d8overwrote the args, so both runs read the second table. Both runs read the same args memory, so one of them is off either way. Keeping the first seems safer, because the first run can't name a BLAS that only gets built later in the same submission. It is still a change on the default path.On OOM the args keep naming the cell's old piece, and the cell's refs keep those BLASes alive (hwrt.rs:5356-5358). The entries can be stale but they never point at freed memory. A fresh cell that hits OOM still points at the zero table (hwrt.rs:6404).
These are the default-path differences from
bb184d8that I found in hwrt.rs.unmade > 0the CPU table is rebuilt on every remap, even at the same version (remap.rs:186).bb184d8reused it until the version changed.bb184d8set them toNone). Both are safe.tlas_stepskips the replace and retire when the refs are the sameArc. That has no visible effect.retire(RemapBuf)instead ofretire_resource, andburydrops both the same way.tablesis back onLeasePool::new()(hwrt.rs:4191, 256 MiB viaLEASE_SPAREat hwrt.rs:838), and all sevenREMAP_DIAGslots are printed at hwrt.rs:3912-3925. Waits and arg skips/writes aren't counted anywhere, though (waited_priorandargs_writtenare unused, remap.rs:338-340). Conflicts and OOM show up only through the existingREMAP_REWRITTEN/NOT_DONEline (hwrt.rs:3866-3867).RemapStatsis still write-only outside tests.I ran
cargo test -p victory-gpu --lib hwrtwith the D3D12 debug layer on one NVIDIA desktop card, with the var unset and with=1, and once with the WARP switch. Each run passed 87/87. None of these tests create a device or reachwrite_table/bindwith real memory, and the WARP switch is only read by tests in indirect.rs. I also ran two extra tests locally, both passing. One compares the snapshot against a fresh table across ledger changes, with snapshots on and off. The other is a randomizedbindsequence that checks it never waits on the current, a later or a finished submission, and that a duplicate keeps the first args and refs.AI-assisted: yes
@tommiehansen on GitHub · 2026-12-04 12:20 UTC · original · edited 2026-12-04 15:46 UTC
Thanks @Kal0s-design for re-checking
c49b6c8and identifying the lock-order / relay hazard onwait_submissionplus the unwiredBindOutcomefields and exact=0diffs! Pusheda14867eaddressing the lock-held wait and missing binding telemetry:RemapRun::bind_no_wait&host.rs):write_table'swait_submissioncall withRemapRun::bind_no_wait(and removed unusedhost::wait_submissionsincehwrt.rswas its only caller;RemapRun::bindstays available for unit/benchmark harnesses).HostListdetach/reset ownership invariant directly abovewrite_table's bind call.debug_assert!inbind_no_waitagainst unexpected prior in-flight reuse; in release builds (bind_no_wait_inner), it does not wait under locks, does not overwrite liveargsor drop priorBlasRefs, retires the unused new table cleanly, and setsBindOutcome.prior_in_flight = true(preservingsame_sharedandsame_sub_conflict).REMAP_DIAG[0..12]outcomes inhwrt.rs&hwrt::report():#[allow(dead_code)]attributes onBindOutcomeand wiredREMAP_DIAG[7..12](args_written,args_skipped,waited_prior,same_sub_conflict,prior_in_flight— which also incrementsNOT_DONE+ rate-limited error logging — andupload_oom).hwrt::report(). As the reviewer subsequently noted, the wait counter should stay zero in the non-blocking production path; these are cumulative counters.=0) differences relative tobb184d8(same_sub_conflictkeeps first submission's args/refs,unmade > 0rebuilds without caching, upload OOM keepscell's existing refs,tlas_stepskips identicalArcreplace/retire,RemapBufretirement, timing/REMAP_DIAGcounters).Verification on
a14867eremap.rstests: 8/8 passed (including newbind_no_wait_inner_preserves_in_flight_args_refs_and_retires_unused_tableand debug#[should_panic]bind_no_wait_panics_in_debug_on_in_flight_prior_reuse).cargo clippy --offline -p victory-gpu --all-targets: exited 0, 0 warnings in modified files.a14867e=0vs=1, Apple M5 CPU-only, 4 blocks): all 22 comparable RT workloads matched digests (identical) with zero regressions (rt_remap_unchanged−87.71%,rt_remap_overlapping_submissions−69.12%,rt_remap_sparse_changes−48.19%,rt_remap_growth_shrinkage−37.74%,rt_remap_sustained_streaming−0.06%No significant difference). Hardware GPU execution remains to be validated before switchingVICTORY_HW_RT_REMAP_SNAPSHOTS=1from opt-in.Historical revision: the tests and measurements above apply to
a14867e. Later lifetime fixes were included inc49d34b, and the current replacement-stack revision is455dfdb. The CPU benchmark exercisesbind(), not live productionbind_no_wait().@tommiehansen on GitHub · 2026-12-04 13:03 UTC · original · edited 2026-12-04 15:51 UTC
Pushed
c49d34btoperf/rt-remap-snapshots(@Kal0s-design):remap.rs&hwrt.rs):RemapRun::bind_impl's no-waitprior_in_flightbranch now extendsself.number = self.number.max(number)before returning (whilebind_no_waitcapturesprev_numberbefore callingbind_no_wait_innerfor an accuratedebug_assert!message).RemapRun::preserve_on_oom(number)and called it onHwRtManager::write_table's upload OOM fallback so preservedargs/BLAS refs track the current submission's lifetime (while a fresh unbound cell returnsNoneunchanged).remap.rs):bind_no_wait_panics_in_debug_on_in_flight_prior_reusewith#[cfg(debug_assertions)].repeated_in_flight_reuse_tracks_lifetime_until_completion(covering sub 10 -> sub 11prior_in_flight-> sub 12 still rejected atfinished = 10-> sub 13 clean rebind atfinished = 12across allShared/Ownedcombinations) andpreserve_on_oom_tracks_lifetime_across_submissions.bind_no_wait()from the benchmark harness'sbind(), single-ownerRemapBuf(REMAP_DIAG[4]) fromrt_remap_bench.rs'sretired_bytes_peak, and GPU lifetime safety from stale-mapping correctness under OOM/invariant violations.c49d34b): portableremap.rstests passed 10/10 in debug (0.07s) and 9/9 in-Orelease (0.02s); Windows MSVCcargo clippy --offline -p victory-gpu --all-targetsexited0with 0 warnings in modified files.Update — current PR head:
455dfdbintegrates these fixes on the replacement HWRT stack. It keeps marked uploads exclusive and snapshot reuse opt-in for unmarked remaps. Portable tests passed (12 debug, 11 release; one timing test ignored in each and run separately in release), and the Windows-target compilation check passed. The updated Standard CPU fixture shows −87.66% for unchanged remaps, −69.27% for overlapping submissions, −47.69% for sparse changes and −38.25% for growth/shrinkage; all six remap digests match. These results do not establish gameplay gains or live marked-path equivalence. The markedleft_outreporting issue was subsequently fixed indbf61f4, which selects the active remap cache inreport_line(). This diagnostic-only change has been diff-reviewed; tests and benchmarks have not been rerun on it. The follow-upc8edd2falso enables the report for marked-only uploads and clarifies its counters. It is now the PR head. Both follow-ups were diff-reviewed, not rebenchmarked. The PR description documents the remaining hardware tests needed. Thanks again for the earlier lifetime review.@Kal0s-design on GitHub · 2026-12-04 14:26 UTC · original
Checked
c49d34b, only c49b6c8..c49d34b. Looks fine to me, the wait under the locks is gone and I have nothing blocking.The in-flight branch (remap.rs:534-553) is not what
bb184d8did in the same spot.bb184d8always wrote the new table into the args and only bumpedREMAP_REWRITTEN(hwrt.rs:5393 and 5401 there). So the new submission got a fresh table, and the earlier one still in flight could read it. Now the args and refs stay on the old table, so it's the new submission's TLAS that can resolve a BLAS rebuilt or added since then to its old entry or miss it. Nothing points at freed memory, because the old refs come back as the TLAS refs. I'd say that's the safer side. It's also loud now, counted inREMAP_DIAG[11]andNOT_DONEwith an error log (hwrt.rs:5417-5426), and it panics in debug (remap.rs:440). As far as I can tell it's still unreachable while the detach/reset rule holds, and nothing callswait_submissionanymore.Lifetimes look right. That branch never touches
snapshot,pieceorrefs, andcommit_tableonly retires the cache's own clone of the Arc. So the old snapshot or piece stays with the run until a later bind gets past the check at remap.rs:534 and hands it toretire(560-567, 585-592).preserve_on_oom(remap.rs:375-379) works the same way. A fresh cell still returnsNone. The.max()at 539 is the same as= numberthere, since the guard already hasself.number < number.All 13
REMAP_DIAGslots have afetch_addand show up in the report line. Slot 9 can't move in a real run though.bind_no_waitpassesNonefor the wait (remap.rs:462), so "waited" will always print 0. The doc comment onwrite_tablestill says prior runs are waited for (hwrt.rs:5323). Also, the counters never reset, so after one OOM or violation every later report line logs at error level (hwrt.rs:3936-3940). Might be what you want, just pointing it out.Default path vs
c49b6c8. On a broken invariant it now keeps the old table instead of waiting. OOM extends the tracked submission. Then there are the new counters and the error-level line. I found nothing else.Tests on one NVIDIA desktop card with the D3D12 debug layer.
cargo test -p victory-gpu --lib hwrtin debug passed 91/91, both with the var unset and with=1. Thehwrt::remaptests in--releasepassed 9/9 both ways, since the should_panic one is debug-only. Same caveat as before. None of these tests open a device, andremap_snapshots_on()is only read inwrite_table(hwrt.rs:5328), so the var and the card don't change what runs.I also ran three local tests, not pushed, in debug and release. Two of them check the Shared and Owned paths with weak refs (their in-flight steps only run in release, since debug hits the assert). They show the old snapshot or piece is still alive after an in-flight reuse, after the cache replaces its copy and after
preserve_on_oom, and that it only goes away through the retire callback on a clean rebind. The third is my earlier ledger test ported to the newprepare_remap, with snapshots on and off. All passed. When I took out the number update inpreserve_on_oom, the release run of the Owned test failed, so the release-only branch really gets exercised.AI-assisted: yes
hwrt: reuse immutable BLAS remap snapshots by ledger version (on #429)to hwrt: reuse immutable BLAS remap snapshots on unmarked TLAS remaps (on #429 / rt-7-reuse)c49d34b6adto455dfdbb76@DrArroway on GitHub · 2026-12-04 18:37 UTC · original
48-minute real-play validation of
#452(c8edd2f) +#429(750e9b7) merged cleanly on top ofLOCKhart07/VIctory-xmemrt-7-reuse(621120b) +main(2382b4c) on RDNA 2.Setup & build
AMD Radeon RX 6900 XT (1002:73bf)(RDNA 2, 16 GB VRAM), Ryzen 9 7900X (12C/24T), 62 GiB RAM, CachyOS kernel7.3.7-1-cachyos,GE-Proton11-15-x86_64, repo-patched Mesa (deps/mesa-inst) + vkd3d-proton.rt-7-reuse(621120b) +#452(c8edd2f, including#429750e9b7) +main(2382b4c) merged cleanly with 0 conflicts (59.5 srelease build, 0 warnings).VICTORY_OUTPUT=2560x1440,VICTORY_FSR_4K=quality,VICTORY_FIDELITYFX_FRAMEGEN=1,VICTORY_FIDELITYFX_FRAMEGEN_DIRECT=1,VICTORY_UI_PLANE=3840x2160,VICTORY_HW_RT=1,VICTORY_HW_RT_DEMOTE=1,VICTORY_HW_RT_PACK=1,VICTORY_HW_RT_REUSE=1,VICTORY_HW_RT_REMAP_SNAPSHOTS=1,VICTORY_PLACED_COPIED=1,VICTORY_PARTS_ONE_CALL=1,VICTORY_KEEP_HOST_BUFFERS=1,VICTORY_SKIP_BINK=1(session ended at 48m on the unrelated#111/#358VICTORY_SKIP_BINK=1TV mini-game crash;0GPU errors and0kernel faults).Verbatim final lines (at
47m 49s)Summary
#452snapshot reuse (VICTORY_HW_RT_REMAP_SNAPSHOTS=1):312,441snapshot hits vs42,022uploads (88.1%hit rate), only311upload allocations (41,711pool reuses,0OOMs),2.0 MBretained, and354,463arg writes with0skipped,0waited,0same-sub conflicts,0in-flight violations.#429+#452+rt-7-reuse):0losses across all 16 counters over461,875,486BLAS instances;0wrong drops fromVICTORY_HW_RT_REUSE=1; clean visuals throughout.618 MBat exit (1,256 MBpeak).13,959 / 15,457 MBat exit (14,678 MBpeak — never overflowed).12,595 MBat exit (14,996 MBpeak).tools/session-fps.sh(505samples):25.8median /26.3avg real FPS (peak50.5real FPS,7.6 msavg preparing).hwrt: reuse immutable BLAS remap snapshots on unmarked TLAS remaps (on #429 / rt-7-reuse)to perf(hwrt): reuse immutable BLAS remap snapshots@tommiehansen on GitHub · 2026-12-05 10:21 UTC · original
Thanks for the lifetime review and RDNA2 real-play validation. The current-head Standard CPU comparison now measures 93.37% lower unchanged-remap time and 82.17% lower overlapping-submission time, with matching digests. Ready for review/testing; still stacked after #429 and the HWRT foundation, not an independent merge.
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.