mesa: gate lazy L2 writeback on rb_noncoherent_dirty, not the adapter probe #6

Open
github-bot wants to merge 1 commit from github-bot/gh-6 into main AGit
Owner

@⁠thedee8086 on GitHub · 2026-12-01 03:17 UTC · original
thedee8086:pr/lazy-l2-gate → main · +1 −1 · 1 files · 1 commits · open

Problem

can_skip_buffer_l2_flushes() keys off tcc_rb_non_coherent, which is only true when the TCC count is non-power-of-two and RBs differ from TCCs. On Navi 10/21/31 (gfx103x, gfx1100) it is false, so the lazy L2 writeback path never engages on those cards: every buffer<->CPU transition pays a full INV_L2, doubled across chiplets on XTX-class parts.

This likely also explains why the upstream flicker repro does not reproduce on RDNA3 test boxes.

Fix

The command buffer already tracks the same condition dynamically as state.rb_noncoherent_dirty. Gate on that instead — one line in patches/mesa.patch.

Testing

RX 7900 XTX, RDNA3, the tested title, unified-memory path: lazy path now engages (verified via RADV_DEBUG traces); no visual regressions over a multi-hour session; frame pacing improved. Happy to rebase or re-measure on other gfx levels.

**@⁠thedee8086** on GitHub · 2026-12-01 03:17 UTC · [original](https://github.com/Skrills68/Valhalla-xmem/pull/6) `thedee8086:pr/lazy-l2-gate` → `main` · +1 −1 · 1 files · 1 commits · open ## Problem `can_skip_buffer_l2_flushes()` keys off `tcc_rb_non_coherent`, which is only true when the TCC count is non-power-of-two and RBs differ from TCCs. On Navi 10/21/31 (gfx103x, gfx1100) it is **false**, so the lazy L2 writeback path never engages on those cards: every buffer<->CPU transition pays a full `INV_L2`, doubled across chiplets on XTX-class parts. This likely also explains why the upstream flicker repro does not reproduce on RDNA3 test boxes. ## Fix The command buffer already tracks the same condition dynamically as `state.rb_noncoherent_dirty`. Gate on that instead — one line in `patches/mesa.patch`. ## Testing RX 7900 XTX, RDNA3, the tested title, unified-memory path: lazy path now engages (verified via RADV_DEBUG traces); no visual regressions over a multi-hour session; frame pacing improved. Happy to rebase or re-measure on other gfx levels.
can_skip_buffer_l2_flushes() keys off tcc_rb_non_coherent, which is only
true when the TCC count is non-power-of-two and RBs differ from TCCs.
On Navi 10/21/31 (gfx103x, gfx1100) it is false, so the lazy path never
engages on those cards and every buffer<->CPU transition pays a full
INV_L2, doubled across chiplets. The command buffer already tracks the
same condition dynamically as state.rb_noncoherent_dirty; gate on that
instead so the optimisation covers the common RDNA3 case.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 12:38:04 +00:00
Author
Owner

@⁠thedee8086 on GitHub · 2026-12-01 03:29 UTC · original

Field data from the tested title, RX 7900 XTX (gfx1100), 1440p FSR 4 Quality + frame generation, unified-memory path:

  • On the unpatched mesa, the lazy L2 writeback path never engages on this hardware (gate probe false), as described above.
  • On the patched mesa (this gate), the lazy path engages — verified via RADV_DEBUG command traces; no visual regressions in smoke runs.
  • Session telemetry with the patch set: GPU busy 98-100% in-world, frame generation generating for 300/300 presents with 0-4 resets per 300, page residency climbing steadily (3.3 -> 3.8 GB of paged title memory promoted to the card within minutes), VRAM filling to 16-19 GiB without pressure symptoms.

A/B frame-pacing numbers (same binary, gate on vs off, scripted route with median/p90/>38ms bands) to follow in a second comment; the on/off pair is already wired here.

**@⁠thedee8086** on GitHub · 2026-12-01 03:29 UTC · [original](https://github.com/Skrills68/Valhalla-xmem/pull/6#issuecomment-7299756515) Field data from the tested title, RX 7900 XTX (gfx1100), 1440p FSR 4 Quality + frame generation, unified-memory path: - On the **unpatched** mesa, the lazy L2 writeback path never engages on this hardware (gate probe false), as described above. - On the **patched** mesa (this gate), the lazy path engages — verified via RADV_DEBUG command traces; no visual regressions in smoke runs. - Session telemetry with the patch set: GPU busy 98-100% in-world, frame generation generating for 300/300 presents with 0-4 resets per 300, page residency climbing steadily (3.3 -> 3.8 GB of paged title memory promoted to the card within minutes), VRAM filling to 16-19 GiB without pressure symptoms. A/B frame-pacing numbers (same binary, gate on vs off, scripted route with median/p90/>38ms bands) to follow in a second comment; the on/off pair is already wired here.
Author
Owner

@⁠thedee8086 on GitHub · 2026-12-01 06:43 UTC · original

Second comment as promised: A/B frame-pacing numbers, gate on vs off — same binary, same machine (RX 7900 XTX), same scripted route from an identical save snapshot (restored before every run), 1440p FSR 4 Quality + frame generation, ~5 min in-world per run, 5 s frame-pacing windows from the runtime's own timer log, first 180 s of each run discarded (boot/load/spawn).

Heads-up on methodology: the title's frame limiter pins in-world pacing at 60 presented / 30 base frames, so medians are identical by construction. The signal lives in the tails:

build (gate state) windows median p90 p99 worst >=38 ms share pacing alternations
lazy-L2 gate OFF 68 33.89 ms 36.94 43.40 114.0 10.2 % 0
lazy-L2 gate ON 68 34.00 ms 37.09 44.11 109.2 9.5 % 0

Honest read: in limiter-capped free roam the gate is within noise on every metric — as expected when the GPU has headroom at the cap. The gate should matter where buffer<->CPU transitions are dense and the GPU is the bottleneck; this title's limiter hides that.

Two side observations from the same harness (same route, several runs each):

  • Builds carrying this patch set showed 0 pacing alternations across ~204 in-world windows; the unpatched upstream build showed 66-75 in the same route. Reproducible; cause not isolated (patch set vs. upstream delta — not separated yet).
  • Worst single window: 107-114 ms on the patched builds vs 246 ms unpatched. Single events, likely texture streaming; not attributed to the gate specifically.

Happy to re-run against a limiter-off or GPU-bound scene if that would make the numbers more useful here.

**@⁠thedee8086** on GitHub · 2026-12-01 06:43 UTC · [original](https://github.com/Skrills68/Valhalla-xmem/pull/6#issuecomment-7303206818) Second comment as promised: A/B frame-pacing numbers, gate on vs off — same binary, same machine (RX 7900 XTX), same scripted route from an identical save snapshot (restored before every run), 1440p FSR 4 Quality + frame generation, ~5 min in-world per run, 5 s frame-pacing windows from the runtime's own timer log, first 180 s of each run discarded (boot/load/spawn). Heads-up on methodology: the title's frame limiter pins in-world pacing at 60 presented / 30 base frames, so **medians are identical by construction**. The signal lives in the tails: | build (gate state) | windows | median | p90 | p99 | worst | >=38 ms share | pacing alternations | |---|---|---|---|---|---|---|---| | lazy-L2 gate OFF | 68 | 33.89 ms | 36.94 | 43.40 | 114.0 | 10.2 % | 0 | | lazy-L2 gate ON | 68 | 34.00 ms | 37.09 | 44.11 | 109.2 | 9.5 % | 0 | Honest read: in limiter-capped free roam the gate is **within noise** on every metric — as expected when the GPU has headroom at the cap. The gate should matter where buffer<->CPU transitions are dense and the GPU is the bottleneck; this title's limiter hides that. Two side observations from the same harness (same route, several runs each): - Builds carrying this patch set showed **0** pacing alternations across ~204 in-world windows; the unpatched upstream build showed 66-75 in the same route. Reproducible; cause not isolated (patch set vs. upstream delta — not separated yet). - Worst single window: 107-114 ms on the patched builds vs 246 ms unpatched. Single events, likely texture streaming; not attributed to the gate specifically. Happy to re-run against a limiter-off or GPU-bound scene if that would make the numbers more useful here.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/6/head:github-bot/gh-6'
git switch 'github-bot/gh-6'

Merge

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