RGP on RADV: workaround for "failed to set new pstate (-16)", plus RX 9070 memory-placement measurements #9
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory#9
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@grykom on GitHub · 2026-11-30 15:48 UTC · original
Measured findings from a related code base (VIctory-xmem with its patched RADV, not VKtory) on an RX 9070 (GFX1201, 16 GB), Ryzen 7 7800X3D, 32 GB, Linux 7.3, Mesa/RADV 26.3.1. Posting because
gpu-time.mdand the roadmap mention a missing full-frame RGP capture and the placement design step 4.1. RGP capture blocked by
failed to set new pstate. (-16): workaroundIn our case the cause was a second Vulkan device in the same process (DXVK and vkd3d each create one): the first device takes the stable pstate, the second gets EBUSY in
radv_device_acquire_performance_counters(), andradv_sqtt_init()returns false, so that device runs without SQTT and the trigger writes nothing for it. Patch for RGP use only (src/amd/vulkan/tools/radv_sqtt.c), the stable pstate is still held by the first device:With it, full-frame captures work (1080p, 128 MiB/SE,
VICTORY_PREPARE_PIPELINES=0because SQTT changes the driver hash). Things that did not work:RADV_PROFILE_PSTATE=none(RADV cancels the capture as a hang condition), forcingprofile_peakvia sysfs (also -16). Clocks in the capture sit at the profile_peak level (~2020 MHz), so times are inflated ×~1.5. A 4K capture once ran the machine into a global OOM (SQTT plus title memory in 32 GB); 1080p was fine.2. Instruction timing on GFX12: does it work for anyone?
With
RADV_THREAD_TRACE_INSTRUCTION_TIMING=truethe file has 4 × ~80 MB SQTT data (no overflow) and a 190 MB code object database, but RGP 2.7.1.13 shows "Detailed data unavailable" / "No wavefronts analyzed" for every event, also a 1335-wave dispatch. What the capture does show in the prison cell: the most expensive 5 % of events take 38 % of the frame, and the top ones are tiny compute dispatches (4–17 groups of 32 threads, 5–7 waves) lasting 400–660 µs each, dozens of them overlapping (same shader); oneDispatchIndirect(6,1,1)keeps running ~450 µs after occupancy has dropped to ~0. Looks latency-bound, in line withxlcost.md.3. The 185 MB 32-bit heap is read by the CPU every frame
The title reserves 185 MB below 4 GiB (
protection 0x1, kind 0x42000, flags 0x7) backed by one physical pool (flags 0x280). Our census (bound ranges per draw/dispatch, an upper bound) has one 174 MB UAV range in it bound ~84 000 times per frame, far above anything else; 56 % of its 64 KiB pages are CPU-touched. Moving that pool to VRAM before its first use: 36 → 8.5 fps in the prison cell (+89 ms/frame) while our own code read only 4 MiB through the pool windows, so it is the title's CPU reading it.memory-placement.mdlists a 192 MB0x280pool as CPU-only (probably the same one): it looks like a candidate for the replica scheme, not a move.4. Main pool (6236 MB,
0x380): CPU-touched vs never touched, per physical pageAliases merged, a page counts as touched if any alias was materialized for the CPU; prison cell, 10 s window:
1988 MB never CPU-touched, 4248 MB touched. All 2064 MB of GPU-only (
0x801) views also have CPU-cached aliases. For comparison, moving the 710 MB WC pool alone to VRAM gave −4.0 ms (+14.7 %) in the cell, ABBA, one switch, at 1440p.Happy to run something specific on the 9070.
@vktory6 on GitHub · 2026-11-30 22:36 UTC · original
Thanks, this is useful, and the numbers fit what we have.
1. RGP and the pstate EBUSY. We hit the same
failed to set new pstate. (-16)on an older build that still had theD3D12 host device next to vkback (
docs/learnings/gpu-time.md, "RGP capture on the merged build failed"). That path isgone now (see "Recently done" in
docs/TASKS.md), so vkback should be the only Vulkan device in the process and stockRADV may capture again; nobody has re-checked yet. We won't ship a RADV patch, but if it is still needed I'd like to add
your workaround to
gpu-time.mdwith credit, since it is the simplest way to get a full frame. One more thing foranyone trying:
MESA_VK_TRACEalso turns off vkback's pipeline cache, so trigger well after the world shows.2. Instruction timing on GFX12. No data from us; our captures ran with
RADV_THREAD_TRACE_INSTRUCTION_TIMING=false.The pattern you describe (small compute dispatches of a few waves running 400-660 us, overlapping, latency-bound)
matches what the translation-cost ranking points at: waterfall loops on by-address loads and register spills in the
large RT programs (
docs/learnings/xlcost.md, and "GPU time: ray tracing and GI compute" / "Register spills andwaterfall loops in RT programs" in
docs/TASKS.md). If you can post the shader hashes of the top few dispatches, wecan check them against the ranking.
3. The 185 MB 32-bit heap. Agreed. Our census sees that
0x280pool only through the CPU space(
docs/learnings/memory-placement.md, view-space census), so by the placement rules it stays in GTT, and your36 -> 8.5 fps result is the cost of breaking that rule. A replica only pays if the GPU really reads a lot of it; a
bound range is an upper bound, so 84 000 binds of one 174 MB range may be one wide raw view over little actual traffic.
Can your census tell whether that range starts at the pool's base? A raw UAV view starting at a heap base is our best
lead for the rare title crash ("Title crash: upload-chunk node list" in
docs/TASKS.md).4. Main pool, touched vs untouched. 1988 MB never CPU-touched is the kind of number the planned
migrate-on-first-touch scheme needs (pages start in VRAM, move to GTT on the first CPU touch;
memory-placement.md, "Refinement", and "Memory placement: VRAM vs GTT" indocs/TASKS.md). Your -4.0 ms for the WCpool alone fits our pair (-7.7 ms for WC pool plus WC heaps together); both are in VRAM by default now.
Your measurements come from a different code base, so we'll re-measure before relying on them. If you want to run
something on the 9070, the most useful would be the same untouched/touched split or a stock-RADV RGP capture on current
VKtory main.
@vktory6 on GitHub · 2026-11-30 22:40 UTC · original
I created a task based on your report (RGP retry and your memory placement numbers):
github.com/vktory6/VKtory@c44a6a3b97@grykom on GitHub · 2026-12-01 06:36 UTC · original
Thanks for the detailed answer and for the task.
1. pstate / RGP. Sure, feel free to put the workaround in
gpu-time.md. Good to know the second device is gone on your side; then stock RADV should be enough, and the patch only matters for builds that still create two devices (DXVK + vkd3d in our case). Thanks for theMESA_VK_TRACEnote.2. Shader hashes. Will do: the capture is on the Linux machine, I'll post the top few in a follow-up. They come from our translation (VIctory-xmem,
ca97da2), so they may not match your ranking one to one.3. The 174 MB range. It does not start at the base. In title addresses the reservation is
0x400000 + 0xb900000(185 MiB) and the range is0xf00000 + 0xae00000: it starts 11 MiB (0xb00000) above the reservation base and ends exactly at its end. The pool is the same size as the reservation, so it is most likely mapped linearly, but I have not checked the pool offset itself. Of the range's 2,784 pages (64 KiB), 56.5 % were materialized for the CPU and 43.5 % never were. Agreed that ~84k binds/frame of one wide view says little about real traffic: our census counts bound ranges, not bytes read.4. An update from our side: the "untouched pages to VRAM" idea is now in VIctory-xmem
main(lobomfz/VIctory-xmem#40), as a lower-priority candidate source in its page residency (pages the card was shown and the CPU never touched), moved for real, not copied. In the same scene the copy version gave more (+9.5 % over no paging at 1.6 GB, while the real move with this source added only +1–3 % over plain residency); our unverified guess is CPU reads through the pool windows, which a copy keeps in RAM.@vktory6 on GitHub · 2026-12-01 07:35 UTC · original
Thanks! It's in
docs/learnings/gpu-time.mdnow (github.com/vktory6/VKtory@5169307): the stock settings that work with one device (confirmed on RDNA2 in #35), plus your patch for processes that still hold two devices.@grykom on GitHub · 2026-12-01 13:28 UTC · original
Follow-up with the shader hashes (from the RGP capture of 30.11: VIctory-xmem
ca97da2, 1080p, prison cell, RX 9070).How they were mapped: RGP only knows RADV pipeline hashes. I matched each code object in the capture to our log line
for the same pipeline by creation time (both on CLOCK_MONOTONIC, constant offset, ±0.1 ms; 2287 of 2667 pipelines
unambiguous), then took the title's entry name from the console container, the same way your
names.pydoes. So the8-hex suffixes below should be directly comparable with your ranking. (Side note for anyone reading RADV captures:
the "API shader hash" RGP shows is the address of the
radv_shaderobject, not a hash.)Top pipelines by summed event duration in that frame (events overlap, so this is not wall time; frame 72 ms under SQTT):
c7e5b2fac5fd36bbb589f3cdc5fd36bb(other variant)15f19d8515f19d85f1f2249c1c34db0a1c34db0a1c34db0aThe "small dispatches of a few waves running 400-660 us" from my first report match the ped skinning programs: dozens
of
Dispatch(4..17,1,1)with 32-thread groups, VGPR 96, overlapping (checked by shape for the top events; theskinning pipelines above are the ones with that VGPR count, event count and average duration). Sizes: CS_PedStandardSkinning_8 is a 15.8 KB
console container and 164 KB of RADV code; _5 is 6.4 KB -> 65 KB; PedBlendShapesSecMotionVelocity 25.3 KB -> 103 KB.
(Container size includes metadata, so this is not an instruction ratio; your
xlcostcounts would be the real one.)Instruction timing did not decode on GFX12 with RGP 2.7.1, so I can't say yet whether it's waterfall loops on
by-address loads or something else.
The single most expensive event (658 us) is a
DispatchIndirect(6,1,1)at VGPR 168 inside the title's CopyBatchregion; vkd3d labels it
[CS 77cba1163353178b], which I could not map back to a container.@vktory6 on GitHub · 2026-12-01 13:51 UTC · original
Thanks, that's a careful mapping (and good to know about RGP's "API shader hash").
The interesting part for us is the skinning programs: small dispatches running 300-360 us each at 96 VGPRs. None of them is in the top 10 of our translation-cost ranking, which is dominated by the ray-tracing and BVH programs, so either our translation handles them better or our ranking misses them. I've added the lead, with the two suffixes and the 168-VGPR
DispatchIndirectin the CopyBatch region, to the shader-cost task so it gets checked against our ranking and a profiled prison frame:github.com/vktory6/VKtory@1cd59d5@TheRifai on GitHub · 2026-12-02 10:09 UTC · original
A stock-RADV RGP capture on current main is now available (this is the step you asked for in #9).
d59b4f8, RX 9070 XT / RADV 26.3.1, GE-Proton11-16, Mesa 26.3.1, house savert3, Series X, GE-Proton11-16, warm store, ray tracing on.docs/learnings/gpu-time.md:MESA_VK_TRACE=rgp,MESA_VK_TRACE_TRIGGER=<run>/trigger.rgp(touched at 180 s, well into the world),RADV_THREAD_TRACE_INSTRUCTION_TIMING=true. No RADV patch, no second Vulkan device.RGP capture saved to '/tmp/victory.exe_2026.12.02_11.08.37_frame4043.rgp', 692 MiB, moved to/home/shlong/Documents/VKtory-capture/rgp-main/victory.exe_2026.12.02_11.08.37_frame4043.rgp(local evidence only; not attaching game-derived data). Nofailed to set new pstate (-16), no device loss; the run continued to its timeout. As documented,MESA_VK_TRACEdisables vkback's pipeline cache, so the seconds before the trigger are not representative.Logs:
/home/shlong/Documents/VKtory-capture/rgp-main/20261202-110536/. I have no RGP viewer on this machine, so I have not inspected the capture's shader timeline; if someone wants a specific frame/pipeline extracted, point me at it and I can re-arm with a different trigger point.@grykom on GitHub · 2026-12-02 11:09 UTC · original
@TheRifai
Thanks, that's a useful capture. It also confirms the pstate -16 error is gone on stock RADV now that the second device is gone.
You don't need a Windows machine to read it: RGP (Radeon GPU Profiler, part of the Radeon Developer Tool Suite) has a Linux build and opens RADV captures. That's what we used on our RX 9070. If you want to have a look, these are the parts that would be most useful to compare with our capture from earlier in this thread:
One caveat when you get to hashes: the "API shader hash" RGP shows for RADV is the address of the radv_shader object, not a hash, so it changes from run to run. We mapped RGP code objects to pipelines by creation time against our log (both use CLOCK_MONOTONIC; constant offset, ±0.1 ms). On VKtory a pipeline-creation log line with a timestamp would work the same way.
Even only point 1 (a screenshot or a small table) would help @vktory6 compare it with the xlcost ranking. No need to attach the capture itself.
@TheRifai on GitHub · 2026-12-02 13:04 UTC · original
@grykom I installed the Linux RGP 2.7.1 build (
RadeonDeveloperToolSuite-2026-10-02-1872) and opened the stock-RADV capture from this thread. No Windows needed — your note was right. This is frame 4042 of the RT-on house capture on maind59b4f8, a 25 ms window; the two tables below are from RGP'sOverview → PipelinesandMost expensive events(selection ~74% of the frame, 100% graphics events).Point 1 — top pipelines by total duration (API shader hash is the RADV
radv_shaderaddress, not a stable hash, as you warned):0x71F33A75FC78D5560x3B24E8E741A4B7010x4700CA31795A4F660xCACEA2947ACE2600xFAEE090F70F08AD030x21F04A51C2969C10x84F51C704D8D52F10x052719D4E4B497AC0x93FF9F721E7DB376So compute is at the top here, not mesh/depth draws: a 256-VGPR CS dispatch at 1.59 ms and several 96-VGPR CS dispatches at 0.98-1.70 ms. Your skinning computes were VGPR 96 at ~300-360 µs, so the 96-VGPR group is the one to name by timestamp before calling it skinning or BVH — I have not done that mapping yet. The graphics group is a long tail of ~762-768 µs
vkCmdDrawIndirect(720, 1)events, some with much shorter work durations (e.g. 858.821 µs duration / 290.526 µs work).Point 3: no
DispatchIndirect(6, 1, 1)in the top 15 most expensive events. The top indirect isvkCmdDispatchIndirect(7486, 1, 1)at 1,704.794 µs, followed byvkCmdDispatch(320, 180, 1)at 1,586.702 µs andvkCmdDispatchIndirect(108944, 1, 1)at 978.945 µs. So the CopyBatch case was not the most expensive event in this RT-on frame, unlike your RT-off cell capture.Point 2: RGP 2.7.1's Instruction timing tab did not decode the selected CS on this GFX12 capture either, so I have no waterfall-vs-memory-latency answer from it.
Screenshots (no capture attached, as requested):
/home/shlong/Documents/VKtory-capture/rgp-analysis/{most-expensive-events,most-events-table,pipelines,pipelines-table}.png.@vktory6 on GitHub · 2026-12-02 16:14 UTC · original
Closing this one: everything in it is either done or tracked.
Thanks to everyone who posted numbers here. A full-frame RGP pass list of the city view is now in "House scene: 30 fps" (from #222).