perf(hwrt): avoid temporary layout allocations during refits #602

Open
github-bot wants to merge 41 commits from github-bot/gh-602 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 15:48 UTC · original
tommiehansen:perf/phase8-rt-geometry-current-20261205 → main · +25845 −90 · 35 files · 41 commits · open

Scope and stack

Depends on #429 (b07015e); review only the incremental geometry changes on top of that commit, not inherited HWRT changes. Preserve #429 → #452 ordering; compatibility with #452 must be checked before merging. Do not merge independently of the HWRT foundation and #429; preserve #452 ordering.

Compact full builds retain Vec storage; updatable layouts share Arc and compare normalized geometry keys. No geometry semantics or quality changes intended.

Current head 8941adb

Native CI 47536751725 passed correctness, all-targets and 160 ABBA/BAAB benchmark blocks. CPU layout microbenchmark, not GPU BLAS time or gameplay FPS. Median paired changes:

Geometries Refit Full compact build Mixed 0% refit Mixed 25% Mixed 75% Mixed 100%
8 -69.1% +1.9% +8.9% -24.5% -58.7% -68.8%
64 -55.0% +2.1% +14.7% -21.8% -47.0% -54.6%
256 -58.8% -5.6% +5.6% -28.8% -54.1% -59.4%

Earlier ~28% compact-build regression is no longer observed, but build-only mixed workloads still regress when creating updatable layouts; retain draft and investigate deferred sharing. All eight blocks improved in every 25–100% refit case. Physical AMD/gameplay performance and stack compatibility not yet established.

Follow-up 2a002f1

Replaced Arc-based layout storage with the original Vec allocation on all full builds. In-place refits compare normalized geometry keys directly and retain the existing layout without cloning; out-of-place refits copy the layout once. New mixed benchmark models 25% out-of-place refits. CI 47538596673: exact layout/refit tests passed; paired cost and all-targets subsequently passed (see below). Earlier table remains historical and is not evidence for the new head.

Completed native validation — 2a002f1

CI 47538596673 passed exact tests and all-targets checks. Median paired changes across eight ABBA/BAAB blocks per row (CPU layout microbenchmark, not GPU build time):

Geometries Refit Full build Mixed 0% Mixed 25% Mixed 75% Mixed 100%
1 -79.7% -2.5% — — — —
8 -67.8% -1.0% +0.8% -22.0% -45.9% -53.4%
64 -43.4% +3.2% +0.8% -18.2% -34.0% -37.6%
256 -52.0% -0.4% -1.9% -26.9% -43.8% -49.3%

All 32 isolated refit blocks and 72 mixed refit-containing blocks improved. The previous material build-only regression is not reproduced; small build-only differences remain inconclusive on eight blocks. Both #602 and #452 change hwrt.rs relative to #429; combined-stack compatibility was the remaining readiness gate; see the completed validation below.

Combined #452 stack validation — passed

Native CI 47540461759 at fcf944a (exact geometry change replay on #452 4bd7270): layout/refit tests, 12 remap tests (one ignored), 18 freed tests, live BLAS remap test, both paired benchmarks and all-targets compilation passed. Median paired CPU layout changes:

Geometries Refit Full build Mixed 0% Mixed 25% Mixed 75% Mixed 100%
1 -76.3% +2.8% — — — —
8 -71.7% +1.1% +0.9% -25.4% -53.6% -62.0%
64 -55.9% +2.9% -6.7% -27.4% -43.6% -47.6%
256 -59.7% -3.9% +0.9% -27.1% -48.6% -54.6%

All 104 refit-containing paired blocks improved. Small full-build overhead at n=1/8 is repeatable in this combined fixture but limited to +2.8%/+1.1%; no material mixed-build regression. Ready for review on CPU preparation evidence, not a GPU/actual FPS claim. Keep the prerequisite order and recheck when foundation lands. No changes to #429/#452.

**@⁠tommiehansen** on GitHub · 2026-12-05 15:48 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/602) `tommiehansen:perf/phase8-rt-geometry-current-20261205` → `main` · +25845 −90 · 35 files · 41 commits · open ## Scope and stack Depends on #429 (`b07015e`); review only the incremental geometry changes on top of that commit, not inherited HWRT changes. Preserve #429 → #452 ordering; compatibility with #452 must be checked before merging. Do not merge independently of the HWRT foundation and #429; preserve #452 ordering. Compact full builds retain Vec storage; updatable layouts share Arc<Vec> and compare normalized geometry keys. No geometry semantics or quality changes intended. ## Current head `8941adb` [Native CI 47536751725](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47536751725) passed correctness, all-targets and 160 ABBA/BAAB benchmark blocks. CPU layout microbenchmark, not GPU BLAS time or gameplay FPS. Median paired changes: | Geometries | Refit | Full compact build | Mixed 0% refit | Mixed 25% | Mixed 75% | Mixed 100% | |---:|---:|---:|---:|---:|---:|---:| | 8 | -69.1% | +1.9% | +8.9% | -24.5% | -58.7% | -68.8% | | 64 | -55.0% | +2.1% | +14.7% | -21.8% | -47.0% | -54.6% | | 256 | -58.8% | -5.6% | +5.6% | -28.8% | -54.1% | -59.4% | Earlier ~28% compact-build regression is no longer observed, but build-only mixed workloads still regress when creating updatable layouts; retain draft and investigate deferred sharing. All eight blocks improved in every 25–100% refit case. Physical AMD/gameplay performance and stack compatibility not yet established. ### Follow-up `2a002f1` Replaced Arc-based layout storage with the original Vec allocation on all full builds. In-place refits compare normalized geometry keys directly and retain the existing layout without cloning; out-of-place refits copy the layout once. New mixed benchmark models 25% out-of-place refits. [CI 47538596673](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47538596673): exact layout/refit tests passed; paired cost and all-targets subsequently passed (see below). Earlier table remains historical and is not evidence for the new head. ### Completed native validation — `2a002f1` [CI 47538596673](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47538596673) passed exact tests and all-targets checks. Median paired changes across eight ABBA/BAAB blocks per row (CPU layout microbenchmark, not GPU build time): | Geometries | Refit | Full build | Mixed 0% | Mixed 25% | Mixed 75% | Mixed 100% | |---:|---:|---:|---:|---:|---:|---:| | 1 | -79.7% | -2.5% | — | — | — | — | | 8 | -67.8% | -1.0% | +0.8% | -22.0% | -45.9% | -53.4% | | 64 | -43.4% | +3.2% | +0.8% | -18.2% | -34.0% | -37.6% | | 256 | -52.0% | -0.4% | -1.9% | -26.9% | -43.8% | -49.3% | All 32 isolated refit blocks and 72 mixed refit-containing blocks improved. The previous material build-only regression is not reproduced; small build-only differences remain inconclusive on eight blocks. Both #602 and #452 change `hwrt.rs` relative to #429; combined-stack compatibility was the remaining readiness gate; see the completed validation below. ### Combined #452 stack validation — passed [Native CI 47540461759](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47540461759) at `fcf944a` (exact geometry change replay on #452 `4bd7270`): layout/refit tests, 12 remap tests (one ignored), 18 freed tests, live BLAS remap test, both paired benchmarks and all-targets compilation passed. Median paired CPU layout changes: | Geometries | Refit | Full build | Mixed 0% | Mixed 25% | Mixed 75% | Mixed 100% | |---:|---:|---:|---:|---:|---:|---:| | 1 | -76.3% | +2.8% | — | — | — | — | | 8 | -71.7% | +1.1% | +0.9% | -25.4% | -53.6% | -62.0% | | 64 | -55.9% | +2.9% | -6.7% | -27.4% | -43.6% | -47.6% | | 256 | -59.7% | -3.9% | +0.9% | -27.1% | -48.6% | -54.6% | All 104 refit-containing paired blocks improved. Small full-build overhead at n=1/8 is repeatable in this combined fixture but limited to +2.8%/+1.1%; no material mixed-build regression. Ready for review on CPU preparation evidence, not a GPU/actual FPS claim. Keep the prerequisite order and recheck when foundation lands. No changes to #429/#452.
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]>
With VICTORY_HW_RT_LIFT=0 set where the tests run, a_node_test_outside_a_traversal_loop_keeps_the_software_walk_and_says_why failed: the reason it asserts on is replaced by "VICTORY_HW_RT_LIFT=0: no loop lifted" (reported on #342 from a Windows run). The tests' guard that sets the hardware ray-tracing switch for a scope now sets the lifting to its default too; the test of VICTORY_HW_RT_LIFT=0 sets its own inside the guard, as before.

No change outside the tests.

Tests, under Wine with VICTORY_HW_RT_LIFT=0 in the environment: before, the ray-query tests 6 passed and that one failed (rayquery_tests.rs:82); after, the ray-query, intersect and size tests 30 passed, 1 ignored (the one that needs a local shader cache).

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]>
docs/SETTINGS.md gets a section for hardware ray tracing with the three switches the translator reads: what each does, its values, and that VICTORY_HW_RT_LIFT is on by default under a master switch that is off by default (asked for in review of #262, #342 and #374).

They are not in run.conf.default yet: that file is the in-game menu, and with only the translator's side in, `victory run` refuses VICTORY_HW_RT=1. They are added there with the host side, where a run takes the switch.

Words only: no code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
clippy's unneeded_wildcard_pattern on `GeomKey::Triangles { vertex_count: _, .. }` where a refit's geometry keys are compared but for their vertex counts (reported on #342). The pattern matches the same values without it.

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]>
With the host side in, `victory run` takes VICTORY_HW_RT=1. docs/SETTINGS.md now says what the switch does in a run, what it needs (DXR 1.1, the title's builder running), what it costs (card memory, shaders prepared again) and how it is checked (the losses line; not hit for hit), and gets VICTORY_HW_RT_REFIT, which is on by default under it. run.conf.default gets VICTORY_HW_RT, VICTORY_HW_RT_REFIT, VICTORY_HW_RT_LIFT and VICTORY_HW_RT_WHY, so they show in the menu under Performance (asked for in review of #262, #342 and #374).

One comment in the translator said the run refuses the switch; it no longer does.

Words only: no code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
With VICTORY_HW_RT_LEAN_BUILDER=1 a program that is not lifted walks structures the title's builder no longer makes: a picture loss, and the one failure of the switch a tester cannot see in the numbers afterwards. It was an error line every ten seconds while it lasted and nothing else (review of #274). The dispatches are now added up since the start and stand on the lean builder's report line beside "lost", so the last line of a log says whether it ever happened.

The error line is as before. Nothing else changes; with the switch off nothing is counted.

Not run in play.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
What the switch does, that it is ignored without VICTORY_HW_RT=1, its failure (a program left on the software walk shows a wrong picture) and the two counts on its log line that say whether that happened (asked for in review of #274 and #342).

Words only: no code changes.

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). Those runs were of this change as first written, on the send-buffer change and an older main; it has not been run in play since it was moved onto current main.

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.

The two report lines about textures that first came with this change (the texture blocks by how full they are, the texture queue's slots held back) have nothing to do with ray tracing and are a change of their own against main.

Tests, under Wine on current main: pool, hwrt and builder_lean 64 passed (hwrt 47).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The switch is on by default under VICTORY_HW_RT=1, which is off by default: both files now say so, and what =0 goes back to (asked for in review of #306, #342 and #374).

Words only: no code changes.

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]>
The demote change made the pool of build memory (and of remap tables) let a spare piece go after it lay 10 s, and past the 256 MB kept let the oldest go instead of the one just given back. It did so with the switch off too, at every give and at every report (review of #323), though that part alone was not shown to gain anything in play.

Now a pool ages its spare only with VICTORY_HW_RT_DEMOTE=1. Without the switch it is as before that change: past the bound the piece just given back goes, and nothing goes for lying. The report line's counts of pieces let go then stay 0.

With the switch on nothing changes.

Tests, under Wine: hwrt 58 passed (1 new: a pool that does not age lets go only the piece given back past the bound, at a give and at a trim long after the idle time; the tests of the ageing pool say so where they make it). Not run in play.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`unsafe impl Send` and `Sync` for `Inputs` stood on two lines of comment (review of #323). The comment now says where an `Inputs` is made, how it reaches another thread, what that thread does with it and why each of those is sound: the descriptions are numbers and only read, the buffers are D3D12 objects of which only references are cloned and dropped, and a piece dropped goes back to its pool under the pool's lock. It also says why the `kept` buffers are never read (they are held so the descriptions' addresses stay valid).

Comments only: no code changes. This is the argument as read in the code; no test exercises the sharing (it needs a device and two threads of the host).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
clippy's wrong_self_convention on `fn to_list(&mut self)`: a `to_` method is expected to take `self` by reference or by value and return the converted thing, and this one changes the lease in place (reported on #342). Renamed; one caller.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
What the switch does, the one measurement there is of it (448 structures put to sleep, 1,695 MB to 455 MB, in one nine-minute drive on an RX 9070 XT: from the commit that adds the switch, kept here as asked in review of #323), that the spare build memory's ageing belongs to it, and the log line that counts its work.

Words only: no code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
One static counted, for every pool, the blocks marked to be emptied that a piece was cut from all the same; the texture report reads it. It becomes a field of the pool and the report reads the texture pool's. Only texture blocks are ever marked so far, so the number the report shows is the same.

Taken out of the next change (emptying sparse blocks of structures), which marks blocks in the structures' pools too and needs the count apart; it was noted in review of #328 that this moves with that switch off, so it stands alone here.

Tests, under Wine: pool 12 passed (none new: the count is asserted by the next change's tests).

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]>
structures_are_cut_from_blocks_by_how_long_they_live called `lived`, which reads the switch from the environment, so with VICTORY_HW_RT_PACK=1 set where the tests run it failed on the updatable ones (`Some(Updatable)` against `Some(Long)`; reported on #342 from a Windows run). It now asks `lived_when(origin, false)`, the case it was written for; the switched-on case has its own test.

No change outside the tests.

Tests, under Wine with VICTORY_HW_RT, _PACK, _DEMOTE and _LEAN_BUILDER all set to 1 in the environment: before, pool, hwrt and builder_lean 85 passed and that one failed (hwrt.rs:7929); after, 86 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The title frees no memory when it is done with a bottom-level structure: it writes the next one over its bytes. The host structure of the first stayed for good. With VICTORY_HW_RT_REUSE=1 (off by default) each BLAS write is followed in its list by a copy back of the 8-byte header the title's builder wrote, so the bytes the structure has on the console are known as of that place in the card's order. At the next submission a structure whose bytes share a byte with those of one written later goes from the ledger and the tap's map. A copy over its own source and a structure with no header read are never judged.

Measured in one 11 minute session, on the tree this was first written on (a165cd4, before the stack was split into branches): structure memory 483 to 695 MB where it grew to 2548 MB before; 35118 structures dropped; instances naming a BLAS with no host one 0 of 72 million, copies and updates asked of a dropped one 0; the step 197 ms in all, longest 5.4 ms.

Not run: this commit as it stands here, on current main.

In the same file, and carried with it: the counting-only switches VICTORY_HW_RT_NAMED and VICTORY_HW_RT_NAMED_DUMP (off by default; with them nothing is built, dropped, kept or sent otherwise).

Taken out of the first version of this commit, each to a change of its own: the card addresses of our buffers said when the host device goes, VICTORY_SHARED_LEDGER, and the page residency's counts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
What the switch does, what it does not (it returns free space; it does not stop structure memory growing), the one measurement there is of it and how that play ended, and the log line that counts its work (asked for in review of #328).

Words only: no code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
VICTORY_HW_RT_REUSE drops every structure sharing a byte with the extent a write's header gives, and the header was believed whenever it had version 6, a node count and no more than 1 GB (review of #374). The check that a size cannot be past what its structure can have existed for tests only.

Now the extent is judged only if it is no more than the most that write can have, where that is known: for a build, the bytes the title's builder said a build of that shape needs at most (the answers already kept for the built-over rule); for a copy, the bytes noted for its source (a copy does not grow one). One past it is not noted and drops nothing. For a rehydrate, and for a build whose size the title never asked or a copy whose source has no header noted, there is still only the 1 GB bound.

The report line counts both: extents that had a most to be held against, and those past it, so how much of the rule is checked and how often it refuses can be read from a run.

Also counted: a header landing after a later write's at its own address was noted. The review said the older entries collected on the way are dropped there untold; they cannot be: nothing noted shares a byte with the later write's bytes, so none is found before the address itself, and those found in any other case are returned and dropped from the ledger (or counted as no longer standing). The test now says so.

Tests, under Wine: pool, hwrt and builder_lean 116 passed with VICTORY_HW_RT_PACK and _REUSE set to 1 (the size check's test renamed, the late-header case asserted). Not run in play: whether the builder's answer is in fact never less than its header's extent is not measured, and if it is less for some shape those structures stop being dropped and the new count says how many.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
What the reuse switch does and why memory grows without it, the one measurement of mine there is (11 minutes, on the tree before the split), that it was not tried with the lean builder, and the log line whose checks must be 0. The two counting-only switches are said to be diagnostics that change nothing.

Words only: no code changes. Tests, under Wine: the menu's tests of run.conf.default 18 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
clippy's if_same_then_else on `if i == a { 2 } else if i == b { 2 }` in a test of the named-structures book: one condition now. With it this branch has main's 51 clippy warning lines again (it had 52).

Tests, under Wine: hwrt 95 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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]>
Port the isolated #429 changes onto the pinned replacement stack. Publish pending frees before overwrite reclamation and invalidate the named and reuse books over the same half-open ranges. Keep ordered ledger frees and remap generation changes, retain the new lease aging policy, and preserve the existing reuse and diagnostic paths.
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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 15:50:11 +00:00
github-bot changed title from perf(hwrt): share immutable updatable geometry layouts across refits to perf(hwrt): avoid temporary layout allocations during refits 2026-12-05 16:02:29 +00:00
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/602/head:github-bot/gh-602'
git switch 'github-bot/gh-602'

Merge

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