[pr-performance][AMD] On rebar-upstream: one slot reference per view (DARNER_SLOT_REFS_ONCE, off), less table work a call, two diagnostics fixes #1

Merged
theforgotten669 merged 5 commits from duckey-dev/Darner:amd-ports into rebar-upstream 2026-12-05 18:25:50 +00:00
Contributor

What it changes

Four changes on top of your rebar-upstream (4c9f777), found while testing it on an RX 7900 XTX, plus one commit that keeps the new comments short and generic. Each change stands alone; I can split them into separate PRs if you prefer.

  1. Dynamic slots: one reference per view and recording, not per slot (DARNER_SLOT_REFS_ONCE, off by default). Every slot filled from a list's view cache took its own AddRef: ~85k a frame in a heavy scene, ~5% of the list threads' busy samples plus ~2% in the per-slot lock. With the switch the list's State holds each view's resource once per recording. Correct with DARNER_TABLE_LISTS on or off; with DARNER_RELEASE_ASIDE the holding stays until the list's reset or drop.
  2. Tables: less work a call on the list threads (no switch). AddressHash takes 8 bytes a round, the per-draw maps use AddressHash, make_listed returns at once for a whole constant record, fewer lookups in the fill loop, diagnostics counts added once per tables() call.
  3. Diagnostics: per-call timing on the translation path only with DARNER_CALL_STATS=1. Diagnostics builds read the clock on every list call and table fill with no switch (~10% of list-thread busy samples). Release builds are unchanged.
  4. Timeline: the card's times anchored to the PC's clock by a round trip. On an RX 7900 XTX the converted card stamps are a constant ~11.7 ms late, so DARNER_TIMELINE showed the card idle with work it had already run. Five round trips at first use measure the offset and shift the stamps. Diagnostics builds only.
  • The problem on main: scene-only profiles and the timeline on an RX 7900 XTX (numbers below); host::stamps::tests::a_submissions_times_are_the_pcs fails on that card without commit 4.

How it was tested

  • Tested revision: the game runs below used these commits on rebar-upstream f6d25d2. Rebased onto 4c9f777: three small conflicts in draw.rs with DARNER_TABLE_STAGING (both sides let go of their slots at the same three places; both kept). After the rebase it compiles with and without diagnostics (cargo check -p darner-gpu --all-targets); not run in the game again.

  • Machine: Ryzen 7 7800X3D, RX 7900 XTX (ReBAR on), Windows 11. Series S profile, the game's 1920x1080, standing still on a heavy save. Switches DARNER_HW_RT=1 DARNER_RELAY=2 DARNER_PORT_CBV=1 DARNER_EARLY_DEPTH=1 DARNER_REBAR_POOLS=1, diag builds.

  • Changes a default: no.

  • DARNER_SLOT_REFS_ONCE flipped in-run (DARNER_AB=10 with a no-op switch on the first bit), 2 runs of 420 s, 86 phases of 10 s, frame time fitted at equal draws:

    A (off) B (on)
    mean frame time -0.41 ms (se 0.12)
    median -0.36 ms (se 0.11)
    90th percentile -0.55 ms (se 0.27)

    On our own branch without the pool the same switch gave -1.3 ms (one 480-s run). No device loss over ~40 flips.

  • All four commits together, switch off, against rebar-upstream f6d25d2, pool on, one pair of 240-s runs (indicative only: the two runs drew different call counts a frame):

    A: f6d25d2 B: this branch
    average fps 36.7 37.7
    median frame 25.6 ms 24.9 ms
    p99 40.3 ms 39.2 ms
    mean frame time at equal draws -2.0 ms (se 0.35)
    translation per list call 4.1 us 3.2 us
    submitting thread waiting on translation (median) 6.4 ms 3.5 ms

    Commit 3 only matters in diagnostics builds, so part of this does not carry to release builds.

  • Gates run: none of the three full gates. cargo test -p darner-gpu --lib --locked --features diagnostics on each commit alone and on this branch: 1920-1925 pass. The failures are not from these commits: compose::tests::bgrx_plane_selects_a_typed_view and shader_cache::tests::the_key_a_preload_list_is_made_under_follows_the_switches fail on f6d25d2 too; host::stamps::tests::a_submissions_times_are_the_pcs fails on this card without commit 4; pipeline::make::tests::a_capped_draw_waits_once_then_drops and one watch test are timing flakes that passed on re-run or on this branch.

  • Hardware dependence: commit 4 matters on cards whose clock calibration is off (seen on an RX 7900 XTX); 1-3 likely general.

  • Coverage gaps: picture not checked by eye yet (commit 1 changes object lifetimes, not shading). Commit 4's code only runs with DARNER_TIMELINE, which was not on in these runs (checked on our own branch: "card clock: stamps shifted by -11.73 ms"). No NVIDIA or Intel runs.

AMD results for DARNER_REBAR_POOLS (rebar-upstream 923aafb as it was)

Same exe, pool off / on / on / off, 4 runs of 249 s, same machine and scene as above:

off on
average fps 34.1 / 33.5 36.4 / 36.5
median frame 27.7 / 28.6 ms 26.0 / 25.8 ms
p99 42.1 / 44.1 ms 40.7 / 40.9 ms
worst frame 106 / 97 ms 70 / 78 ms
write-watch asking a frame 4.1 ms 0.6 ms
submitting thread a frame 23.7 / 24.9 ms 19.4 / 19.3 ms
card idle a frame 6.1 / 6.5 ms 4.3 ms

At equal draws: median -1.9 ms, mean -2.2 ms, 90th percentile -3.4 ms. The pool (1277 MB, Series S profile) sits in card memory; setting it up took 8.9 s once at start. Card memory in use 17.2-18.5 GB of a 22.7 GB budget. No device loss in these runs or in 5 more with the pool on. Left over: reads through the card, ~13 round trips and 3.8-3.9 ms a frame. With the pool on, the submitting thread mostly waits on list translation, which is what commits 1-3 cut.

Checklist

  • I ran this change in the game (all four together; commit 4's code only on our own branch).
  • This PR contains one change based on main. (Four changes, based on rebar-upstream.)
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches (here and on TrustNo1/Darner).
  • Related PRs: Lucid/Darner#4 (the same commits, aimed at Lucid's main; closed for this one)
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

## What it changes Four changes on top of your rebar-upstream (4c9f777), found while testing it on an RX 7900 XTX, plus one commit that keeps the new comments short and generic. Each change stands alone; I can split them into separate PRs if you prefer. 1. **Dynamic slots: one reference per view and recording, not per slot (`DARNER_SLOT_REFS_ONCE`, off by default).** Every slot filled from a list's view cache took its own AddRef: ~85k a frame in a heavy scene, ~5% of the list threads' busy samples plus ~2% in the per-slot lock. With the switch the list's State holds each view's resource once per recording. Correct with `DARNER_TABLE_LISTS` on or off; with `DARNER_RELEASE_ASIDE` the holding stays until the list's reset or drop. 2. **Tables: less work a call on the list threads** (no switch). AddressHash takes 8 bytes a round, the per-draw maps use AddressHash, make_listed returns at once for a whole constant record, fewer lookups in the fill loop, diagnostics counts added once per tables() call. 3. **Diagnostics: per-call timing on the translation path only with `DARNER_CALL_STATS=1`.** Diagnostics builds read the clock on every list call and table fill with no switch (~10% of list-thread busy samples). Release builds are unchanged. 4. **Timeline: the card's times anchored to the PC's clock by a round trip.** On an RX 7900 XTX the converted card stamps are a constant ~11.7 ms late, so `DARNER_TIMELINE` showed the card idle with work it had already run. Five round trips at first use measure the offset and shift the stamps. Diagnostics builds only. - The problem on main: scene-only profiles and the timeline on an RX 7900 XTX (numbers below); `host::stamps::tests::a_submissions_times_are_the_pcs` fails on that card without commit 4. ## How it was tested - Tested revision: the game runs below used these commits on rebar-upstream f6d25d2. Rebased onto 4c9f777: three small conflicts in draw.rs with `DARNER_TABLE_STAGING` (both sides let go of their slots at the same three places; both kept). After the rebase it compiles with and without diagnostics (`cargo check -p darner-gpu --all-targets`); not run in the game again. - Machine: Ryzen 7 7800X3D, RX 7900 XTX (ReBAR on), Windows 11. Series S profile, the game's 1920x1080, standing still on a heavy save. Switches `DARNER_HW_RT=1 DARNER_RELAY=2 DARNER_PORT_CBV=1 DARNER_EARLY_DEPTH=1 DARNER_REBAR_POOLS=1`, diag builds. - Changes a default: no. - `DARNER_SLOT_REFS_ONCE` flipped in-run (`DARNER_AB=10` with a no-op switch on the first bit), 2 runs of 420 s, 86 phases of 10 s, frame time fitted at equal draws: | | A (off) | B (on) | |---|---|---| | mean frame time | | -0.41 ms (se 0.12) | | median | | -0.36 ms (se 0.11) | | 90th percentile | | -0.55 ms (se 0.27) | On our own branch without the pool the same switch gave -1.3 ms (one 480-s run). No device loss over ~40 flips. - All four commits together, switch off, against rebar-upstream f6d25d2, pool on, one pair of 240-s runs (indicative only: the two runs drew different call counts a frame): | | A: f6d25d2 | B: this branch | |---|---|---| | average fps | 36.7 | 37.7 | | median frame | 25.6 ms | 24.9 ms | | p99 | 40.3 ms | 39.2 ms | | mean frame time at equal draws | | -2.0 ms (se 0.35) | | translation per list call | 4.1 us | 3.2 us | | submitting thread waiting on translation (median) | 6.4 ms | 3.5 ms | Commit 3 only matters in diagnostics builds, so part of this does not carry to release builds. - Gates run: none of the three full gates. `cargo test -p darner-gpu --lib --locked --features diagnostics` on each commit alone and on this branch: 1920-1925 pass. The failures are not from these commits: `compose::tests::bgrx_plane_selects_a_typed_view` and `shader_cache::tests::the_key_a_preload_list_is_made_under_follows_the_switches` fail on f6d25d2 too; `host::stamps::tests::a_submissions_times_are_the_pcs` fails on this card without commit 4; `pipeline::make::tests::a_capped_draw_waits_once_then_drops` and one watch test are timing flakes that passed on re-run or on this branch. - Hardware dependence: commit 4 matters on cards whose clock calibration is off (seen on an RX 7900 XTX); 1-3 likely general. - Coverage gaps: picture not checked by eye yet (commit 1 changes object lifetimes, not shading). Commit 4's code only runs with `DARNER_TIMELINE`, which was not on in these runs (checked on our own branch: "card clock: stamps shifted by -11.73 ms"). No NVIDIA or Intel runs. ## AMD results for `DARNER_REBAR_POOLS` (rebar-upstream 923aafb as it was) Same exe, pool off / on / on / off, 4 runs of 249 s, same machine and scene as above: | | off | on | |---|---|---| | average fps | 34.1 / 33.5 | 36.4 / 36.5 | | median frame | 27.7 / 28.6 ms | 26.0 / 25.8 ms | | p99 | 42.1 / 44.1 ms | 40.7 / 40.9 ms | | worst frame | 106 / 97 ms | 70 / 78 ms | | write-watch asking a frame | 4.1 ms | 0.6 ms | | submitting thread a frame | 23.7 / 24.9 ms | 19.4 / 19.3 ms | | card idle a frame | 6.1 / 6.5 ms | 4.3 ms | At equal draws: median -1.9 ms, mean -2.2 ms, 90th percentile -3.4 ms. The pool (1277 MB, Series S profile) sits in card memory; setting it up took 8.9 s once at start. Card memory in use 17.2-18.5 GB of a 22.7 GB budget. No device loss in these runs or in 5 more with the pool on. Left over: reads through the card, ~13 round trips and 3.8-3.9 ms a frame. With the pool on, the submitting thread mostly waits on list translation, which is what commits 1-3 cut. ## Checklist - [x] I ran this change in the game (all four together; commit 4's code only on our own branch). - [ ] This PR contains one change based on `main`. (Four changes, based on rebar-upstream.) - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches (here and on TrustNo1/Darner). - Related PRs: Lucid/Darner#4 (the same commits, aimed at Lucid's main; closed for this one) - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Diagnostics builds read the clock on every title list call, every descriptor
table and every descriptor made or copied in a table's fill (copystat create,
copied, listed, recorded, the tables() call, the key's hash, the fill, the
dynamic slots' search, copy_mapped's moves), with no switch. In a heavy scene
(heavy save standing still, Ryzen 7 7800X3D, scene-only profile) those reads were ~10% of the 8 list
threads' busy samples (RtlQueryPerformanceCounter 6.6%, Instant::now 3.7%),
and the list threads are what the frame waits for.

They now read the clock only with DARNER_CALL_STATS=1 (read once, then one
load a call; logged once as "per-call timing on the translation path"); what
the lines count is still counted, and their times are left out when off.
DARNER_TIMELINE still times list calls. Release and fast builds are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every dynamic slot filled from a list thread's view cache (make_listed_batched)
and every in-place constant view (constant_raw_at) took its own reference to
the view's resource, let go when the slot was given back. In a heavy scene
(heavy save standing still, Ryzen 7 7800X3D, scene-only profile) that was ~85k AddRefs a frame, ~5% of
the 8 list threads' busy samples in the AddRef alone and ~2% in the per-slot
lock: the same few resources' counts touched by eight threads at once.

With DARNER_SLOT_REFS_ONCE=1 (read through asked_for!, so DARNER_AB can turn
it), the list's draw::State holds each view's resource once per recording
(SlotRefs, deduplicated by holding id and pointer) and the slot only notes
what it shows in a word of its own, read by slots_showing, slots_stamped,
raw_in and slot_story. The holding is let go, through host::retire and its
lag, where the State gives its dynamic slots back: when its flight landed,
at the title's reset, or when the State is dropped; a list that may run
again keeps it. With DARNER_SHARED_TABLES=1 other lists read a shared
table's slots after its own list ran, so each slot keeps its reference.
Off, nothing changes but counters on the desc tables line (counted in the
thread, added once a fill).

Here with DARNER_TABLE_LISTS: constant_at, which both a table's fill and a
table made as a list make constant views with, passes the list's holding
on to constant_raw_at, so a list's constant views of title memory in place
are held once by the list either way; a table made as a list takes its
slots into the same dynamic slots, so they go back, and the holding with
them, at the same places. With DARNER_RELEASE_ASIDE the slots go back
later on a thread of their own, so the holding stays until the list's
reset or drop. The counters stay at 128 (three more fit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- AddressHash::write takes eight bytes a round (a list view's [u32; 3]
  key was thirteen rounds, a byte each).
- The per-draw maps States, HostList.twins and Deferred.textures hash
  with AddressHash, as their neighbours do, not SipHash.
- make_listed returns at once for a constant record named whole: it was
  never kept, after a hash, a probe and a view_at.
- clear_twin looks before its swap; the fill loop looks up a slot's group
  entry once, and keeps the fresh table found first.
- Diagnostics: a tables() call's counts are held on the thread and added
  once when it returns; zero adds are skipped.

Scene-only profile before: tables_inner 10% self, make_listed_batched 8%
self, copystat 2.8% of list-thread busy samples. Measured on the branch it
comes from (with DARNER_SLOT_REFS_ONCE=1 and DARNER_LIST_NULLS=1 in both,
against the commit before; heavy save standing still, 3 pairs of 249 s): translation
3.07-3.41 vs 3.52-3.57 us a call, standing 3.6-4.5 vs 4.4-5.3 ms; frame at
equal draws -0.2 ms, inside the run-to-run spread. No device loss.

Here without DARNER_LIST_NULLS: its second look at the list's view in the
fill loop, and the null-view counters in fill_end, are not on this branch,
so those parts are left out (fill_end adds as before; add() skips zeros).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On that card every converted card time came out a constant ~11.7 ms late
(bounds 11.70-11.76 ms from two windows 49 s apart, no drift), so card
spans started after the CPU had seen their fence complete and the timeline
showed the card idle with work sent that it had in fact already run. Before
the stamps are first used, five round trips on the idle main queue measure
how far a converted stamp falls from the middle of its [sent, done] window;
when it is outside by more than a round trip, every converted time is
shifted by the median. Only with DARNER_TIMELINE (diagnostics builds).

Logged in a run: "card clock: stamps shifted by -11.73 ms to the PC's clock
(calibration off on this card; round trip 0.06 ms)".
host::stamps::tests::a_submissions_times_are_the_pcs failed on that card
before (start 11.86 ms after the send) and passes now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
theforgotten669 merged commit f5348077c7 into rebar-upstream 2026-12-05 18:25:50 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
theforgotten669/Darner!1
No description provided.