Skip to content

frame step: give a probe 2 s for the GPU clock to come back up - #314

Closed
Xipzer wants to merge 1 commit into
seedds:mainfrom
Xipzer:fstep-grace
Closed

Xipzer wants to merge 1 commit into
seedds:mainfrom
Xipzer:fstep-grace

Conversation

@Xipzer

@Xipzer Xipzer commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

FSTEP_GRACE is 30 frames, half a second at 60 fps. The comment beside it measures how fast the controller lowers the clock ("the controller lowered the clock within 10 frames of a step to 30"). Raising it again is slower.

On an M4 iPad every probe expired before the clock arrived. The probe failed, the hold-off doubled toward its 8 s maximum, and the game settled at hold 2 with the clock low. The grace window was causing the slowness it exists to detect.

Measurements

Breath of the Wild 1.9.0 (registered profile, exact build match), iPad Pro 13" M4, iPadOS 27.0.1. Same save, same areas, same style of play. Numbers from the host's own [nvn] frame step reports.

FSTEP_GRACE frames at 60 fps step ups / downs long-frame GPU median
30 27.8 % 2953 / 2904 27.4 ms
120 90.6 % 952 / 919 19.9 ms

Nothing graphics related changed between the two runs. The GPU median falling is the evidence: the same work got faster because iOS kept the clock up.

Tradeoff

Where 60 genuinely cannot hold, a failed probe now spends 2 s with late frames instead of 0.5 s. 60 (1 s) is the obvious middle value if 120 proves too long on other hardware.

Tests

make GAME=01007EF00011E000 t_fstep && ./t_fstep passes 47 checks, 0 failed.

Two checks bounded the last probe gap with a hard-coded 600, which is 480 (max hold) + 30 (the old grace) + 90 of slack. They now read 480 + FSTEP_GRACE + 90 so they follow the constant rather than encode it. Probe gaps become 304, 425, 664, 664.

"one probe to hold 1 that holds" and the Breath of the Wild GPU clock case both still pass.

FSTEP_GRACE was 30 frames, half a second at 60 fps. The comment beside it
measures how fast the controller lowers the clock (within 10 frames of a step
to 30). Raising it again is slower, so on an M4 iPad every probe expired before
the clock arrived: the probe failed, the hold-off doubled toward its 8 s
maximum, and the game settled at hold 2 with the clock low.

Breath of the Wild 1.9.0, iPad Pro 13" M4 (iPadOS 27.0.1), same save and the
same areas, statistics from the host's own frame step reports:

  FSTEP_GRACE  frames at 60 fps  step ups / downs  long-frame GPU median
  30                     27.8 %       2953 / 2904                27.4 ms
  120                    90.6 %         952 / 919                19.9 ms

The GPU median falling with no graphics change is the point: the grace window
was causing the slowness it exists to detect.

Where 60 genuinely cannot hold, a failed probe now spends 2 s with late frames
instead of 0.5 s. 60 (1 s) is the obvious middle value if 120 is too long
elsewhere.

t_fstep: two checks bounded the last probe gap with a hard-coded 600, which is
480 (max hold) + 30 (the old grace) + 90 of slack. They now read
480 + FSTEP_GRACE + 90 so they follow the constant. 47 checks, 0 failed.
@v0lumehi

Copy link
Copy Markdown
Contributor

This looks right to me, and the GPU median dropping from 27.4 to 19.9 ms is convincing evidence that the clock is what was missing. It matches what we saw on iPhones: the governor reads idle GPU time as slack and lowers the clock, and raising it takes longer than lowering it. Two thoughts: an iPhone (thermal cap, less headroom) might behave differently, and I can measure this on an iPhone 17 Pro Max with the same build if that helps. Taken together with your fps_hold off numbers in #316 (100 % at 60), it looks like the probe is too cautious on recent hardware in general. (CI hasn't run here yet; first-time contributor workflows need the maintainer's approval.)

@Xipzer

Xipzer commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Yes please, an iPhone 17 Pro Max run would be the useful missing half: I have one here too and will post the same three numbers from it, so we would have two independent measurements on the same hardware.

The thermal cap is worth separating out. On the M4 iPad the oscillation turned out not to be heat at all: NSProcessInfo.thermalState sat at nominal for 215 of 345 windows and serious for the other 130, never fair or critical, while the frame rate swung between 60 and 30 the whole time. The governor was moving the clock inside a single thermal state. That is why the probe mattered more than cooling did.

One thing that surprised me, in case it affects how you set up the iPhone run: the iPad ran cooler and faster attached to its aluminium Magic Keyboard than suspended in open air, because the case conducts heat out of the back. If you test an iPhone in a holder with an air gap behind it, expect worse sustained clocks than in the hand.

@v0lumehi

Copy link
Copy Markdown
Contributor

Thanks a lot for all of this, and for taking the feedback on #315 and #316 so well. Splitting it into #335 and the follow-ups makes it much easier to follow, and the downsample point in #315 is a good catch.

On the iPhone 17 Pro Max run: happy to do it, but I'm tied up with the work in #313 for now and will get to it after that. Since you have the same phone, please go ahead and post your numbers first. Mine will then be the second, independent measurement. Good tip on the holder, I'll test in the hand.

On the pre-HUD scaling experiment you asked about in #315: it's on my branch for Breath of the Wild (the profile names the draw that scales the scene into the output). I'll share the details once I'm back on it.

@Xipzer

Xipzer commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

an iPhone (thermal cap, less headroom) might behave differently, and I can measure this on an iPhone 17 Pro Max with the same build if that helps

It behaves differently in a way that matters for anything gated on the thermal state, including the probe's companions. NSProcessInfo.thermalState never moves.

Breath of the Wild 1.9.0, iPhone 17 Pro Max, iOS 27, docked, 60 fps target, render scale 1.35, one continuous session. The host's own on-screen up to frame lines:

frame   frames  dropped    %    p99 ms  thermal
  300      289       1    0.3    16.67      0
 1500      300       0    0.0    16.67      0
 3000      300      11    3.7    33.34      0
 3600      300      28    9.3    33.34      0
 4200      300     138   46.0    33.34      0
 6000      300     101   33.7    33.34      0
 9000      300     101   33.7    33.34      0
11700      300     104   34.7    33.34      0

Thirty-eight consecutive windows, ten minutes of play, a third of every window dropped from frame 4200 onward, and thermal is 0 for every single one. The only thermal line in the whole 7,015-line log is the one at launch.

The Metal HUD agrees with the host and disagrees with the device. Same scene, same settings, same session:

cold    8.40 ms GPU    59.99 fps    Thermal Nominal
warm   21.83 ms GPU    43.63 fps    Thermal Nominal

2.6x the GPU time for identical work, still reporting nominal. The user could feel the heat through the glass at the top left of the phone while the HUD read nominal.

So on this hardware the governor's clock changes live entirely inside thermal state 0. On the M4 iPad we saw states 0 and 2 with nothing between, which already suggested the state is a coarse after-the-fact label; the iPhone shows it can be decoupled altogether.

Two consequences I think are worth recording somewhere in the docs:

  1. The probe's measurement is the right instrument and the thermal state is not. This PR's 2 s probe looks at the clock directly, which is why it works. Anything that reads thermalState to decide whether a slowdown is thermal will read nominal and conclude it is not.
  2. hle_nvn.c already gates two slowdown decisions on dm_thermal_now() <= 1 (fstep_cpu_slowed and the nvn_fstep_gpu_slowed call). On an iPhone that gate is always open, so those paths behave as if the device were never hot. That may be the intended behaviour, but it is worth knowing it is not actually checking anything on this device.

Happy to run any specific comparison you want on the same phone. The probe change itself held up fine here: fps_hold off plus this branch gave a clean 60 while the device was cool, and the fall afterwards is the clock, not the probe.

@v0lumehi

Copy link
Copy Markdown
Contributor

@Xipzer would you be open to help me optimize BotW and TotK? You are basically doing it already and your analyses are great. I will have a look at your measurements once I caught some sleep.

Only thing is, I am working on other things at the moment but will definitely get back to that topic after

@v0lumehi

Copy link
Copy Markdown
Contributor

I think what you are reporting here is not caused by thermals, but I'll look at it later

@Xipzer

Xipzer commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@v0lumehi yes, happy to. I have an iPad Pro 13" M4 and an iPhone 17 Pro Max with both games, plus a Mac for A/B runs, and can take whatever measurements you want on them.

On "not thermals": I agree, and #349 may be the same thing. QID-Rob traced the Mac's drop to Game Mode: once gamepolicyd labels the bundle a game and starts a full-screen gaming session, the GPU clock falls to its minimum 45-180 s later while it is 75-98% busy, and a non-game LSApplicationCategoryType avoids it. What I see on the iPad looks the same: 120 fps holds for about 35 s, then the same scene goes from 8.4 to 21.8 ms of GPU time while thermalState stays nominal. iOS has Game Mode too, so my next test is a BotW build with a non-game category on the iPad, same route, same settings. I'll post the numbers here.

@github-actions github-actions Bot added the nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) label Nov 3, 2026
@Xipzer

Xipzer commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main now renews a probe's grace while its frames keep getting cheaper, up to 180 frames (0fd9b1c, DM_FSTEP_PROBE_RAMP), which covers what this fixed grace was for.

@Xipzer Xipzer closed this Nov 10, 2026
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 16, 2026
…es on area loads, no stutters from segment joins' (seedds#314) from Wick3dPhant0m/BananaNative:kirby-android-memory into android

Reviewed-on: https://git.eden-emu.dev/moceure/BananaNative/pulls/314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants