perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK, on by default on the Deck) #1053
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1053
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:gpu-peak-power-state"
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?
Type: perf · Risk: low · Tested on: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH), ours and dukenheimer's; Steam Deck LCD (omgitsgela); RX 580 with
RX_VK_GPU_CLOCK=peak(Linux, RADV, HumanBean); Linux x86-64 game-free checks; the renderer built for Windows (llvm-mingw) · Needs: none (follow-ups on a Deck by hand, not gates: battery and a long session)Why
On the Steam Deck the GPU's automatic clocks do not keep up with the game. The frame waits on reads of GPU results, the GPU looks idle for a moment, and its clock drops: in Kokiri Forest it spends about 30% of the time at 1040 MHz, about 27% at 200 MHz and the rest in between. Held at 1300 MHz, the same frame takes 32 ms of GPU time instead of 58, and Kokiri Forest at handheld settings goes from 11.1 to 16.2 fps on a Deck OLED, with no frame over 100 ms where there were 130 to 170 in 45 s. The kernel lets any program ask for this clock for itself, with no root and no system setting written, and gives it back when the program ends. See #716, which asks for a way for the game to raise the Deck's GPU clock.
The idea, the code and the first measurements are sheep's. They built it in their fork, https://git.magicbean.dev/sheep/BunnyHood (GPL-3.0), commit
sheep/BunnyHood@16db7519a8, and measured it on a Deck LCD (their numbers are below, labelled as theirs). Their commit is here as they wrote it (cherry-pick -x, their authorship kept), with a[port: ...]line for the fork's names mapped to Longshot's. The one code change of ours makes it opt-in. sheep is welcome to take this PR over, send commits to it, or leave it with us.On by default on the Steam Deck (
RX_VK_GPU_CLOCK=0turns it off). This is a power decision on a handheld. In Kokiri Forest the APU is already at its 15 W limit, so the gain costs no more power there. In Hyrule Field it is not, and the same clock costs 4 W more. It was first ported opt-in; HumanBean made it the Deck's default at review (e91acea6; the decision: #1053 (comment)), with the battery and long-session runs as a follow-up. Off the Deck it stays asked for by name.The tracker was searched (
RX_VK_GPU_CLOCK, "GPU clock", "peak power", "stable pstate", "power state", "pin the GPU",priv-write): #716 (the issue; omgitsgela proposes there a different way, SteamOS'ssteamos-priv-writehelper writing the level, and offers to build it) and #968 (the Deck playbook, merged, which documents setting the clock by hand) came up. No other pull request does this.What changed
On a Steam Deck whose GPU power level is
auto(by default, orRX_VK_GPU_CLOCK=1), the renderer asks the kernel's amdgpu driver, through an amdgpu context of its own on the GPU's render node, to hold the GPU at its peak stable power state (1300 MHz on the Deck) while the game runs. The kernel gives the level back when the game's file on the render node closes, which happens when the game exits, crashes or is killed. Off the Deck, unset, nothing is opened, read or asked: everything is as on main.RX_VK_GPU_CLOCK=0is main on the Deck too.gpu/vk/vk_gpu_clock.cppgpu_clock_device_created, called once fromcreate_deviceingpu/vk/vk_main.cppafter the device is made. It finds the device's render node fromVK_EXT_physical_device_drm, reads/sys/dev/char/<major>:<minor>/device/power_dpm_force_performance_level, opens/dev/dri/renderD<minor>(checking it is that device), makes an amdgpu context (DRM_IOCTL_AMDGPU_CTX,AMDGPU_CTX_OP_ALLOC_CTX) and sets its stable power state (AMDGPU_CTX_OP_SET_STABLE_PSTATE). The file stays open until the process ends; nothing is submitted on the context. The ioctl is written out, so the build needs neither libdrm nor the kernel's headers (a build on Ubuntu 22.04's headers, the release sysroot's, has the whole feature); the test compares it with<drm/amdgpu_drm.h>where the system has it. One log line says what it did. Linux only: on Windows the function is empty.gpu/vk/gpu_clock.hchoose, no Vulkan and no system calls. The peak only on the Deck's APU (Custom GPU 0405 or 0932, or Steam'sSteamDeck=1) and only while the level isauto, so a level someone chose (manual,high, a profile) stays theirs.RX_VK_GPU_CLOCK=peakorstandardasks for that state on any AMD GPU, whatever its level, for measuring elsewhere.e91acea6): unset is the Deck's rule on the Deck's own APU (deck_apu: Custom GPU 0405 or 0932, by its name), and nothing is read elsewhere (looked_at). Another handheld with Steam'sSteamDeck=1needs=1: it was not measured.tests/test_gpu_clock.cppchecks unset on the Deck (the peak, a chosen level left alone, an unread level), on aSteamDeck=1handheld and on another AMD GPU;tests/test_gpu_clock.pychecks that the APU is known before the early return. The doc row anddocs/steam-deck-playbook.mdsay so.1f692f10, off by default beforee91acea6): unset, empty,0oroffis the driver's own clocks on every GPU, with nothing opened or read and no log line;=1is the fork's Deck rule.SteamDeck=1counts only on an integrated GPU, asauto_profile'shw.handhelddoes, since Steam sets it in Gaming Mode on desktops with a discrete card too.tests/test_gpu_clock.cpp(the rule's cases, unset and=1,SteamDeck=1on a discrete card, the ioctl's numbers against the kernel's header) andtests/test_gpu_clock.py(the call after the device is made, the level read before the choice, the file kept open once the state is held, the early return when unset). The check builds the rules twice, the second time against a copy of the system's header without the stable power states, as before Linux 5.18 (Ubuntu 22.04's linux-libc-dev 5.15, where it failed to compile: dukenheimer's report). Where the header lacks them,test_gpu_clock.cppwrites their numbers as the kernel's UAPI gives them and still checks the rest of the ioctl against it (1c25587bthe check, failing;fda1b886the fix).docs/development.md(withac385b8e: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches), and nine run files indocs/tested/(2026-11-16-gpu-clock-zeldaootr-*, a commit of ours). The fork's row indocs/tested-configurations.mdis left out: that table is frozen here.Measurements
Verdict: helps on the Steam Deck OLED and LCD, against automatic clocks. Kokiri Forest at handheld settings: 11.12 -> 16.21 fps (+45.8%), 1% low 6.77 -> 12.06, no frame over 100 ms, at the same ~15 W. Hyrule Field native: 14.98 -> 17.88 fps (+19.4%), 1% low 13.19 -> 14.75, for 4.0 W more. The power level was
autoagain after every exit and after akill -9. Two testers confirmed it since, on this PR's commits: a Deck LCD (omgitsgela: +7.7% standing, +10-20% turning, with noise) and a Deck OLED play build at native with frame generation (dukenheimer: +27%, about 4 W more). It is not the Deck's top clock: the peak state is 1300 MHz, and a clock of 1600 MHz set by hand did as well or better at about the same power (dukenheimer, below). The switch is for a player who doesn't set the clock themselves; amdgpu offers a program nothing higher without root. Off the Deck,RX_VK_GPU_CLOCK=peakon a desktop RX 580 took GPU time down 9-11% and fps up 7-12% in every phase of two interleaved rounds, with no root and the levelautoagain after every run (HumanBean); its power was not measured, sopeakbeyond the Deck stays a separate question.Baseline: both columns are one renderer pack built with
scripts/dev_packs.pyon the Deck's development base, main9c9d69ed, as Testing a change against a base describes:9c9d69edplus this PR'sgpu/diff (local tree ed4549ea, rendererlongshot_vk.sosha256d79401a56fab6f6ebb340857c297a4c9a390686c1280d8fb084b2e49ff867e62, the game binary main's). "Before" is that pack withRX_VK_GPU_CLOCKunset, which is main's path (nothing is asked or read, no log line); "After" is=1. The pack is on an older main than this PR, but the PR's code in it is the same:gpu/vk/gpu_clock.h,gpu/vk/vk_gpu_clock.cppandgpu/vk/vk_gpu_clock.hare byte-identical (the same git blobs) to this PR's head, and this PR'sgpu/diff is the pack's line for line, the four lines invk_main.cppincluded. Why the result holds on today's main: what the change does, asking the kernel for a power state once at start-up, does not depend on the renderer, and the level's behaviour (held, thenautoagain) is the kernel's. The renderer's commits since9c9d69edchange how much GPU work a frame has, so the absolute fps and the size of the gain on today's main will differ from these; the direction holds as long as the GPU's clock is what the frame waits on.Hardware: Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), SteamOS 3.9.5 (20261023.100, kernel 7.2.7-valve2), Zen 2 4C/8T, 16 GB shared; plugged in, headless, nothing else running
Scene: Kokiri Forest, the child save's spot outside Link's house (~2,200 draws a frame), handheld settings: output 1280x720, render resolution 50%, the game's own upscaler, frame generation off. Hyrule Field, native: 1280x800, render resolution 100%, the game's upscaler, frame generation off. No frame rate cap (headless); precompile off with warm caches
Method: one session on 2026-11-16, 03:30-04:04 UTC. For each scene, after a warm-up run, interleaved off, on, on, off; 75 s warm-up then 45 s standing; the median of each arm. fps and frame times from the present trace (
HOS_PRESENT_TRACE) over the 45 s sample. 1% low: 1000 divided by the mean of the slowest 1% of present intervals in that same sample (5 to 9 intervals a run). GPU time and host waits from the log'svk: GPU timeandhost time in GPU resource waitslines inside the sample. GPU clock, busy, APU power (power1_average) and temperature from sysfs at 10 Hz.power_dpm_force_performance_levelread (never written) every 2 s for the whole sessionHow to reproduce: the child Kokiri save;
RX_VK_GPU_CLOCK=1against unset, nothing else in the environment butRX_VK_PRECOMPILE=0, warm caches copied fresh into each run, nolongshot_env.txt; Hyrule Field by teleport from the same save; read/sys/class/drm/card*/device/power_dpm_force_performance_levelbefore, during and afterRX_VK_GPU_CLOCKunset: dev pack on main9c9d69ed@ ed4549eaRX_VK_GPU_CLOCK=1: dev pack on main9c9d69ed@ ed4549eaRX_VK_GPU_CLOCKunset: dev pack on main9c9d69ed@ ed4549eaRX_VK_GPU_CLOCK=1: dev pack on main9c9d69ed@ ed4549eaThe power level (
power_dpm_force_performance_level, read every 2 s, never written):autobefore the series and through every off run. In every on run,profile_peak(1300 MHz) from the first or second sample after the game started until it exited, andautoagain within one 2 s sample of the exit:profile_peakfromprofile_peakautoagainkill -930 s after the lineauto5 s and 20 s afterNo kernel line about amdgpu or drm in the journal during the killed run. No device fault,
VK_ERRORor validation line in any run; every timed run exited 0.sheep's numbers, from BunnyHood (their commit message), not from this branch: Steam Deck LCD, Kokiri Forest standing, three interleaved runs each.
The OLED gains more than the LCD did in Kokiri Forest: there the OLED's automatic clocks fell to 200 MHz over a quarter of the time, where sheep's LCD held ~1040.
Testers' runs since, on this PR's two code commits (their numbers, from their comments; not ours):
omgitsgela, Steam Deck LCD (VANGOGH, SteamOS 3.x, Mesa 26.2.0-devel), desktop mode, stock clocks, a pack of their LCD runtime's base
a4821d56plus this PR's two code commits; the Kokiri Village benchmark save, standing then a steady camera spin, off, on, on, off (#1053 (comment)):Standing, every on run is above every off run (+7.7% by the mean); turning, +16.8% by the mean but with about 3 fps of noise between runs (their reading: "idle always up ~8%, spin up ~10-20% with noise"). The log line was in every on run, the level
profile_peakthrough each andautowithin 4 s of each exit. On the LCD, too, the peak state tops out at 1300 MHz, where thehighlevel and the automatic clocks' boost reach 1600.dukenheimer, Steam Deck OLED (Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel, SteamOS 3.9.5), docked, Game Mode, a Deck play build (v3.0.0-rc.5 with this PR and nine others, the release toolchain), output 1280x800, the game's upscaler at 100%, frame generation 3x,
RX_VK_READBACK_LATE=newest; their moving Kokiri route (80 s), 2 interleaved runs each (#1053 (comment)):=1(1300 MHz)manual)* These runs went indoors for the last part of the route; the others stayed outside.
=1against automatic clocks: median 16.55 against 13.05 fps (+27%) for about 4 W more. The manual 1600 MHz did as well or better at about the same power: outside, 17.3 against=1's 15.8; with the indoor parts, 17.3 each. With #906'ssoalayout on top:=116.9 / 18.0, manual 1600 MHz 18.1 / 18.2.Ours, with #977's early reads and #906's layout in one pack (same Deck OLED, Hyrule Field native, two runs each, empty shader caches; #1053 (comment)): nothing on 15.07 fps at 8.2 W, the hold alone 17.81 at 12.3 W, the other two 20.99 at 9.4 W, all three 24.64 at 13.6 W. The hold still pays once the readback waits are gone.
HumanBean,
RX_VK_GPU_CLOCK=peakon a desktop card (#1053 (comment); their numbers): RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root; a build of this PR merged withmainc167ec67, with #384 and #906 in it, each behind its own switch;=peakagainst unset, two interleaved rounds, plus main's own build (the same as unset); Kokiri Forest, Hyrule Field, the Market and Hyrule Field again, standing then turning:=peak(2 runs)GPU time 9 to 11% lower and fps 7 to 12% higher in every phase and both rounds. The log had
vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak)and the level readautoagain after every run.=1does nothing there (not a Deck), as designed. Board power and temperature were not measured, so this says the desktop card's automatic level leaves performance unused, not what holding the peak costs.Flags and settings
One switch is added, on by default on the Steam Deck's APU only: elsewhere nothing changes unless it is set.
RX_VK_GPU_CLOCKauto, by default;=0off;=1the same rule, withSteamDeck=1handhelds too;peakorstandardthat state on any AMD GPU=1leaves such a level alone;peakon a desktop RX 580: GPU time -9 to -11%, fps +7 to +12% (HumanBean), power not measured; untested on battery, over a long session,standardanywhere, andpeakon other AMD GPUspeakbeyond the Deck after a valid run on RDNA (warm caches) showing no cap below the boost clock, and a power figureTesting
Tested:
RX_VK_GPU_CLOCKunset against=1, 2 runs each interleaved, plus one run killed withkill -9: the numbers and the power level above. The code is this PR's, in a renderer pack on main9c9d69ed(see Baseline).RX_VK_GPU_CLOCK=peakon a desktop RX 580 (Linux, RADV, no root), by HumanBean: this PR merged withmainc167ec67, two interleaved rounds against unset in four places, the log line in every=peakrun and the levelautoagain after each (Measurements; #1053 (comment)).tests/test_gpu_clock.pywithCXX=g++(13.3) andCXX=clang++(23.1.5), the ioctl's numbers checked against the system's<drm/amdgpu_drm.h>(Linux 6.8's) and against a copy of it without the stable power states, as before Linux 5.18: passes with both. At1c25587b(the check alone) the second build fails as dukenheimer saw on Ubuntu 22.04 (AMDGPU_CTX_STABLE_PSTATE_NONE,_STANDARD,_PEAKandAMDGPU_CTX_OP_SET_STABLE_PSTATEnot declared); atfda1b886it passes and says the header is from before 5.18.python3 -I -B tests/run_all.py(clang++ 23.1.5, the Vulkan and SPIR-V headers found) onac385b8e: 619 passed, 19 failed, 26 skipped. 17 fail on maine4d035e9too, run there the same way:test_bug_report_defaults,test_crt_options,test_fsr_uniform_ownership,test_guest_imported,test_import_reach,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_nonuniform_image_arrays,test_parallel_init_order,test_pending_guest_import,test_replay_write_order,test_run_all_changed,test_vk_occlusion_queriesandtest_walk_key. The other two,test_seed_readerandtest_recorder_sync(a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (withtest_gpu_clock) Before those commits, ate8e49640:python3 -I -B tests/run_all.py --changed forge/main(the 52 checks that read what changed) with each compiler, and one fullpython3 -I -B tests/run_all.py:--changed: 50 passed, 2 failed, 5 skipped with each compiler; the full run: 570 passed, 12 failed, 82 skipped. Every failure also fails on maine4d035e9(run there the same way):test_bug_report_defaults,test_crt_options,test_guest_imported,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_pending_guest_import,test_run_all_changed,test_vk_occlusion_queriesandtest_walk_keyin the full run;test_vk_occlusion_queriesandtest_walk_keyin--changed, with both compilers.RX_VK_ONLY=1 RX_TARGET=windows:longshot_vk.dll) on this head, and for Linux by the pack above.Not tested:
manual,high) being left alone: the code path was read, not run.standardon any AMD GPU, andpeakon AMD GPUs other than the Deck and the RX 580.peak: what offering it beyond the Deck would cost.gpu_clock_device_createdis empty there, and nothing else reads the switch).RX_VK_GPU_CLOCKunset (the default) against 20 minutes with=0, expecting the drain and the APU temperature to rise by about what the APU power above says (the same in Kokiri Forest at the 15 W limit, about 4 W more in Hyrule Field), no throttling below the automatic clocks, and the levelautoafter exit (by hand: the battery percentage, the APU power and temperature, the fan)manual), then the game withRX_VK_GPU_CLOCKunset, expectingthe GPU's power level was chosen (not auto): it staysin the log and the level stillmanualafter exit (by hand)Must be tested: None. By the maintainer's decision (#1053 (comment)) the battery and long-session runs and the manual level's check are follow-ups, under Not tested.
Risks
What could break: on the Steam Deck by default, elsewhere only with
RX_VK_GPU_CLOCK=1,peakorstandardset:peakorstandardasked by name over a level someone set by hand (manual,high): what the kernel gives back at exit isauto, not their level.=1never asks over a chosen level.power_dpm_force_performance_levelwhile the game runs wins: the context's hold is dropped, and nothing is changed back over their choice at exit.=1, and=1leaves that level alone.RADV_PROFILE_PSTATE) makes amdgpu refuse ours, and the log says so.Turning it off:
RX_VK_GPU_CLOCK=0.Compatibility: Nothing changes: no shader translator file (the shader caches stay valid),
MKWVK_API_VERSIONunchanged (vk_api.huntouched), no option, ini key or menu row.Issues
See #716
Checklist
Everyone
type(scope): description) of the status line's type.main: at review onto26ce01b5, commit by commit with no conflict, heade91acea6(the default on top). Before that: one4d035e9; merges with currentmain71b1edd8without a conflict (git merge-tree).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). Run atac385b8e;e91acea6was not run (a code-only review):tests/test_gpu_clock.pyis the check it changes. (python3 -I -B tests/run_all.py(clang++ 23.1.5, the Vulkan and SPIR-V headers found) onac385b8e: 619 passed, 19 failed, 26 skipped. 17 fail on maine4d035e9too, run there the same way:test_bug_report_defaults,test_crt_options,test_fsr_uniform_ownership,test_guest_imported,test_import_reach,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_nonuniform_image_arrays,test_parallel_init_order,test_pending_guest_import,test_replay_write_order,test_run_all_changed,test_vk_occlusion_queriesandtest_walk_key. The other two,test_seed_readerandtest_recorder_sync(a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (withtest_gpu_clock))third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened. (tests/test_gpu_clock.py, new, readsvk_main.cpp,gpu_clock.handvk_gpu_clock.cpp; it now also builds against a header from before Linux 5.18, which it failed to, and still checks the ioctl's other numbers there)(the switch's row, now with the 1300 MHz against 1600 set by hand)
Tested in game: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), this branch's gpu/ change as a renderer pack on an older main: Kokiri Forest at handheld settings and Hyrule Field at 1280x800, the switch unset and set, interleaved off, on, on, off, and one run killed with -9. Kokiri 11.12 to 16.21 fps at the same 15 W, the Field 14.98 to 17.88 fps for 4 W more; the GPU's power level read auto again after every exit and after the kill.
Hi @sheep! This PR brings your GPU clock hold (BunnyHood
16db7519a: the Deck's GPU at amdgpu's peak power state, asked for through the game's own render-node context, no root) to Longshot. Your commit is cherry-picked as you wrote it, your authorship kept, with only the fork's names mapped back. Thank you: #716 has been asking for this, and the context trick is a neat way to get it without a helper.It has now run on a Deck OLED, beside your LCD numbers:
autoagain after every exit and after akill -9.One change of ours: here it is opt-in (
RX_VK_GPU_CLOCK=1), andSteamDeck=1counts only on an integrated GPU. The reason is power, not doubt about the result. On a handheld it costs nothing where the APU is already at 15 W, but 4 W where it isn't, so making it the Deck's default feels like a call for you and the maintainers, in its own PR, once someone has run it on battery and over a long session.It's yours as much as ours: take the PR over, send commits to it, or leave it with us, whichever you prefer. If you'd like it on by default, or want to run those battery tests yourself, say so and we'll follow your lead.
@Beanstalk steamdeck (an LCD especially): Kokiri Forest and Hyrule Field, a few minutes each, with and without
RX_VK_GPU_CLOCK=1inlongshot_env.txt. Expecting the log linevk: GPU clock: amdgpu's peak power state held while the game runswhen set, higher fps, andpower_dpm_force_performance_levelreadingautoagain after the game exits. Unset must match main, with novk: GPU clockline.@zeldaootr only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it.This request was fore8e4964, and the PR has changed since (ac385b8), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.Measured together with early reads (#977) and the fallback record layout (#906) in one build, same Deck OLED, each arm twice in mirrored order, empty shader caches in every run:
Kokiri Forest at handheld settings: 12.97 and 9.87 fps with nothing on, 19.39 and 19.83 with all three; early reads plus the hold take the host's wait on the GPU from 52 ms a frame to under 1 ms. So the hold still pays once the readback wait is gone. The power level read
autoafter every one of the 18 runs (2,864 samples, none offautowith no game running).Steam Deck LCD run, since the PR's Needs line asks for one (my prior run was OLED): Jupiter/VANGOGH (same GPU chipset as OLED, ~1100 MT/s slower memory), SteamOS 3.x, Mesa 26.2.0-devel. Your pinned head verified against
refs/pull/1053/head(e8e4964024e9…) before building, and the pack is honest: source = our LCD runtime's own basea4821d56+ exactly your two commits (clean cherry-pick, zero conflicts), so the renderer differs from our control by the clock change and nothing else.Method: desktop mode (no gamescope treatment), stock clocks — no sysfs written by hand anywhere (that is your claim under test: the game asks, the kernel gives, the kernel takes back). Same runtime both arms, only
RX_VK_GPU_CLOCKflips. Kokiri Village benchmark save, walk-in/settle then idle×4 samples, then a steady right-stick spin×4 samples, arms interleaved off/on/on/off, first-launch pipeline prep paid warm once.RX_VK_GPU_CLOCK=1RX_VK_GPU_CLOCK=1vk: GPU clock: amdgpu's peak power state held while the game runs (… auto -> profile_peak), and a 2-second watcher (read-only) sawlevel=profile_peakfor the whole arm andlevel=autoagain within 4 s of exit — both times, no hand-reset. Nothing on desktop or Game Mode needs sudo or a group change.profile_peak's sclk table tops out at 1300 MHz (watcher:0: 1300 1: 1100 2: 1300), while the classichighforce exposes 1600 and auto does boost to 1600 under load (*2: 1600Mhz). So peak-state-hold is not "pinned to 1600"; part of the gain here is presumably never dipping to 200-1100 between/within frames rather than a higher ceiling. If a later toggle ever exposed 1600 under peak, this LCD's numbers might go up; I can re-run the same arms if you change that.amdgpu refusednever appeared), no effect seen on CPU governors (leftpowersaveboth arms).Verdict from my side: on LCD it works, is automatic in both modes, and self-releases; worth shipping for the Deck defaults discussion. Not tested: Game Mode fps deltas (same runtime in gamescope) — if useful I can run the same four arms from the couch tile.
Deck OLED:
RX_VK_GPU_CLOCK=1against stock clocks and a manual 1600 MHz, at native 1280x800Hardware: Steam Deck OLED (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel), SteamOS 3.9.5, docked, in Game Mode through Steam.
Build: a Deck play build, v3.0.0-rc.5 + #225 + #227 + #222 + #977 (off) + #1086 + #1053 + #906 + #790 + #391 + #568 (for #1086, #391 and #568 their own commits, since they sit on newer mains). Linux, the release toolchain (LLVM 23.1.5),
x86-64-v3with the play profile.Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x;
longshot_env.txtsetsRX_VK_READBACK_LATE=newest.Method: our moving Kokiri route (80 s), 2 interleaved runs per arm: unset at stock clocks;
=1; unset with the GPU pinned at 1600 MHz by hand (power levelmanual, as Steam's Manual GPU Clock Control sets it).=1* These runs went indoors for the last part of the route:
=1's first went into the shop and stood in the item pose, the manual run's second went into a house. The other runs stayed outside.=1against stock: median game fps 16.55 against 13.05 (+27%), for about 4 W more.vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=1 on the Steam Deck's APU; the power level auto -> profile_peak)appeared in every=1run, and the level readautoafter every exit.RX_VK_MESH_FB_LAYOUT=soaon top:=116.9 / 18.0, manual 1600 MHz 18.1 / 18.2.Checks:
tests/test_gpu_clock.pyfails to compiletests/test_gpu_clock.cppin an Ubuntu 22.04 container. Its<drm/amdgpu_drm.h>(linux-libc-dev 5.15) has noAMDGPU_CTX_OP_SET_STABLE_PSTATEorAMDGPU_CTX_STABLE_PSTATE_*. This happens with g++ 11.4 and clang++ 23.1.5, on this PR's heade8e49640too. The__has_includeguard finds the old header; also checking forAMDGPU_CTX_OP_SET_STABLE_PSTATEwould cover it.auto_profile no longer has: "Custom GPU 0405". #225 moves the Deck's names andgetenv("SteamDeck")intodeck_found()andhandheld_found(), whichauto_profilecalls. Reading those two functions as well makes the check pass (our local, test-only change); the build itself is unaffected.RX_VK_GPU_CLOCK's 1300 MHz is the peak state's, below a 1600 MHz clock set by handThree commits on top, no renderer change.
1c25587bmakestests/test_gpu_clock.pyalso build against anamdgpu_drm.hfrom before Linux 5.18; it fails there as dukenheimer saw on Ubuntu 22.04.fda1b886fixes the check: the stable power states' numbers are written in where the header lacks them, and the rest is still checked against it. The renderer never included that header, so it builds with the feature on the release sysroot.ac385b8eupdates the switch's docs row: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches, and no state a program may ask for without root is higher. The description now has omgitsgela's Deck LCD run (which removes the LCD from Needs) and dukenheimer's OLED run at native: +27% against automatic clocks, but a manual 1600 MHz did as well or better. The fixed check is the same with both compilers, and the full suite was run again on this head.Thanks @dukenheimer, this was very useful. All three points are in the description now.
The header check on Ubuntu 22.04. Reproduced and fixed. It was only the test: the renderer never includes
<drm/amdgpu_drm.h>.gpu/vk/vk_gpu_clock.cppwrites the ioctl out and needs only<sys/ioctl.h>and<sys/sysmacros.h>, so a build on the release sysroot (glibc 2.35, the same 5.15 headers) has the whole feature, as your play build'svk: GPU clock: ... heldline shows. Two commits on top ofe8e49640:1c25587bmakestests/test_gpu_clock.pybuild the check a second time, against a copy of the system's header with the stable power states taken out (as before Linux 5.18). It fails with your errors (AMDGPU_CTX_STABLE_PSTATE_NONE,_STANDARD,_PEAKandAMDGPU_CTX_OP_SET_STABLE_PSTATEnot declared), with g++ 13.3 and clang++ 23.1.5.fda1b886: where the header lacksAMDGPU_CTX_OP_SET_STABLE_PSTATE,test_gpu_clock.cppdefines those four with the kernel's UAPI values (6; 0, 1, 4). It still checks the rest against the old header: the alloc op,DRM_COMMAND_BASE,DRM_AMDGPU_CTX,DRM_IOCTL_BASEand the union's size. Its line says which header it had. Both builds pass with both compilers.With #225. Your local change works, but we'd rather leave it to whichever of the two lands second than make our check accept both shapes now. The check isn't there to find the names somewhere. It is there to keep
gpu_clock.h's own Deck test (steam_deck) the same rule asauto_profile's. #225 changes that rule:deck_foundadds the PCI IDs (0x163F, 0x1435) and no longer countsSteamDeck=1, which moves tohandheld_foundbecause Steam sets it on other handhelds too. A check that followed the calls into those two functions would pass whilegpu_clock.hkept the old rule. That divergence is exactly what it should catch. So:RX_VK_GPU_CLOCK=1followdeck_found(the Deck's APU, not any handheld withSteamDeck=1: we measured it only on Decks), and point the check atdeck_found.tests/test_gpu_clock.pythe way you did locally, and keepsgpu_clock.hin line with its rule.1300 against 1600 MHz. Thanks for measuring the manual pin. Measurements and Risks now say plainly that the peak state is 1300 MHz and that a manual 1600 MHz did as well or better at about the same power. The switch is for players who don't set the clock themselves.
=1leaves a manual level alone, so your owner's setup is untouched. We looked for an unprivileged way to 1600 and found none. Our reading of the kernel:AMDGPU_CTX_OP_SET_STABLE_PSTATEtakes one of five states:NONE,STANDARD,MIN_SCLK,MIN_MCLKandPEAK; anything abovePEAKis-EINVAL.amdgpu_ctx.cmaps them to the forced levelsauto,profile_standard,profile_min_sclk,profile_min_mclkandprofile_peak. There's no capability check (the render node is enough), and only one context may hold a state at a time (-EBUSYotherwise). There's no context op forhighormanual.vangogh_ppt.c, swsmu), the profile levels are fixed UMD pstate clocks, not the hardware's range:profile_peak1300 MHz andprofile_standard1100 MHz, which is what you and omgitsgela saw.profile_min_sclkis the shader clock's floor (200 MHz) andprofile_min_mclkthe memory clock's floor.highis the one that sets the shader clock to its 1600 MHz maximum. Uncertain: the clock values are from our memory of the kernel source, not read from it today. 1300 and 1100 match the runs; the twominlevels andhigh's exact behaviour weren't run.high,manualwithpp_od_clk_voltage, and the power profiles are all sysfs files that only root can write. That's what Steam's GPU clock slider uses through SteamOS's privileged helper (#716'ssteamos-priv-writeroute).RADV_PROFILE_PSTATEgoes through the same context op, so it has the same five states.So 1600 MHz is the player's call through Steam's own setting (or that helper route), not something a program can ask for. The docs row now says so too (
ac385b8e).Thanks @omgitsgela for the LCD run. It's in the description now under Measurements (idle +7.7% with every on run above every off run, the turning numbers with your noise caveat). It also settles the PR's LCD need, so that Test Farm item is gone.
On your 1300 against 1600 MHz catch: dukenheimer saw the same on an OLED, and a manual 1600 MHz did as well or better there. We looked for a way to get 1600 without root and found none. The context op takes only amdgpu's five stable states (none, standard, the lowest shader or memory clock, peak). On Van Gogh peak is a fixed 1300 MHz, as your watcher showed.
highand a manual clock are sysfs writes that need root. So no later toggle on our side can raise the peak, and there's no need to re-run. A Game Mode run of the same four arms would still be welcome if you have the time; it isn't needed for this PR.Tested
RX_VK_GPU_CLOCK=peakon a desktop AMD GPU, which the description lists as untested.Hardware: RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root.
Build: this PR merged with
mainc167ec67, together with #384 and #906, each behind its own switch.Method:
=peak(P) against unset (B), two interleaved rounds, plus main's own build (M). B and M are the same.Route: Kokiri Forest, Hyrule Field, the Market, Hyrule Field again; standing, then turning.
It works with no root. The log has
vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak), andpower_dpm_force_performance_levelreadsautoagain after every run.=peak(2 runs)GPU time is 9 to 11% lower and fps 7 to 12% higher, in every phase and both rounds. So even on a desktop card, amdgpu's
autolevel leaves performance unused in this game's load. I didn't measure board power or temperature.=1(the default when on) doesn't act here, since this isn't a Deck. The gain on a desktop Polaris card suggests offeringpeakbeyond the Deck, but that needs a power measurement first.🤖 Generated with Claude Code
Description updated, no code change (head still
ac385b8e): HumanBean's RX 580 run withRX_VK_GPU_CLOCK=peak(#1053 (comment)) is in Measurements, Testing and the flag's row. It takespeakon a desktop AMD card off Not tested (GPU time 9-11% lower, fps 7-12% higher, no root, the level back toauto); the card's power withpeakandstandardanywhere are what remain there. Needs and Must be tested are unchanged: the Deck's battery run and the manual-level check are still to do by hand.Thanks @HumanBean, this covers a line the description had as untested:
peakon a desktop card, as a normal user, with the log line and the level back toautoafter every run, and GPU time lower in every phase of both rounds. It's in the description now under Measurements and Testing, and in the flag's row.On offering
peakbeyond the Deck: agreed, it needs a power measurement first. By our reading of amdgpu, a profiling power state also turns off the GPU's power and clock gating while it's held, so a desktop card would draw more in menus and at idle too, not only in play. The board power and temperature over a session are the numbers that decide it. That would be its own PR, after this one: here=1stays the Deck's, andpeak/standardstay switches for measuring. If you can read the RX 580's board power (power1_averageunder its hwmon) in the same rounds, that would be the start of it.Suggest turning the hold on by default rather than opt-in:
=1rule, on by default. That's +45% in Kokiri and +19% in Hyrule Field on yours, and 15.07 → 24.64 fps with #977 and #906 together, for about 4 to 5 W.peakbehaviour on by default. On the RX 580 above it gave GPU time 9 to 11% lower and fps 7 to 12% higher in every phase of both rounds, with no root needed andautorestored after every run.One thing to check before the desktop default: board power and temperature on a discrete card under
peak, since I didn't measure them. KeepRX_VK_GPU_CLOCK=0as the way back.🤖 Generated with Claude Code
@Beanstalk please test this PR's
RX_VK_GPU_CLOCK=peakagainstRX_VK_GPU_CLOCKunset on AMD hardware other than a Steam Deck or GCN. We need to know whether the hold should be on by default beyond those. Priority order:/sys/class/drm/card*/device/pp_dpm_sclk, the active line) in both arms. Board power if the farm can read it (hwmonpower1_average). The question is whetherprofile_peakpins the GPU below the boost clockautoreaches, which would make it slower.=peak, kill the game withkill -9while playing, then readpower_dpm_force_performance_level. We need to know it goes back toautoand doesn't stay onprofile_peakuntil reboot.For reference, the RX 580 (GCN) runs in my comment above gave fps +7 to +12% and GPU time 9 to 11% lower. Either way, a log line like
vk: GPU clock: amdgpu's peak power state held ...confirms the hold took effect.🤖 Generated with Claude Code
Beanstalk test farm · an earlier run: commit
ac385b8(the newer results are in a comment below)Commit
ac385b8· tier reviewed · approved by HumanBean · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)Two interleaved sessions compare main with GPU clocks unset against the PR with peak requested on Linux AMD hardware, sampling FPS and GPU time in Kokiri Forest and the Market before and after camera turns. The discrete target covers RX 6000 and 7000 cards; the integrated target may wait for a suitable non-Deck tester and cannot exclude Decks automatically. Each tester’s game runs take about 30 minutes; crashes, a 10% FPS drop, or a 15% GPU-time increase fail. The farm cannot read clocks or power, ensure AC power, confirm the peak-hold log only on the PR, or perform the requested kill-and-restoration test.
peak(PR only).Done. Comment
@Beanstalkto run it again.AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99Measurements · linux+amd+dgpu+gpu-rx-6*_rx-7*
Verdict: fail on linux+amd+dgpu+gpu-rx-6*_rx-7* (1/1 report):
forest-market forest-standing.fps_mean.min_delta_pct (-24.1%)failed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAMScene: forest-market, from a new save; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)e4d035eac385b8RX_VK_GPU_CLOCK=peak (PR only)· forest-standing · frame rateRX_VK_GPU_CLOCK=peak (PR only)· forest-standing · frame time (p99) (ms)Flags and settings
RX_VK_GPU_CLOCKpeakMarkdown for the PR description
Measurements · linux+amd+igpu
Verdict: fail on linux+amd+igpu (1/1 report):
forest-market forest-standing.fps_mean.min_delta_pct (-29.3%)failed.Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99AMD Custom APU 0932, 16 GB RAMScene: forest-market, from a new save; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)e4d035eac385b8RX_VK_GPU_CLOCK=peak (PR only)· forest-standing · frame rateRX_VK_GPU_CLOCK=peak (PR only)· market-standing · frame rateRX_VK_GPU_CLOCK=peak (PR only)· forest-after-turn · frame rateRX_VK_GPU_CLOCK=peak (PR only)· forest-standing · frame time (p99) (ms)RX_VK_GPU_CLOCK=peak (PR only)· market-standing · frame time (p99) (ms)RX_VK_GPU_CLOCK=peak (PR only)· forest-after-turn · frame time (p99) (ms)Flags and settings
RX_VK_GPU_CLOCKpeakMarkdown for the PR description
Thanks @HumanBean, and for starting the farm run. Where we stand on defaults:
=1rule on by default: yes in principle, with two open points. It has not been measured on battery or over a long session, and it costs 4 to 5 W where the APU was not already at its limit, which on a handheld is battery life. And a player who sets Steam's manual GPU clock to 1600 MHz gets as much or more (@dukenheimer's run above); the hold leaves a manual level alone, so the two do not fight. We will run the battery and long-session measurement on our Deck and send the Deck default as a follow-up with those numbers.peakby default: worth it only if the farm run showsprofile_peakdoes not sit below whatautoboosts to on RDNA cards (on the Deck, peak is 1300 MHz against a 1600 MHz maximum, so on some chips it could be a cap), and with a board power figure. Your three questions to the farm are the right ones; the kill test passed on the Deck (the level wasauto1 s afterkill -9), since the kernel drops the state with the context.As with the other two, we would keep this PR as the measured opt-in and send each default as its own small PR.
We're turning the
=1rule on by default for the Steam Deck in this PR. Elsewhere it stays as it is:peakandstandardare opt-in on other AMD GPUs, and other APUs and laptops are off. I'll push it on top of a rebase, and the review follows.Why the Deck now:
kill -9included.RX_VK_GPU_CLOCK=0is the way back.The battery and long-session runs move from a gate to a follow-up. If they show something worse than about 4 W, for example throttling below automatic clocks, or much more drawn while paused because power gating is off, we revisit the default.
Why not
peakon other AMD GPUs yet: it holds the GPU at amdgpu's fixed profiling clock, and on the Deck that is below the boost clock (1300 against 1600 MHz). A GPU-bound RDNA card that boosts normally could run slower. Your RX 580 gained, but that's the only card measured. Discrete AMD can follow once one valid RDNA run shows no cap.The Test Farm run above doesn't count, either way. It measured 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck, with p99 frame times of 1 to 2.7 s. That is the game compiling shaders after a cold start, with main and the PR as separate builds each starting their own caches. Its "−24% / −29%" is not this switch. A rerun needs warm caches on both sides.
🤖 Generated with Claude Code
ac385b8e6fe91acea6a0Beanstalk test farm
Commit
e91acea· tier untrusted · approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK=1, off by default)to perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK, on by default on the Deck)I read it as code only and ran nothing. Approved, with the Deck default pushed on top, as decided in #1053 (comment).
Pushed (head
e91acea6):main26ce01b5, with no conflict. sheep's authorship is kept.e91acea6, the default:=1rule, but only on the Deck's own APU, matched by name (deck_apu: Custom GPU 0405 or 0932).SteamDeck=1still needs=1. The default would otherwise reach a ROG Ally or Legion Go under a SteamOS-like session, unmeasured, where the peak state may sit below the boost clock.looked_atkeeps the early return: off the Deck, unset, nothing is read or opened and nothing is logged.=0,offand an empty value are still the driver's own clocks, andpeakandstandardare still asked for by name.test_gpu_clock.cppchecks unset on the Deck (the peak, a chosen level left alone, a level that couldn't be read), on aSteamDeck=1handheld and on another AMD GPU.test_gpu_clock.pychecks the APU is known before the early return.`RX_VK_GPU_CLOCK=1`text the check needs) and the playbook's paragraph about #716 are updated.What I checked in sheep's code:
amdgpu_drm.h:drm_amdgpu_ctx_inis op, flags, ctx_id, priority; the union is 16 bytes.ALLOC_CTXis 1 andSET_STABLE_PSTATEis 6.PEAKis 4 andSTANDARDis 1._IOWR('d', 0x42, ...).kill -9run confirms it.power_dpm_force_performance_levelduring the game overrides the hold, as Risks says.vkCreateDevice. It is Linux only and empty on Windows.Not run:
e91acea6;tests/test_gpu_clock.pyis the one it changes.On the Test Farm run above: its 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck are cold-start shader compiling, so its "fail" is not this switch.
🤖 Generated with Claude Code
@ -0,0 +60,4 @@if (e && !strcmp(e, "standard")) return {STANDARD, "RX_VK_GPU_CLOCK=standard"};if (e && strcmp(e, "1")) return {NONE, "RX_VK_GPU_CLOCK is not 0, 1, peak or standard"};if (!(e ? f.deck : f.deck_apu)) // (unset: the Deck's own APU only; another handheld with SteamDeck=1 was not measured)return {NONE, "measured on the Steam Deck only (RX_VK_GPU_CLOCK=1 or peak asks for it here)"};Unset uses deck_apu, not deck: Steam's SteamDeck=1 alone (another handheld) needs =1, as it wasn't measured.