perf(hwrt): reuse immutable BLAS remap snapshots #452

Open
github-bot wants to merge 43 commits from github-bot/gh-452 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-04 10:55 UTC · original
tommiehansen:perf/rt-remap-snapshots → main · +27505 −90 · 35 files · 43 commits · open

Stacked PR — ready for review and community testing, not independent merge. Do not merge before LOCKhart07's replacement HWRT stages 1–7 (starting with #468) and #429 have landed and the isolated change has been reconciled and revalidated against main. The main-based diff includes borrowed prerequisite commits. See the isolated review diff and outstanding checks below.

Final Standard benchmark — latest HWRT foundation (2026-12-05)

CI: all 6 jobs passed · head 4bd7270 · #429 b07015e and LOCKhart07 621120b · paired CPU Standard, eight ABBA blocks.

Workload Baseline (ms) Candidate (ms) Time change
Unchanged remaps 2.831 0.178 −93.71%
Overlapping submissions −89.75%
Sparse changes −69.54%
Growth/shrinkage −67.15%
Sustained streaming −19.72%
Streaming invalidations −7.01%, inconclusive

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).

Workload Baseline (ms) Candidate (ms) Time change Verification
Unchanged remaps 2.079 0.138 −93.37% Identical
Overlapping submissions 2.868 0.509 −82.17% Identical
Sparse changes 2.261 0.746 −66.97% Identical
Growth/shrinkage 2.128 1.010 −54.66% Identical
Sustained streaming 16.183 13.867 −10.25% Inconclusive
Streaming invalidations 2.345 2.360 +0.77% Inconclusive

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

  • #468
  • Remaining replacement HWRT stages 2–7 (as specified in #429).
  • #429

Strip all borrowed HWRT commits after the prerequisites land; rebase onto main before merging.

What this does

reuse immutable BLAS remap snapshots.

Checks

  • Off-by-default and main parity: Snapshot switch defaults off; both modes change some lifetime/binding paths. Prove disabled-path equivalence and resolve exceptions after rebasing.
  • Docs move with code: Snapshot flag documented; menu decision and final policy checks pending.
  • No unrelated cleanup: Own remap change is isolated in the linked diff; main-based diff still carries prerequisite HWRT commits.
  • A test must exercise the change: Portable tests ran at 455dfdb, not current diagnostic head; rerun and verify fail-before/pass-after after rebase.
  • Queue checked on 2026-12-04: Follows #429 and replacement HWRT stages 1–7 (#468 begins the stack); not independent of these.
  • Run cargo xtask policy on 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

Dependency Pinned revision
LOCKhart07's replacement stack (starting at #468) rt-7-reuse @ c3a0500
#429 — batched RT invalidation 750e9b7
This PR — BLAS remap snapshots c8edd2f

Isolated 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 to c3a0500; 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.

  • Unmarked path: cache by Ledger::version when 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.
  • Marked path: retain exclusive uploads with per-remap stamps and slot indices. Snapshot reuse is disabled when named diagnostics are active. The packing helper preserves the logical table/indices/stamp layout; padding is zero.
  • Lifetime safety: production uses non-blocking 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=1 under VICTORY_HW_RT=1; default is off. To measure snapshot reuse, keep VICTORY_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 455dfdb

Apple 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.

Synthetic workload Off (ms) On (ms) Paired change (95% CI)
Unchanged remaps 0.124 0.015 −87.66% [−87.87%, −87.46%]
Overlapping submissions 0.194 0.059 −69.27% [−69.45%, −69.09%]
Sparse changes 0.179 0.094 −47.69% [−47.90%, −47.47%]
Growth/shrinkage 0.172 0.106 −38.25% [−38.50%, −38.01%]
Streaming invalidations 0.321 0.323 +1.05% [−0.55%, +2.68%], inconclusive
Sustained streaming 3.357 3.358 −0.02% [−0.58%, +0.55%], not significant

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 TableCache and RemapRun::bind() with modeled upload resources; it does not exercise production bind_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.

./tools/benchmark-suite/run compare 455dfdb 455dfdb --cpu-only --offline --suite raytracing --profile standard --blocks 4 \
  --base-env VICTORY_HW_RT_REMAP_SNAPSHOTS=0 \
  --cand-env VICTORY_HW_RT_REMAP_SNAPSHOTS=1 \
  --out local/benchmarks/rt9-integration/final-standard

Verification and limitations

The reported tests and benchmarks apply to 455dfdb. The follow-ups dbf61f4 and c8edd2f change only reporting in report_line(). Their isolated diffs were reviewed, but compilation and benchmarks have not been rerun on the new head.

  • Portable remap tests: debug 12 passed, release 11 passed, zero failures; one ignored timing test in each configuration, run separately in release.
  • Windows MSVC-target GPU all-targets cargo check passed with the local check-only mimalloc shim. Clippy reported no diagnostics in modified Rust files; the strict whole-crate run failed on pre-existing unrelated lints. No native GPU execution was performed.
  • Switch-policy test still fails on four pre-existing guard variables; the snapshot switch is recognized.
  • Kal0s-design's earlier independent review had no blocking concerns on archived revision c49d34b, not the new integration.
  • Diagnostics: dbf61f4 selects the active cache for left_out (mgr.marks.is_some()). c8edd2f also 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.

Test VICTORY_HW_RT_NAMED VICTORY_HW_RT_REMAP_SNAPSHOTS
Unmarked baseline 0 0
Unmarked candidate 0 1
Marked compatibility 1 0 vs 1 (reuse bypassed)

Keep the other HWRT switches fixed in each comparison; report whether VICTORY_HW_RT_REUSE is 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 parent 750e9b7 with 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.

**@⁠tommiehansen** on GitHub · 2026-12-04 10:55 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452) `tommiehansen:perf/rt-remap-snapshots` → `main` · +27505 −90 · 35 files · 43 commits · open > **Stacked PR — ready for review and community testing, not independent merge.** Do not merge before LOCKhart07's replacement HWRT stages 1–7 (starting with #468) and #429 have landed and the isolated change has been reconciled and revalidated against main. The main-based diff includes borrowed prerequisite commits. See the isolated review diff and outstanding checks below. ## Final Standard benchmark — latest HWRT foundation (2026-12-05) [CI: all 6 jobs passed](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47526488261) · head `4bd7270` · #429 `b07015e` and LOCKhart07 `621120b` · [paired CPU Standard](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47526488261/job/145694064575), eight ABBA blocks. | Workload | Baseline (ms) | Candidate (ms) | Time change | |---|---:|---:|---:| | Unchanged remaps | 2.831 | 0.178 | **−93.71%** | | Overlapping submissions | | | **−89.75%** | | Sparse changes | | | **−69.54%** | | Growth/shrinkage | | | **−67.15%** | | Sustained streaming | | | **−19.72%** | | Streaming invalidations | | | −7.01%, inconclusive | Identical correctness digests; native remap and freed tests passed in debug and release, shader checks passed. [Isolated current comparison](https://github.com/tommiehansen/VIctory-xmem/compare/b07015e...4bd7270). These are CPU benchmark results, not gameplay FPS. Still stacked; do not merge independently. ## Historical Standard benchmark — 2026-12-05 [Reproducible CI result](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47503640056/job/145622974581) · head `c8edd2f74d4e` · Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm). | Workload | Baseline (ms) | Candidate (ms) | Time change | Verification | |---|---:|---:|---:|---| | Unchanged remaps | 2.079 | 0.138 | **−93.37%** | Identical | | Overlapping submissions | 2.868 | 0.509 | **−82.17%** | Identical | | Sparse changes | 2.261 | 0.746 | **−66.97%** | Identical | | Growth/shrinkage | 2.128 | 1.010 | **−54.66%** | Identical | | Sustained streaming | 16.183 | 13.867 | **−10.25%** | Inconclusive | | Streaming invalidations | 2.345 | 2.360 | +0.77% | Inconclusive | 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 - [ ] #468 - [ ] Remaining replacement HWRT stages 2–7 (as specified in #429). - [ ] #429 Strip all borrowed HWRT commits after the prerequisites land; rebase onto main before merging. ## What this does reuse immutable BLAS remap snapshots. ## Checks - [ ] Off-by-default and main parity: Snapshot switch defaults off; both modes change some lifetime/binding paths. Prove disabled-path equivalence and resolve exceptions after rebasing. - [ ] Docs move with code: Snapshot flag documented; menu decision and final policy checks pending. - [ ] No unrelated cleanup: Own remap change is isolated in the linked diff; main-based diff still carries prerequisite HWRT commits. - [ ] A test must exercise the change: Portable tests ran at `455dfdb`, not current diagnostic head; rerun and verify fail-before/pass-after after rebase. - [x] Queue checked on 2026-12-04: Follows #429 and replacement HWRT stages 1–7 (#468 begins the stack); not independent of these. - [ ] Run `cargo xtask policy` on 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 | Dependency | Pinned revision | | --- | --- | | LOCKhart07's replacement stack (starting at #468) | [rt-7-reuse @ `c3a0500`](https://github.com/LOCKhart07/VIctory-xmem/tree/c3a0500cd519885aa1ff71ee6a91641cc1fbb25f) | | #429 — batched RT invalidation | `750e9b7` | | This PR — BLAS remap snapshots | `c8edd2f` | **[Isolated diff: 3 files, +1,920 / −90](https://github.com/tommiehansen/VIctory-xmem/compare/750e9b7441eceda2c54409e409d03c9ee7d5e7c6...c8edd2f74d4e48133f84c4f6c6955104fe5a2411)**. 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 to `c3a0500`; later upstream stack changes have not been included in this benchmarked revision. The old head is [archived](https://github.com/tommiehansen/VIctory-xmem/tree/archive/pr452-pre-rt7-c49d34b). [LOCKhart07 agreed to this integration order](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/429); 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. - **Unmarked path:** cache by `Ledger::version` when 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. - **Marked path:** retain exclusive uploads with per-remap stamps and slot indices. Snapshot reuse is disabled when named diagnostics are active. The packing helper preserves the logical table/indices/stamp layout; padding is zero. - **Lifetime safety:** production uses non-blocking `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=1` under `VICTORY_HW_RT=1`; default is off. To measure snapshot reuse, keep `VICTORY_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 `455dfdb` Apple 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. | Synthetic workload | Off (ms) | On (ms) | Paired change (95% CI) | | --- | ---: | ---: | --- | | Unchanged remaps | 0.124 | 0.015 | **−87.66%** [−87.87%, −87.46%] | | Overlapping submissions | 0.194 | 0.059 | **−69.27%** [−69.45%, −69.09%] | | Sparse changes | 0.179 | 0.094 | **−47.69%** [−47.90%, −47.47%] | | Growth/shrinkage | 0.172 | 0.106 | **−38.25%** [−38.50%, −38.01%] | | Streaming invalidations | 0.321 | 0.323 | +1.05% [−0.55%, +2.68%], inconclusive | | Sustained streaming | 3.357 | 3.358 | −0.02% [−0.58%, +0.55%], not significant | 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 `TableCache` and `RemapRun::bind()` with modeled upload resources; it does not exercise production `bind_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. ```sh ./tools/benchmark-suite/run compare 455dfdb 455dfdb --cpu-only --offline --suite raytracing --profile standard --blocks 4 \ --base-env VICTORY_HW_RT_REMAP_SNAPSHOTS=0 \ --cand-env VICTORY_HW_RT_REMAP_SNAPSHOTS=1 \ --out local/benchmarks/rt9-integration/final-standard ``` ## Verification and limitations The reported tests and benchmarks apply to `455dfdb`. The follow-ups `dbf61f4` and `c8edd2f` change only reporting in `report_line()`. Their isolated diffs were reviewed, but compilation and benchmarks have not been rerun on the new head. - Portable remap tests: debug 12 passed, release 11 passed, zero failures; one ignored timing test in each configuration, run separately in release. - Windows MSVC-target GPU all-targets cargo check passed with the local check-only mimalloc shim. Clippy reported no diagnostics in modified Rust files; the strict whole-crate run failed on pre-existing unrelated lints. No native GPU execution was performed. - Switch-policy test still fails on four pre-existing guard variables; the snapshot switch is recognized. - [Kal0s-design's earlier independent review](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/452) had no blocking concerns on archived revision `c49d34b`, not the new integration. - **Diagnostics:** `dbf61f4` selects the active cache for `left_out` (`mgr.marks.is_some()`). `c8edd2f` also 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. | Test | `VICTORY_HW_RT_NAMED` | `VICTORY_HW_RT_REMAP_SNAPSHOTS` | | --- | ---: | --- | | Unmarked baseline | 0 | 0 | | Unmarked candidate | 0 | 1 | | Marked compatibility | 1 | 0 vs 1 (reuse bypassed) | Keep the other HWRT switches fixed in each comparison; report whether `VICTORY_HW_RT_REUSE` is 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 parent `750e9b7` with 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](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47524529854) 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.
The title's ray-tracing programs walk the console's structures in a loop
of their own. With VICTORY_HW_RT=1 the translator recognises each such
loop and writes a DXIL RayQuery in its place, keeping the title's own
hit tests, masks and ordering rules as the candidate and commit steps.
A loop it cannot prove equivalent stays as translated before.

Ported from VIctory-NVIDIA PR #3706 (GPL-3.0), with the lifter's
exactness rules of dakisback2/VIctory-Nvidia-Linux (85b0b11b, 5485daf7)
by way of Leslie-d-a/VIctory-NVIDIA-HWRT; see the header of
emit/rayquery.rs.

New here: the 14 loops those leave unlifted (6 programs, given a forced
miss there). The console compiler reuses three registers as loop scratch
on the lanes that run the loop and reads their old values on the lanes
that do not; the lane sets pass through mask joins the lifter could not
relate. Joins whose inputs are all one mask now collapse to it, and the
reading lanes are refuted against the loop's entry lanes by an exact
search (Bools::sat_with; out of budget refuses). All 64 ray-tracing
programs and their 397 loops lift and pass the DXIL validator.

Two fixes on the way, with the switch off too (translator version up):
the sign of zero in v_mad_legacy, and partial stores through a counter
view. Apart from those, the output with the switch off is unchanged.

`victory translate` names an emit panic per program and prints a
ray-tracing summary. A run refuses the switch until the host side is in.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The host side of the lifted ray queries. Started from VIctory-NVIDIA
PR #3706 (GPL-3.0) as ported to RADV by
MJ26gaming/victory-rdna4-linux-rt-MJ26 365fad515; see the header of
hwrt.rs for what was taken and what was left out.

The title's structure builder keeps running (a tap, not a replacement):
its build, refit and copy calls are passed on, and the same triangles
and instances go into host bottom- and top-level structures that the
lifted programs trace.

- Inputs follow the console builder's rules: only a NaN in X makes a
  triangle inactive; infinite and far positions pass through; indices
  and meshlets past the stated counts read the title's real bytes.
  Every departure is counted by what it changed, and bytes that cannot
  be read are a counted loss, never a silent zero.
- No budget evicts a structure and no instance is masked.
- Host work is recorded in the title's lists at the title's call, and a
  ledger keeps it in the card's order. Structures that are not refit
  are compacted exactly.
- Loss counters are printed with the frame-rate lines; all 0 over the
  check runs.
- VICTORY_RT_STAMPS=rt (diagnostics) stamps only the ray-tracing
  dispatches and the host builds. Over two 5 minute runs in the same
  place: trace passes 5.4 ms a frame as translated loops, 0.9 ms as
  ray queries, plus 0.5 ms for the host builds.
- A run takes VICTORY_HW_RT=1. Not yet checked hit for hit against the
  console's own walk on a captured frame.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
In free play the host structures grew past 7 GB in a few minutes and
kept growing. Measured by what each buffer holds, almost all of it was
structures kept at the driver's largest size:

- An updatable structure costs about four times a compacted one's bytes
  a triangle on RADV (its refit needs a fixed leaf region), and the
  title allows updates of many structures it never updates, or updates
  once. A structure is now built without ALLOW_UPDATE on the host, and
  becomes updatable only when the title updates it again within a
  second of its last update; an update short of that is built in full,
  the same triangles.
- Every structure built without ALLOW_UPDATE is compacted by the host
  once built, through the tickets the title's own COMPACT copies use:
  rehydrates (ready-made on the console, never copied by the title) and
  the title's builds it does not copy.
- Structures the title builds over are dropped: the builder's own
  prebuild sizes are tapped, and a structure kept at an address inside
  the bytes a new build was given goes, as with freed title memory.

The report says where the bytes are: alive by what they hold, in the
tap's map or outside it, updatable ones by their last update and by
how many updates they had, the host's own cost (buffers made,
compaction points), and the console's bytes next to the host's where
the console's are known. An event the card's order refuses is logged
with what the ledger held there.

Over a 3 minute drive: 7.3 GB and growing before; steady between 2.1
and 2.5 GB after, every loss counter 0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
With hardware ray tracing nothing of ours reads what the title's
structure builder writes: every traversal loop is a ray query on the
host's structures, and those are built from the title's inputs. The
title reads one result of it: the compacted size a build is asked for,
which is the node count of the tree that build made, read back a frame
or two later to size the copy. No other program can give that number.

With the switch (only with VICTORY_HW_RT=1) each request of a tapped
call is kept or skipped:

- A bottom-level build that carries postbuild descriptions is kept:
  the builder runs it as ever and the title reads its own size. A copy
  of a structure a kept build made is kept too.
- Every other build, update, top-level build, rehydrate and copy is
  skipped. The title's export is still called, so its checks and
  results stay its own, between two marks in the list: the builder's
  dispatches recorded between them are dropped when the list is
  translated, before anything is bound. A batch is given to the export
  as runs, in its order.
- A request that asks a size and cannot be kept (a top-level build, an
  update of a structure no kept build made) is skipped, counted and
  logged as an error. None was seen.

The builder's stages run all or none, so whole calls are kept or
skipped, and a kept stage reads only what a kept one wrote.

A report line counts requests kept, skipped by kind, copies, losses
and dispatches dropped; an error is logged if a dispatch reads title
memory by address while the switch is on (a program not lifted).

By the builder's own stamps, standing still: 2.05 ms of card time a
frame before, 0.1 ms with the switch (98 dispatches dropped a frame).
Driving: 1.4 ms mean. Losses 0 in both, every hardware ray-tracing
loss counter 0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Four files of the shader crate conflicted with #283, which fixed the same two things another way:

- legacy_fmad's zero addend: kept this branch's form, worked on the bits (-0 gives +0, and a NaN addend comes out quieted as the console's arithmetic gives it); main's comparison against zero covers the sign alone.
- the joined mask and number test, the image store test and the container hash test: kept this branch's, which check more (a full and a partial wave, every channel mask against the store of one, the validator's hash).

TRANSLATOR_VERSION 14: main's 13 is the legacy multiply, and this branch changes the legacy mad's NaN and partial stores through a counter view with the switch off.

Shader crate tests: 412 passed, 0 failed. The gpu crate's hardware ray-tracing tests: 43 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Every submission in flight made an upload buffer of its own for what it sends up, sized to what was asked, and kept it until the submission was done. A buffer given back was used again only by a request of the same size, so most were made new: about 570 MB of them stood on the card at the end of a six minute run.

Now a buffer is made at the next power of two (64 KiB at least) and, once its submission is done, kept spare for the next request of that size. Spare buffers not taken for 10 s are let go, and so is what passes 768 MB of spare; both go through host::retire, as other memory the card may still read.

Measured on an RX 9070 XT (RADV), 2560x1440, six minutes with the camera turning, hardware ray tracing on: 3 buffers alive (0.9 MB), 6 made in the whole run, 3 let go by the trim, none for the cap. Three runs, no error line, no device loss.

Two report lines say it: what submissions send up (alive, in flight, spare, made, let go), and the host's buffers by who makes them.

Tests: host::send, 6 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Every host bottom-level structure was a committed buffer of its own: 73,703 buffers made in 6.9 s of one play (the longest 73 ms), and 363 MB lost to their 64 KiB placement.

Now they are cut from 64 MiB blocks at 4 KiB (VICTORY_HW_RT_ARENA, on by default; =0 gives every structure its own buffer as before). Two sets of blocks, by how long a structure lives: one for those built in full and not updatable, which are compacted or replaced soon and go; one for updatable, copied and compacted ones, which stay. Mixed in one set, the short-lived left holes among the long-lived and no block ever emptied: 1,664 MB of blocks for 888 MB of structures. A piece is given back when the structure is dropped, which host::retire already does only after the lists that used it, so it rests no further and is free at once. Top-level structures keep their own buffers.

Measured on an RX 9070 XT (RADV), 2560x1440, six minutes with the camera turning: 32 structure buffers made in 11 ms (the longest 5 ms); 20 blocks (1,280 MB) for 1,023 MB of structures, nothing resting, 6 of the short-lived set's blocks made and 4 given back. Three runs, all loss counters 0, no error line. The gain is in the buffers no longer made; the bytes are about what the buffers took (a different scene from the 363 MB above, so not a pair).

Report lines with it, which the next changes are read from:
- the blocks of structures of each set (alive, held, resting, free, made, given back);
- the build memory (scratch, instances and sanitised copies): what lists hold now, asked for against handed out, buffers made and how long that took, the spare by size and how much of it was not taken lately;
- texture blocks by the tenth of them textures hold, their free space, and the textures' copy footprints against the pieces they lie in (what the pieces' rounding costs);
- the texture queue's slots held back for want of room on the card.

Tests: pool 13 passed, hwrt 47 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Every texture cut from a texture block was asked at 64 KiB, so each took a multiple of 64 KiB. Most of the title's textures are small: their copy footprints came to 1,599 MB in 2,760 MB of pieces, 1,161 MB of rounding.

Now a texture is asked with D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT where the host says it has it (D3D12_FEATURE_D3D12_TIGHT_ALIGNMENT, tier 1 or more), and its piece is the size at the alignment the host answers: 4 KiB multiples for a small one (256 bytes for the smallest), 64 KiB as before for a large one. The host is asked once and the texture is made with the description the size was asked for. A host without the tier is asked as before.

The earlier 4 KiB placement (VICTORY_POOL_SMALL, removed after two device losses on 2026-11-25) asked at 4 KiB and, refused, asked again at 0; the flag is never refused. What those losses were was not proven. The new test places 11 kinds of small texture three times over back to back from 0x6000 into a heap (the kind and place of those losses first), in each of the three ways of asking, writes every level with bytes of its own, reads them back by a copy and then by a shader through a view of the whole chain and one of each level, and compares with the same texture on a 64 KiB multiple: 500 reads compared, none differ, on an RX 9070 XT (RADV), where the driver lays such textures out at 4 KiB (so nothing is padded).

Measured there, 2560x1440, six minutes with the camera turning, against the run before it (not a pair: the scene streams): rounding 1,161 MB -> 108 MB (2,014 MB of footprints in 2,123 MB of pieces); texture blocks 64 -> 56; slots held back for want of room on the card 152 -> 0; host copies let go for room 6,495 MB -> 3,359 MB; card in use 13,326 -> 13,020 MB with 415 MB more of texture loaded. No error line, no device loss, the picture looked right.

Tests: pool 14 passed (the new one among them), resource 16, texture 11.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A structure the title updates twice within a second is built with ALLOW_UPDATE from then on and stays so for good. Much of what earns that is updated for a while and then left alone (it is still read by the top level). On RADV an updatable structure keeps a fixed layout of about 177 bytes a triangle that compaction cannot shrink, against about 46 for a compacted one, so the idle ones hold most of the structure memory they do not need.

With the switch on:

- A build of an updatable structure keeps its inputs (the staged vertex, index and transform pieces and the geometry descriptions) with the structure, in pieces of its own. Inputs under 256 KiB, inputs decoded or staged in place, boxes and copies are not kept, and such a structure is left as it is.
- At the card point at the start of a submission, every 250 ms, structures not updated and not read as a refit source for 10 s are built again from the kept inputs without ALLOW_UPDATE, at most 16 MiB of them a pass, and then compacted by the path that exists. The swap is an event in card order like a compaction, so reads and copies tapped before it see the old structure and those after it the new one.
- An update of such a structure is never a refit: it is a full build, and the existing rule makes it updatable again if the title keeps updating it. The wait before it is put to sleep again doubles each time, up to 80 s.
- The old structure, its inputs and the scratch are let go only after the submissions that may use them are done, as elsewhere.

The kept inputs come from a pool of their own. Sharing the build pool made it overflow its 256 MB of spare pieces every frame (39,166 buffers made in five minutes); with their own pool none are let go past the bound.

This also changes the pool of build pieces itself, switch or no switch: a spare piece is picked by how lately it was used and one idle for 10 s is let go. That part alone was not shown to gain anything in play.

Measured on an RX 9070 XT (RADV, Mesa 26.3.1), 2560x1440, nine minutes of driving, one run: 448 structures put to sleep, 444 of them compacted, 1,695 MB -> 455 MB; none failed; 25 were updated afterwards and 24 became updatable again; inputs held at the end 129 MB; the card points took 387 ms in all, the longest 10.8 ms; 120 idle updatable structures left (25 MB: small ones and one staged in place). No error line, no device loss, every loss counter 0, the picture looked as before.

What it does not do: the freed bytes stay inside the 64 MiB structure blocks until a block empties (1,487 MB free in 49 blocks at the end), and the card still fills, because compacted structures nothing names any more are never let go. Buffers made for builds are more than without the switch (about 2,300 a minute against about 600), though the longest wait for one was shorter (57 ms against 203 ms). Other drivers and cards were not tried.

Tests: hwrt 57 passed (the verdict table, the swap at the card point, refits and copies tapped before the swap, an update after it not a refit, what is kept, the pick and the wait, the pool of kept pieces).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Long-lived bottom-level structures share 64 MiB blocks, and a block goes back to the card only when nothing is left in it. When compaction, or the rebuild of idle updatable structures, shrinks what the blocks hold, the survivors stay spread over all of them: at the end of one nine-minute play 49 blocks (3,136 MB) held 1,648 MB, and none had emptied in the last four minutes. The holes are used again by later structures, so this is a high-water mark rather than fragmentation, but the card does not get the memory back.

With the switch on:

- Updatable structures are cut from blocks of their own. They are never moved, and so no longer pin a block of the others.
- At the card point at the start of a submission, every 250 ms, while more than a quarter of the long-lived blocks' bytes is free (four blocks' worth at least), the emptiest blocks are marked to be emptied, as many as the free bytes of the rest can take with 128 MB to spare. Nothing new is cut from a marked block while another has room.
- Structures in marked blocks are copied (a clone) into the fullest block that stays, at most 8 MB and 32 structures a card point, and put in their place in card order as a compaction is: reads and copies tapped before see the one moved from, those after the one moved into. A move never makes a block; no room is a skip, counted.
- A structure is moved only if the tap and the ledger agree on it, it is not updatable, no write of its address is tapped and not yet in card order, no compaction waits at its address, it is 10 s old, and it was not moved in the last 60 s (the ledger's alias names one structure back).
- The one moved from is let go only after the submissions that may use it are done, as elsewhere. A top-level structure built before the move keeps it until its next build.

With the switch off nothing is marked or moved and updatable structures stay where they were. Three things on shared paths change form but not result: the texture report's count of blocks cut from again is kept per pool, a structure piece is given back through a function that also looks for a mark (there is none), and a compacted structure is stamped with when it was made. The new report line prints with the switch off too.

Measured on an RX 9070 XT (RADV, Mesa 26.3.1), 2560x1440, one play of 36 minutes on my local tree (this change with a counting-only switch of mine also on): 31 blocks marked, 25 empty after moves and 3 by themselves, 17 given back to the card (1,088 MB); 4,080 structures moved (822 MB) in two bursts of about half a minute; the card points' part 238 ms in all, the longest 1.7 ms; no try found no room; the old places not yet free came to 210 MB at most. Every loss counter 0, the two of card order among them (a write after a newer one at the same address, a refit or copy whose source is not the one assumed).

That play ended in a device loss at minute 36, with the card and the memory shared with it both full and structures grown from 2.4 GB to 3.8 GB in the last quarter of an hour. The last move was 17 minutes before it and the blocks were 98% full by then. What caused it is not known, and this change does not stop that growth: it returns space that is free, no more.

Not tried: this branch itself in play (the diagnostics build compiles and its tests pass), other cards or drivers, the cost of the copies on the card (not measured; the bytes a card point moves are bounded).

Tests: hwrt 64 passed (7 new: the verdict table, the swap, a compaction waiting, copies tapped before a move and two moves back, the pick, the blocks of updatable ones, the count of blocks), pool 18 passed (4 new: the marking, the destination, the fallback, an emptied marked block).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings the lifted ray queries and host structures (VICTORY_HW_RT=1), the
structure blocks, the send-memory and texture-block changes, and the two
structure-memory switches (VICTORY_HW_RT_DEMOTE=1, VICTORY_HW_RT_PACK=1)
up to main. All of these switches stay off by default.

Two files conflicted:

- crates/victory-gpu/src/descriptor/host.rs, TextureQueue::scan. Main
  now walks only the due front of `by_due` and reads the kinds of slots
  from counts kept as slots change; this side had added, to the old walk
  of every slot, the count of slots held back for want of room on the
  card (QUEUE_HELD). Kept main's walk and counts, and put the held-back
  count before it: it walks `held` alone, not every slot.

- crates/victory-shader/src/lib.rs, TRANSLATOR_VERSION. Main went from
  13 to 19, this side from 13 to 14 for two fixes that change
  translations with the switches off (the sign of zero in
  v_mad_legacy, partial stores through a counter view). Both sets of
  changes are in, so the version is 20: translations cached by either
  side are made again.

Nothing else needed a change: the other files merged as they were, and
the 64 ray-tracing programs still lift whole on main's translator (397
of 397 loops, all 64 validated).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings VICTORY_HW_RT_LEAN_BUILDER=1 (off by default; only with
VICTORY_HW_RT=1): the title's structure builder runs only where the
title reads its result.

Nothing conflicted. The change to the work a title list runs at a place
of its own (it is now given the draw state too) merged with the
hardware ray-tracing operations recorded the same way, and the report
line is called from the hardware ray-tracing report as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Collect half-open ranges between hardware RT operations, merge adjacent or overlapping spans, and visit the tap and index caches once. Publish the batch at its tap sequence so earlier ledger calls still see their structures. Flush at RT observation boundaries and keep immediate single-range invalidation when the switch is off or an operation is active.

Adapted from Darner 775a0c7f36adfa2049820fc540a9d98fb632e7f4.
Track the key order of the four RT tables under their existing locks when explicitly enabled. Limit frees and build-overlap queries to matching guest addresses while keeping hash lookups for the translation path. Maintain the index only when inserting or removing a key and keep sequencing and retirement at their existing boundaries.
Fall back to a sequential hash sweep when range hits exceed the sparse removal budget. Trim the ordered index in one pass, using a tree split for an edge-aligned range. Keep the two structures consistent across partial sparse removals and fall back to hash-only lookups if the dense retirement callback unwinds.
Register RT activity and pending batches in one atomic state. Entering work waits for a published batch and mapping cannot collect into a batch while an RT operation is active. Preserve the first original notice for TLAS diagnostics and cover concurrent gate entry and nested work.
Keep sorted keys within address blocks and store singleton blocks inline. Dense frees discard fully covered buckets without comparing or removing individual index keys. Keep half-open boundary matching exact for composite keys and preserve the original hash table for hot lookups.
Publish the queue bit only for the first notice and use the queue mutex to order later appends with waiting entrants. Build a single span directly when notices form one growing interval, preserving original diagnostic order and falling back to sorted joining for fragmented batches.
Remove the secondary ordered key index. Use the guest block to choose a hash-table partition, find affected partitions with a bounded mask, and drain partitions covered by one free span without scanning unrelated entries. Preserve half-open matching where addresses collide in a partition.
Use fewer hash partitions to reduce the number of short walks on wide address ranges. Keep direct lookups bounds-check free and skip partition-mask construction for single-block overlap queries. Update range bounds only when an address is introduced.
Retain the direct hash partitions for the first address band and own more distant bands in a range-addressable table. Dense frees can drain complete bands instead of repeatedly filtering unrelated entries with the same partition slot. Keep adjacent and disjoint spans exact without revisiting any overflow band in the batch.
Use exact hash lookups for overflow bands to reduce scattered mutation costs. Probe small invalidation ranges directly and sweep only populated bands for wide ranges. Retire emptied hash partitions during the same sweep and keep direct-home lookup unchanged.
Select the representation while the table is small, using address locality to keep dispersed keys in a single hash table. Use a reserved adjacent band for workloads that grow continuously beyond their first band. Add a differential check that promotion preserves keys and dispersed tables stay flat.
Apply the same locality check beyond the direct bands. Keep a single hash table for dispersed spill and promote a concentrated band in place. Preserve half-open invalidation when a clustered table later acquires far-apart addresses.
Collapse a still-small registry when early overflow proves scattered. Keep whole-resource visits in the underlying table loops, and derive direct partition bounds from address bits instead of updating them on inserts.
Use the tested automatic layout when hardware RT is enabled, with independent zero-valued overrides for diagnosis. Preserve the registry borrow across bulk visitor calls so remap construction can retain references until it finishes.
Keep the same direct address band with fewer hash tables. This reduces whole-map iterator setup while limiting a local free to the covered portions of the band.
Classify address locality from a bounded sample already in the original hash table. Keep its exact allocation and hash state when the sample is dispersed. Use fewer direct partitions to reduce full traversal overhead further.
Extend the direct address window to two adjacent bands. Use the same offset lookup and fixed bounds in both bands, so additional clustered keys update no secondary state. Classify sparse address bands by exact identity and test the top-of-address-space boundary.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 11:01:56 +00:00
Author
Owner

@⁠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-snapshots contains all 30 commits of perf/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.rs 784 new lines, hwrt.rs rewritten around it, one docs/SETTINGS.md row). What GitHub shows against main is +23,545/−138 over 37 files, i.e. the entire lower PR again.

Two consequences, both avoidable:

  • Reviewers cannot see the new work. Anyone opening this PR re-reviews 23k lines they have already seen, and the one new idea — snapshot reuse keyed by ledger version — is buried at the top of it.
  • The stack grows in the wrong direction. Each layer is based on 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:

  1. Retarget this PR at perf/rt-freed-gathered so its diff is the one commit, and let it land after its base. Stack depth 2 is fine and reviewable.
  2. Or split the base into the pieces suggested there, and land this snapshot change on top of the RT-structures PR only — it looks independent of the pool/memory work.
  3. If neither, at least say in the description which commit is new and which numbers move for it alone.

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](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7409443991) This one is a stack, not a change, and the diff a reviewer gets does not show that. `perf/rt-remap-snapshots` contains all 30 commits of `perf/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.rs` 784 new lines, `hwrt.rs` rewritten around it, one `docs/SETTINGS.md` row). What GitHub shows against `main` is +23,545/−138 over 37 files, i.e. the entire lower PR again. Two consequences, both avoidable: - **Reviewers cannot see the new work.** Anyone opening this PR re-reviews 23k lines they have already seen, and the one new idea — snapshot reuse keyed by ledger version — is buried at the top of it. - **The stack grows in the wrong direction.** Each layer is based on `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: 1. Retarget this PR at `perf/rt-freed-gathered` so its diff is the one commit, and let it land after its base. Stack depth 2 is fine and reviewable. 2. Or split the base into the pieces suggested there, and land this snapshot change on top of the RT-structures PR only — it looks independent of the pool/memory work. 3. If neither, at least say in the description which commit is new and which numbers move for it alone. 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.
Author
Owner

@⁠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:

  • It cannot be reviewed, so it is not reviewed. A 23k-line diff with 37 files gets a skim and a question, not a read. The good parts end up merged on trust or dropped on doubt — both lose the work.
  • It holds the queue. While it waits, it touches 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.
  • Its own size hides its own result. A PR that cannot state "this change moved this number" reads as "something in here helps". That is exactly where review stalls, and where a later regression becomes unbisectable.

Five habits that cost you almost no extra work and fix most of that:

  1. One PR, one decision. If a reviewer might accept half of it, it is two PRs. The commits are already layered that way — hardware structures, shader ray-query lowering, pool/memory, HLE, docs — each of those is a PR on its own.
  2. Stack with the base set. Base the child on the parent branch, not on main, so the diff GitHub shows is the increment. Retarget to main with gh pr edit --base main after the parent merges.
  3. Never point a stack at main. That is what makes a one-commit change show up as 23k lines, as this PR currently does.
  4. One measurement per PR, for that PR's change alone — even a coarse one. It is what makes the merge defensible later, when the numbers are the only thing left to argue with.
  5. Fewer in flight. Ten open PRs of that size is more than any queue can absorb; each merge invalidates the others. Three or four well-sized ones will merge faster than ten big ones — I would wager the total landed code is higher too.

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 10:58 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7409457658) 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: - **It cannot be reviewed, so it is not reviewed.** A 23k-line diff with 37 files gets a skim and a question, not a read. The good parts end up merged on trust or dropped on doubt — both lose the work. - **It holds the queue.** While it waits, it touches `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. - **Its own size hides its own result.** A PR that cannot state "this change moved this number" reads as "something in here helps". That is exactly where review stalls, and where a later regression becomes unbisectable. Five habits that cost you almost no extra work and fix most of that: 1. **One PR, one decision.** If a reviewer might accept half of it, it is two PRs. The commits are already layered that way — hardware structures, shader ray-query lowering, pool/memory, HLE, docs — each of those is a PR on its own. 2. **Stack with the base set.** Base the child on the parent branch, not on `main`, so the diff GitHub shows *is* the increment. Retarget to `main` with `gh pr edit --base main` after the parent merges. 3. **Never point a stack at `main`.** That is what makes a one-commit change show up as 23k lines, as this PR currently does. 4. **One measurement per PR**, for that PR's change alone — even a coarse one. It is what makes the merge defensible later, when the numbers are the only thing left to argue with. 5. **Fewer in flight.** Ten open PRs of that size is more than any queue can absorb; each merge invalidates the others. Three or four well-sized ones will merge faster than ten big ones — I would wager the total landed code is higher too. 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.
Author
Owner

@⁠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), one docs/SETTINGS.md row.

Step 1 — retarget, do not split. Point this PR at perf/rt-freed-gathered instead of main:

gh pr edit 452 --base perf/rt-freed-gathered

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 main and 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.rs alone, 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 — the hwrt.rs rewrite 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 --base mechanics 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.

**@⁠Luxuride** on GitHub · 2026-12-04 11:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7409546182) 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), one `docs/SETTINGS.md` row. **Step 1 — retarget, do not split.** Point this PR at `perf/rt-freed-gathered` instead of `main`: ```sh gh pr edit 452 --base perf/rt-freed-gathered ``` 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 main` and 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.rs` alone, 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` — the `hwrt.rs` rewrite 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 `--base` mechanics 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.
Author
Owner

@⁠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::version before 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 from next_serial() (5038, 5192, 5264, 5536, 6584, 7139). So rebuilds into another buffer, copies and compactions all bump. Frees go through catch_up, which bumps when a BLAS goes (2584-2594). The host address is a OnceLock (2040), so it can't change under an entry. A BLAS whose buffer is made later by mem_of (4308-4332) without a bump is left out and counted, exactly as before this PR. Ledger::new is 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> through TableCache::prepare_remap and 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. RemapCell and its REMAP_ARGS slot are made together at translation (6338-6348, 6386-6388), and both are dropped only in HostList::reset, after the list's last submission finished (host.rs:5148-5189). Nothing else writes the args after translation. The same-Arc skip in RemapRun::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 through host::retire with BURY_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 case REMAP_REWRITTEN already counted. Reusing an unchanged snapshot now skips that write, which is safer if anything.

Opt-out. VICTORY_HW_RT_REMAP_SNAPSHOTS=0 takes the Owned path (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 from LEASE_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=2 with VICTORY_D3D12_DEBUG=1. On the NVIDIA card, WARP via VICTORY_BENCH_WARP=1, and WARP via --features diagnostics with 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 reach write_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. RemapStats is 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

**@⁠Kal0s-design** on GitHub · 2026-12-04 11:08 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7409687130) 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::version` before 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 from `next_serial()` (5038, 5192, 5264, 5536, 6584, 7139). So rebuilds into another buffer, copies and compactions all bump. Frees go through `catch_up`, which bumps when a BLAS goes (2584-2594). The host address is a `OnceLock` (2040), so it can't change under an entry. A BLAS whose buffer is made later by `mem_of` (4308-4332) without a bump is left out and counted, exactly as before this PR. `Ledger::new` is 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>` through `TableCache::prepare_remap` and 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. `RemapCell` and its `REMAP_ARGS` slot are made together at translation (6338-6348, 6386-6388), and both are dropped only in `HostList::reset`, after the list's last submission finished (host.rs:5148-5189). Nothing else writes the args after translation. The same-Arc skip in `RemapRun::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 through `host::retire` with `BURY_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 case `REMAP_REWRITTEN` already counted. Reusing an unchanged snapshot now skips that write, which is safer if anything. Opt-out. `VICTORY_HW_RT_REMAP_SNAPSHOTS=0` takes the `Owned` path (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 from `LEASE_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=2` with VICTORY_D3D12_DEBUG=1. On the NVIDIA card, WARP via VICTORY_BENCH_WARP=1, and WARP via `--features diagnostics` with 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 reach `write_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. `RemapStats` is 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
Author
Owner

@⁠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-gathered does not exist in the upstream repository, so retargeting the upstream PR with gh pr edit --base is 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:

  • #429: eliminates repeated RT structure registry scans. @⁠khift363 reported an improvement from roughly 15–25 to 25–40 FPS while driving on an RX 7900 XTX with #374. This is a qualitative gameplay report, but a particularly encouraging one.
  • #452: eliminates redundant BLAS remap table uploads. The isolated CPU benchmarks show up to 89% lower processing time and 95.8% less copied data, with no additional dispatches or barriers modeled by the CPU fixture. Gameplay validation is still needed.

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:11 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7409769664) · 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-gathered` does not exist in the upstream repository, so retargeting the upstream PR with `gh pr edit --base` is 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: - **#429:** eliminates repeated RT structure registry scans. @⁠khift363 reported an improvement from roughly 15–25 to 25–40 FPS while driving on an RX 7900 XTX with #374. This is a qualitative gameplay report, but a particularly encouraging one. - **#452:** eliminates redundant BLAS remap table uploads. The isolated CPU benchmarks show up to 89% lower processing time and 95.8% less copied data, with no additional dispatches or barriers modeled by the CPU fixture. Gameplay validation is still needed. 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](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/429). [Review #452's isolated three-file diff](https://github.com/tommiehansen/VIctory-xmem/compare/750e9b7...455dfdb). Current CPU results are in the PR descriptions; the original figures above are historical.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 11:28 UTC · original · edited 2026-12-04 15:46 UTC

Pushed commit c49b6c8 hardening PR #452 and updated the PR description with a prominent isolated diff link right at the top: bb184d8...c49b6c8.

@⁠Luxuride — Understood on why --base makes stacked PRs much cleaner to review on GitHub; once the prerequisite HWRT stack / #429 land upstream (so the parent branch exists in lobomfz/VIctory-xmem), we can switch the PR base immediately, and in the meantime the direct bb184d8...c49b6c8 compare link isolates only the 4 files touched by #452.

@⁠Kal0s-design — Thanks for the thorough code walk and Windows/NVIDIA + WARP test pass! c49b6c8 also addresses both items you noted alongside additional lifetime hardening:

  • Restored HwRtManager::tables to LeasePool::new() (256 MiB spare cap) so =0 / off matches the pre-PR pool capacity.
  • Added single-owner RemapBuf memory accounting and added remap telemetry for snapshot activity and upload memory; the subsequent review identified unwired binding counters.
  • Switched VICTORY_HW_RT_REMAP_SNAPSHOTS=1 to opt-in (off by default) pending real game GPU validation.
  • Fixed indirect-arg / upload-OOM lifetime hazards: RemapRun::bind waits on unretired prior submissions via host::wait_submission before writing args and preserves the first table on same-submission duplicate command lists (same_sub_conflict); unmade > 0 incomplete mappings are not cached; upload OOM preserves previous BlasRefs and args while the prior mapping can be stale; removed raw pointers from the upload callback; borrowed &mem.kept during ledger.map.visit and short-circuited tlas_step via Arc::ptr_eq.
  • Verified local #374 (VICTORY_HW_RT_NAMED) compatibility against e95cab7 (Windows MSVC cargo check exited 0) without pulling #374 into #452, and re-verified on Windows MSVC clippy (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 455dfdb uses non-blocking binding, preserves the replacement stack's LeasePool::aging(demote_on()), and limits snapshot reuse to unmarked tables. See the current isolated diff.

**@⁠tommiehansen** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7410139457) · edited 2026-12-04 15:46 UTC Pushed commit `c49b6c8` hardening PR #452 and updated the PR description with a prominent isolated diff link right at the top: [`bb184d8...c49b6c8`](https://github.com/tommiehansen/VIctory-xmem/compare/bb184d8...c49b6c8). @⁠Luxuride — Understood on why `--base` makes stacked PRs much cleaner to review on GitHub; once the prerequisite HWRT stack / #429 land upstream (so the parent branch exists in `lobomfz/VIctory-xmem`), we can switch the PR base immediately, and in the meantime the direct `bb184d8...c49b6c8` compare link isolates only the 4 files touched by #452. @⁠Kal0s-design — Thanks for the thorough code walk and Windows/NVIDIA + WARP test pass! `c49b6c8` also addresses both items you noted alongside additional lifetime hardening: - Restored `HwRtManager::tables` to `LeasePool::new()` (`256 MiB` spare cap) so `=0` / off matches the pre-PR pool capacity. - Added single-owner `RemapBuf` memory accounting and added remap telemetry for snapshot activity and upload memory; the subsequent review identified unwired binding counters. - Switched `VICTORY_HW_RT_REMAP_SNAPSHOTS=1` to **opt-in** (`off` by default) pending real game GPU validation. - Fixed indirect-arg / upload-OOM lifetime hazards: `RemapRun::bind` waits on unretired prior submissions via `host::wait_submission` before writing args and preserves the first table on same-submission duplicate command lists (`same_sub_conflict`); `unmade > 0` incomplete mappings are not cached; upload OOM preserves previous `BlasRefs` and args while the prior mapping can be stale; removed raw pointers from the upload callback; borrowed `&mem.kept` during `ledger.map.visit` and short-circuited `tlas_step` via `Arc::ptr_eq`. - Verified local `#374` (`VICTORY_HW_RT_NAMED`) compatibility against `e95cab7` (Windows MSVC `cargo check` exited 0) without pulling `#374` into `#452`, and re-verified on Windows MSVC `clippy` (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 `455dfdb` uses non-blocking binding, preserves the replacement stack's `LeasePool::aging(demote_on())`, and limits snapshot reuse to unmarked tables. See the [current isolated diff](https://github.com/tommiehansen/VIctory-xmem/compare/750e9b7...455dfdb).
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 11:37 UTC · original

Re-checked c49b6c8, just the changes since f9dc2c3. Looks good to me. A few notes.

The new wait in RemapRun::bind runs on the submitting thread, inside run_deferred. At that point it holds the submission lock, the list's deferred lock (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 through detach (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_table or cell locks. hwrt registers no after_gpu observers, and the drops in bury only 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's deferred in read_backs (host.rs:3799) before it stores FINISHED (host.rs:4210). A debug_assert or a comment there could help.

same_sub_conflict makes both runs of a list named twice in one ExecuteCommandLists read the first table, and the TLAS gets that table's refs. bb184d8 overwrote 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 bb184d8 that I found in hwrt.rs.

  • The duplicate-in-one-submission case above.
  • With unmade > 0 the CPU table is rebuilt on every remap, even at the same version (remap.rs:186). bb184d8 reused it until the version changed.
  • On OOM the TLAS keeps the cell's refs (bb184d8 set them to None). Both are safe.
  • tlas_step skips the replace and retire when the refs are the same Arc. That has no visible effect.
  • Table buffers go through retire(RemapBuf) instead of retire_resource, and bury drops both the same way.
  • There's extra timing and counters, plus the new report line.

tables is back on LeasePool::new() (hwrt.rs:4191, 256 MiB via LEASE_SPARE at hwrt.rs:838), and all seven REMAP_DIAG slots are printed at hwrt.rs:3912-3925. Waits and arg skips/writes aren't counted anywhere, though (waited_prior and args_written are unused, remap.rs:338-340). Conflicts and OOM show up only through the existing REMAP_REWRITTEN/NOT_DONE line (hwrt.rs:3866-3867). RemapStats is still write-only outside tests.

I ran cargo test -p victory-gpu --lib hwrt with 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 reach write_table/bind with 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 randomized bind sequence 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

**@⁠Kal0s-design** on GitHub · 2026-12-04 11:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7410349383) Re-checked c49b6c8, just the changes since f9dc2c3. Looks good to me. A few notes. The new wait in `RemapRun::bind` runs on the submitting thread, inside `run_deferred`. At that point it holds the submission lock, the list's `deferred` lock (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 through `detach` (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_table` or cell locks. hwrt registers no `after_gpu` observers, and the drops in `bury` only 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's `deferred` in `read_backs` (host.rs:3799) before it stores `FINISHED` (host.rs:4210). A `debug_assert` or a comment there could help. `same_sub_conflict` makes both runs of a list named twice in one ExecuteCommandLists read the first table, and the TLAS gets that table's refs. bb184d8 overwrote 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 bb184d8 that I found in hwrt.rs. - The duplicate-in-one-submission case above. - With `unmade > 0` the CPU table is rebuilt on every remap, even at the same version (remap.rs:186). bb184d8 reused it until the version changed. - On OOM the TLAS keeps the cell's refs (bb184d8 set them to `None`). Both are safe. - `tlas_step` skips the replace and retire when the refs are the same `Arc`. That has no visible effect. - Table buffers go through `retire(RemapBuf)` instead of `retire_resource`, and `bury` drops both the same way. - There's extra timing and counters, plus the new report line. `tables` is back on `LeasePool::new()` (hwrt.rs:4191, 256 MiB via `LEASE_SPARE` at hwrt.rs:838), and all seven `REMAP_DIAG` slots are printed at hwrt.rs:3912-3925. Waits and arg skips/writes aren't counted anywhere, though (`waited_prior` and `args_written` are unused, remap.rs:338-340). Conflicts and OOM show up only through the existing `REMAP_REWRITTEN`/`NOT_DONE` line (hwrt.rs:3866-3867). `RemapStats` is still write-only outside tests. I ran `cargo test -p victory-gpu --lib hwrt` with 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 reach `write_table`/`bind` with 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 randomized `bind` sequence 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
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 12:20 UTC · original · edited 2026-12-04 15:46 UTC

Thanks @⁠Kal0s-design for re-checking c49b6c8 and identifying the lock-order / relay hazard on wait_submission plus the unwired BindOutcome fields and exact =0 diffs! Pushed a14867e addressing the lock-held wait and missing binding telemetry:

  1. Removed lock-held wait in production (RemapRun::bind_no_wait & host.rs):
    • Replaced write_table's wait_submission call with RemapRun::bind_no_wait (and removed unused host::wait_submission since hwrt.rs was its only caller; RemapRun::bind stays available for unit/benchmark harnesses).
    • Documented the production HostList detach/reset ownership invariant directly above write_table's bind call.
    • Added a debug_assert! in bind_no_wait against unexpected prior in-flight reuse; in release builds (bind_no_wait_inner), it does not wait under locks, does not overwrite live args or drop prior BlasRefs, retires the unused new table cleanly, and sets BindOutcome.prior_in_flight = true (preserving same_shared and same_sub_conflict).
  2. Wired all REMAP_DIAG[0..12] outcomes in hwrt.rs & hwrt::report():
    • Removed the #[allow(dead_code)] attributes on BindOutcome and wired REMAP_DIAG[7..12] (args_written, args_skipped, waited_prior, same_sub_conflict, prior_in_flight — which also increments NOT_DONE + rate-limited error logging — and upload_oom).
    • Printed all 13 counters in hwrt::report(). As the reviewer subsequently noted, the wait counter should stay zero in the non-blocking production path; these are cumulative counters.
  3. Updated PR description: Accurately documents all default-path (=0) differences relative to bb184d8 (same_sub_conflict keeps first submission's args/refs, unmade > 0 rebuilds without caching, upload OOM keeps cell's existing refs, tlas_step skips identical Arc replace/retire, RemapBuf retirement, timing/REMAP_DIAG counters).

Verification on a14867e

  • Portable remap.rs tests: 8/8 passed (including new bind_no_wait_inner_preserves_in_flight_args_refs_and_retires_unused_table and debug #[should_panic] bind_no_wait_panics_in_debug_on_in_flight_prior_reuse).
  • Windows MSVC cargo clippy --offline -p victory-gpu --all-targets: exited 0, 0 warnings in modified files.
  • Standard RT comparison (a14867e =0 vs =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 switching VICTORY_HW_RT_REMAP_SNAPSHOTS=1 from opt-in.

Historical revision: the tests and measurements above apply to a14867e. Later lifetime fixes were included in c49d34b, and the current replacement-stack revision is 455dfdb. The CPU benchmark exercises bind(), not live production bind_no_wait().

**@⁠tommiehansen** on GitHub · 2026-12-04 12:20 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7411298144) · edited 2026-12-04 15:46 UTC Thanks @⁠Kal0s-design for re-checking `c49b6c8` and identifying the lock-order / relay hazard on `wait_submission` plus the unwired `BindOutcome` fields and exact `=0` diffs! Pushed [`a14867e`](https://github.com/tommiehansen/VIctory-xmem/commit/a14867e) addressing the lock-held wait and missing binding telemetry: 1. **Removed lock-held wait in production (`RemapRun::bind_no_wait` & `host.rs`):** - Replaced `write_table`'s `wait_submission` call with `RemapRun::bind_no_wait` (and removed unused `host::wait_submission` since `hwrt.rs` was its only caller; `RemapRun::bind` stays available for unit/benchmark harnesses). - Documented the production `HostList` detach/reset ownership invariant directly above `write_table`'s bind call. - Added a `debug_assert!` in `bind_no_wait` against unexpected prior in-flight reuse; in release builds (`bind_no_wait_inner`), it does not wait under locks, does not overwrite live `args` or drop prior `BlasRefs`, retires the unused new table cleanly, and sets `BindOutcome.prior_in_flight = true` (preserving `same_shared` and `same_sub_conflict`). 2. **Wired all `REMAP_DIAG[0..12]` outcomes in `hwrt.rs` & `hwrt::report()`:** - Removed the `#[allow(dead_code)]` attributes on `BindOutcome` and wired `REMAP_DIAG[7..12]` (`args_written`, `args_skipped`, `waited_prior`, `same_sub_conflict`, `prior_in_flight` — which also increments `NOT_DONE` + rate-limited error logging — and `upload_oom`). - Printed all 13 counters in `hwrt::report()`. As the reviewer subsequently noted, the wait counter should stay zero in the non-blocking production path; these are cumulative counters. 3. **Updated PR description:** Accurately documents all default-path (`=0`) differences relative to `bb184d8` (`same_sub_conflict` keeps first submission's args/refs, `unmade > 0` rebuilds without caching, upload OOM keeps `cell`'s existing refs, `tlas_step` skips identical `Arc` replace/retire, `RemapBuf` retirement, timing/`REMAP_DIAG` counters). ### Verification on `a14867e` - **Portable `remap.rs` tests:** **8/8 passed** (including new `bind_no_wait_inner_preserves_in_flight_args_refs_and_retires_unused_table` and debug `#[should_panic]` `bind_no_wait_panics_in_debug_on_in_flight_prior_reuse`). - **Windows MSVC `cargo clippy --offline -p victory-gpu --all-targets`:** exited 0, 0 warnings in modified files. - **Standard RT comparison (`a14867e` `=0` vs `=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 switching `VICTORY_HW_RT_REMAP_SNAPSHOTS=1` from opt-in. **Historical revision:** the tests and measurements above apply to `a14867e`. Later lifetime fixes were included in `c49d34b`, and the current replacement-stack revision is `455dfdb`. The CPU benchmark exercises `bind()`, not live production `bind_no_wait()`.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 13:03 UTC · original · edited 2026-12-04 15:51 UTC

Pushed c49d34b to perf/rt-remap-snapshots (@⁠Kal0s-design):

  1. Submission lifetime tracking (remap.rs & hwrt.rs):
    • RemapRun::bind_impl's no-wait prior_in_flight branch now extends self.number = self.number.max(number) before returning (while bind_no_wait captures prev_number before calling bind_no_wait_inner for an accurate debug_assert! message).
    • Added RemapRun::preserve_on_oom(number) and called it on HwRtManager::write_table's upload OOM fallback so preserved args/BLAS refs track the current submission's lifetime (while a fresh unbound cell returns None unchanged).
  2. Release-mode test fix & regression coverage (remap.rs):
    • Guarded bind_no_wait_panics_in_debug_on_in_flight_prior_reuse with #[cfg(debug_assertions)].
    • Added repeated_in_flight_reuse_tracks_lifetime_until_completion (covering sub 10 -> sub 11 prior_in_flight -> sub 12 still rejected at finished = 10 -> sub 13 clean rebind at finished = 12 across all Shared/Owned combinations) and preserve_on_oom_tracks_lifetime_across_submissions.
  3. Documentation: Updated PR #452 description to distinguish production bind_no_wait() from the benchmark harness's bind(), single-owner RemapBuf (REMAP_DIAG[4]) from rt_remap_bench.rs's retired_bytes_peak, and GPU lifetime safety from stale-mapping correctness under OOM/invariant violations.
  4. Verification (c49d34b): portable remap.rs tests passed 10/10 in debug (0.07s) and 9/9 in -O release (0.02s); Windows MSVC cargo clippy --offline -p victory-gpu --all-targets exited 0 with 0 warnings in modified files.

Update — current PR head: 455dfdb integrates 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 marked left_out reporting issue was subsequently fixed in dbf61f4, which selects the active remap cache in report_line(). This diagnostic-only change has been diff-reviewed; tests and benchmarks have not been rerun on it. The follow-up c8edd2f also 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.

**@⁠tommiehansen** on GitHub · 2026-12-04 13:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7412292650) · edited 2026-12-04 15:51 UTC Pushed [`c49d34b`](https://github.com/tommiehansen/VIctory-xmem/commit/c49d34b) to `perf/rt-remap-snapshots` (@⁠Kal0s-design): 1. **Submission lifetime tracking (`remap.rs` & `hwrt.rs`):** - `RemapRun::bind_impl`'s no-wait `prior_in_flight` branch now extends `self.number = self.number.max(number)` before returning (while `bind_no_wait` captures `prev_number` before calling `bind_no_wait_inner` for an accurate `debug_assert!` message). - Added `RemapRun::preserve_on_oom(number)` and called it on `HwRtManager::write_table`'s upload OOM fallback so preserved `args`/BLAS refs track the current submission's lifetime (while a fresh unbound cell returns `None` unchanged). 2. **Release-mode test fix & regression coverage (`remap.rs`):** - Guarded `bind_no_wait_panics_in_debug_on_in_flight_prior_reuse` with `#[cfg(debug_assertions)]`. - Added `repeated_in_flight_reuse_tracks_lifetime_until_completion` (covering sub 10 -> sub 11 `prior_in_flight` -> sub 12 still rejected at `finished = 10` -> sub 13 clean rebind at `finished = 12` across all `Shared`/`Owned` combinations) and `preserve_on_oom_tracks_lifetime_across_submissions`. 3. **Documentation:** Updated PR #452 description to distinguish production `bind_no_wait()` from the benchmark harness's `bind()`, single-owner `RemapBuf` (`REMAP_DIAG[4]`) from `rt_remap_bench.rs`'s `retired_bytes_peak`, and GPU lifetime safety from stale-mapping correctness under OOM/invariant violations. 4. **Verification (`c49d34b`):** portable `remap.rs` tests passed **10/10** in debug (`0.07s`) and **9/9** in `-O` release (`0.02s`); Windows MSVC `cargo clippy --offline -p victory-gpu --all-targets` exited `0` with 0 warnings in modified files. **Update — current PR head:** [`455dfdb`](https://github.com/tommiehansen/VIctory-xmem/compare/750e9b7...455dfdb) integrates 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 marked `left_out` reporting issue was subsequently fixed in [`dbf61f4`](https://github.com/tommiehansen/VIctory-xmem/commit/dbf61f4af523e751b3cca19e0c1ca581901b55b7), which selects the active remap cache in `report_line()`. This diagnostic-only change has been diff-reviewed; tests and benchmarks have not been rerun on it. The follow-up [`c8edd2f`](https://github.com/tommiehansen/VIctory-xmem/commit/c8edd2f74d4e48133f84c4f6c6955104fe5a2411) also 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.
Author
Owner

@⁠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 bb184d8 did in the same spot. bb184d8 always wrote the new table into the args and only bumped REMAP_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 in REMAP_DIAG[11] and NOT_DONE with 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 calls wait_submission anymore.

Lifetimes look right. That branch never touches snapshot, piece or refs, and commit_table only 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 to retire (560-567, 585-592). preserve_on_oom (remap.rs:375-379) works the same way. A fresh cell still returns None. The .max() at 539 is the same as = number there, since the guard already has self.number < number.

All 13 REMAP_DIAG slots have a fetch_add and show up in the report line. Slot 9 can't move in a real run though. bind_no_wait passes None for the wait (remap.rs:462), so "waited" will always print 0. The doc comment on write_table still 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 hwrt in debug passed 91/91, both with the var unset and with =1. The hwrt::remap tests in --release passed 9/9 both ways, since the should_panic one is debug-only. Same caveat as before. None of these tests open a device, and remap_snapshots_on() is only read in write_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 new prepare_remap, with snapshots on and off. All passed. When I took out the number update in preserve_on_oom, the release run of the Owned test failed, so the release-only branch really gets exercised.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 14:26 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7414341339) 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 bb184d8 did in the same spot. bb184d8 always wrote the new table into the args and only bumped `REMAP_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 in `REMAP_DIAG[11]` and `NOT_DONE` with 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 calls `wait_submission` anymore. Lifetimes look right. That branch never touches `snapshot`, `piece` or `refs`, and `commit_table` only 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 to `retire` (560-567, 585-592). `preserve_on_oom` (remap.rs:375-379) works the same way. A fresh cell still returns `None`. The `.max()` at 539 is the same as `= number` there, since the guard already has `self.number < number`. All 13 `REMAP_DIAG` slots have a `fetch_add` and show up in the report line. Slot 9 can't move in a real run though. `bind_no_wait` passes `None` for the wait (remap.rs:462), so "waited" will always print 0. The doc comment on `write_table` still 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 hwrt` in debug passed 91/91, both with the var unset and with `=1`. The `hwrt::remap` tests in `--release` passed 9/9 both ways, since the should_panic one is debug-only. Same caveat as before. None of these tests open a device, and `remap_snapshots_on()` is only read in `write_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 new `prepare_remap`, with snapshots on and off. All passed. When I took out the number update in `preserve_on_oom`, the release run of the Owned test failed, so the release-only branch really gets exercised. AI-assisted: yes
github-bot changed title from 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) 2026-12-04 15:43:52 +00:00
github-bot force-pushed github-bot/gh-452 from c49d34b6ad to 455dfdbb76 2026-12-04 15:44:05 +00:00 Compare
Author
Owner

@⁠DrArroway on GitHub · 2026-12-04 18:37 UTC · original

48-minute real-play validation of #452 (c8edd2f) + #429 (750e9b7) merged cleanly on top of LOCKhart07/VIctory-xmem rt-7-reuse (621120b) + main (2382b4c) on RDNA 2.

Setup & build

  • GPU / System: AMD Radeon RX 6900 XT (1002:73bf) (RDNA 2, 16 GB VRAM), Ryzen 9 7900X (12C/24T), 62 GiB RAM, CachyOS kernel 7.3.7-1-cachyos, GE-Proton11-15-x86_64, repo-patched Mesa (deps/mesa-inst) + vkd3d-proton.
  • Build: rt-7-reuse (621120b) + #452 (c8edd2f, including #429 750e9b7) + main (2382b4c) merged cleanly with 0 conflicts (59.5 s release build, 0 warnings).
  • Settings: 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/#358 VICTORY_SKIP_BINK=1 TV mini-game crash; 0 GPU errors and 0 kernel faults).

Verbatim final lines (at 47m 49s)

2026-12-04T18:33:41.568596Z  INFO victory_gpu::hwrt: hardware RT remap table: 312441 snapshot hits, 42022 unmarked uploads (10172 MB copied across both paths), 311 upload allocations (41711 pool reuses, 0 OOMs), 2.0 MB retained (live+cached+spare+retired), 354463 arg writes (0 skipped, 0 waited, 0 same-sub conflicts, 0 in-flight violations), 15331 ms in write_table
2026-12-04T18:33:41.568570Z  INFO victory_gpu::hwrt: hardware RT title bytes written again (VICTORY_HW_RT_REUSE; since the start): headers asked for after a write 5363810 (no copy of title memory there 0, no slot 0), landed 5362965 (of a write no longer at its address 5257755, no structure's header 0), extents known 105210 (noted now 5604, waiting for a card point 0), of them held against the most their write can have 23323 and past it, not judged, 1076; landed after a later write's at their address 0. Structures the title wrote another over, dropped: 24636 (8758 MB of host structures), of them as their own header landed 0; older ones no longer standing 4426; writes over their own source (not judged) 4. CHECK (must be 0): copies asked of a source dropped here 0, updates asked of one dropped here (built in full) 0; the first instance named with no host BLAS (the losses line) is one dropped here: none named. The step: 1324 ms in all, longest 2224 us
2026-12-04T18:33:41.568583Z  INFO victory_gpu::hwrt: hardware RT losses (each a bug to fix; 0 is parity): geometries not given 0, instances naming a BLAS with no host one 0 (first 0x0; found 461875486; since the start), CPU rehydrates with no host BLAS 0, copies not followed 0, BLASes left out of the remap table 0, lifted dispatches given the empty TLAS for lack of a host one 0 (address 0: 0; first 0x0, last 0x0), copies of a source with no host structure 0; in the card's order: structure writes after a newer structure's at the same address 0, refits or copies whose source is not the one assumed 0, lifted dispatches given another TLAS than the one built last there 0; builds or copies not done (no memory, or larger than their host structure's buffer) 0, remap tables written again while an earlier run of their list may read them 0; compactions left clones for a size of 0 or past the clone 0, for no memory 0, for no size slot 0; triangles naming a vertex past the count given, made 0,0,0 on the card 0, vertices given that could not be widened to the indices naming them 0

Summary

  • #452 snapshot reuse (VICTORY_HW_RT_REMAP_SNAPSHOTS=1): 312,441 snapshot hits vs 42,022 uploads (88.1% hit rate), only 311 upload allocations (41,711 pool reuses, 0 OOMs), 2.0 MB retained, and 354,463 arg writes with 0 skipped, 0 waited, 0 same-sub conflicts, 0 in-flight violations.
  • Parity (#429 + #452 + rt-7-reuse): 0 losses across all 16 counters over 461,875,486 BLAS instances; 0 wrong drops from VICTORY_HW_RT_REUSE=1; clean visuals throughout.
  • Memory & performance:
    • Host RT memory: 618 MB at exit (1,256 MB peak).
    • Card VRAM: 13,959 / 15,457 MB at exit (14,678 MB peak — never overflowed).
    • Shared memory: 12,595 MB at exit (14,996 MB peak).
    • tools/session-fps.sh (505 samples): 25.8 median / 26.3 avg real FPS (peak 50.5 real FPS, 7.6 ms avg preparing).
**@⁠DrArroway** on GitHub · 2026-12-04 18:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7420678572) 48-minute real-play validation of `#452` (`c8edd2f`) + `#429` (`750e9b7`) merged cleanly on top of `LOCKhart07/VIctory-xmem` `rt-7-reuse` (`621120b`) + `main` (`2382b4c`) on RDNA 2. ### Setup & build - **GPU / System:** `AMD Radeon RX 6900 XT (1002:73bf)` (RDNA 2, 16 GB VRAM), Ryzen 9 7900X (12C/24T), 62 GiB RAM, CachyOS kernel `7.3.7-1-cachyos`, `GE-Proton11-15-x86_64`, repo-patched Mesa (`deps/mesa-inst`) + vkd3d-proton. - **Build:** `rt-7-reuse` (`621120b`) + `#452` (`c8edd2f`, including `#429` `750e9b7`) + `main` (`2382b4c`) merged cleanly with 0 conflicts (`59.5 s` release build, 0 warnings). - **Settings:** `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`/`#358` `VICTORY_SKIP_BINK=1` TV mini-game crash; `0` GPU errors and `0` kernel faults)*. ### Verbatim final lines (at `47m 49s`) ```text 2026-12-04T18:33:41.568596Z INFO victory_gpu::hwrt: hardware RT remap table: 312441 snapshot hits, 42022 unmarked uploads (10172 MB copied across both paths), 311 upload allocations (41711 pool reuses, 0 OOMs), 2.0 MB retained (live+cached+spare+retired), 354463 arg writes (0 skipped, 0 waited, 0 same-sub conflicts, 0 in-flight violations), 15331 ms in write_table ``` ```text 2026-12-04T18:33:41.568570Z INFO victory_gpu::hwrt: hardware RT title bytes written again (VICTORY_HW_RT_REUSE; since the start): headers asked for after a write 5363810 (no copy of title memory there 0, no slot 0), landed 5362965 (of a write no longer at its address 5257755, no structure's header 0), extents known 105210 (noted now 5604, waiting for a card point 0), of them held against the most their write can have 23323 and past it, not judged, 1076; landed after a later write's at their address 0. Structures the title wrote another over, dropped: 24636 (8758 MB of host structures), of them as their own header landed 0; older ones no longer standing 4426; writes over their own source (not judged) 4. CHECK (must be 0): copies asked of a source dropped here 0, updates asked of one dropped here (built in full) 0; the first instance named with no host BLAS (the losses line) is one dropped here: none named. The step: 1324 ms in all, longest 2224 us ``` ```text 2026-12-04T18:33:41.568583Z INFO victory_gpu::hwrt: hardware RT losses (each a bug to fix; 0 is parity): geometries not given 0, instances naming a BLAS with no host one 0 (first 0x0; found 461875486; since the start), CPU rehydrates with no host BLAS 0, copies not followed 0, BLASes left out of the remap table 0, lifted dispatches given the empty TLAS for lack of a host one 0 (address 0: 0; first 0x0, last 0x0), copies of a source with no host structure 0; in the card's order: structure writes after a newer structure's at the same address 0, refits or copies whose source is not the one assumed 0, lifted dispatches given another TLAS than the one built last there 0; builds or copies not done (no memory, or larger than their host structure's buffer) 0, remap tables written again while an earlier run of their list may read them 0; compactions left clones for a size of 0 or past the clone 0, for no memory 0, for no size slot 0; triangles naming a vertex past the count given, made 0,0,0 on the card 0, vertices given that could not be widened to the indices naming them 0 ``` ### Summary - **`#452` snapshot reuse (`VICTORY_HW_RT_REMAP_SNAPSHOTS=1`):** **`312,441` snapshot hits** vs `42,022` uploads (**`88.1%` hit rate**), only `311` upload allocations (`41,711` pool reuses, `0` OOMs), **`2.0 MB` retained**, and **`354,463` arg writes** with **`0` skipped, `0` waited, `0` same-sub conflicts, `0` in-flight violations**. - **Parity (`#429` + `#452` + `rt-7-reuse`):** **`0` losses across all 16 counters** over **`461,875,486` BLAS instances**; `0` wrong drops from `VICTORY_HW_RT_REUSE=1`; clean visuals throughout. - **Memory & performance:** - Host RT memory: `618 MB` at exit (`1,256 MB` peak). - Card VRAM: `13,959 / 15,457 MB` at exit (**`14,678 MB` peak** — never overflowed). - Shared memory: **`12,595 MB` at exit** (`14,996 MB` peak). - `tools/session-fps.sh` (`505` samples): `25.8` median / `26.3` avg real FPS (peak `50.5` real FPS, `7.6 ms` avg preparing).
github-bot changed title from hwrt: reuse immutable BLAS remap snapshots on unmarked TLAS remaps (on #429 / rt-7-reuse) to perf(hwrt): reuse immutable BLAS remap snapshots 2026-12-04 22:20:02 +00:00
Author
Owner

@⁠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.

**@⁠tommiehansen** on GitHub · 2026-12-05 10:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/452#issuecomment-7436387500) Thanks for the lifetime review and RDNA2 real-play validation. The [current-head Standard CPU comparison](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47503640056/job/145622974581) 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.
The lift commit carried two changes that did not depend on its switch
(its message said so: "two fixes on the way, with the switch off too")
and raised TRANSLATOR_VERSION for them:

- v_mad_legacy's zero addend worked on the bits (and a NaN quieted),
  in place of main's comparison;
- a store through a counter view taken as its one integer channel for
  any mask naming channel 0, refused for one that does not.

Both are taken out here, with the store's test, and the version is 20
again. main's form of the first stays; the second is to be proposed on
its own. What a NaN addend gives is not carried anywhere now.

Measured, on one machine (Wine, RADV), over the 25,694 shader
containers of the title's archive, by `victory shaders` translating
again what main (0fd7614) had cached and counting what came out
different, no switch set:

  before this commit   3,980 of 25,694 different
  after                    0 of 25,694 different

("before" was taken on the top of the stack, "after" on this commit;
195 containers hold no program and translate on neither).

With VICTORY_HW_RT=1, after: `victory translate` lifts whole all 64
compute programs with traversal loops, 397 loops of 397, so the lift
does not need either change.

Not measured: the host side (none in this commit), any run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A run refuses VICTORY_HW_RT=1 on this branch, but `victory shaders` and
`translate --warm` take it and write the cache a run reads. Their
lifted programs went in under the key of the plain ones, so a later run
without the switch would have been given them, with no host structure
to bind.

The switch (and VICTORY_HW_RT_LIFT under it) now goes into the key,
only when on: caches made without it keep their keys.

Measured on one machine (Wine, RADV), the title's 25,694 containers,
on a cache holding the plain translations: `victory shaders` with
VICTORY_HW_RT=1 took 105 s (it translated them), and the one after it
with no switch took 5 s and translated none again (the plain entries
were still there, under their own keys).

Not tested by a unit test: the key reads the environment once per
process. No run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base. The cache key here stays
this branch's own.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings in the two commits added to rt-1-lift (the two translator
changes that did not depend on the switch taken out, TRANSLATOR_VERSION
20 again; the switch in the shader cache's key). Merged, not rebased,
so work based on this branch keeps its base.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/structure.rs
  • docs/SETTINGS.md
  • run.conf.default
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.
git fetch -u origin '+refs/pull/452/head:github-bot/gh-452'
git switch 'github-bot/gh-452'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-452'
git switch 'github-bot/gh-452'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-452'
git switch 'github-bot/gh-452'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-452'
git switch 'main'
git merge --squash 'github-bot/gh-452'
git switch 'main'
git merge --ff-only 'github-bot/gh-452'
git switch 'main'
git merge 'github-bot/gh-452'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.