Repository navigation
Conversation
|
Measured in a heavier scene: Zora's Domain, from a converted Cemu save, on an M2 Max with a 144 Hz screen matched to 120 Hz. Each run lasted 120 s with no input.
With the new trigger the filler started, went off after its 60 s hold, and the clock fell to about 1,100 MHz. Frames came late again, and the filler came back on with a 120 s hold. The previous trigger needed 1 in 10 presents to be more than a quarter over the frame period. Here frames came late by less than that, so the filler never started. The new trigger (9f32f9a) counts a present as late at a tenth over the period, as the frame step does, and starts the filler when 1 in 20 presents are late. Present snapshots, which decouple the swapchain texture, did not help here. Without the filler they left the clock at 444 MHz and the frame step dropped to 30 fps. |
…he game's submissions macOS lowers the GPU clock while the GPU idles part of each frame, even when the frames then miss their deadline, and offers no interface to ask for a clock. Breath of the Wild waits for each frame's GPU work, so its GPU idles while the host translates the next frame (GitHub issue seedds#71). The filler of PR seedds#62 ran for every game all the time and shared the GPU with the game's work. Now it starts only when a tenth of 120 presents come late (mtl_gpu_fill_frame), keeps one small dispatch on a queue of its own only while none of the game's submissions is on the GPU (from the completion of the last in flight to the next commit), so it never adds to the GPU time the frame step reads, and stops after a hold without late frames that doubles at each start (60 s up to 16 min). DM_GPU_FILL=0 never, =1 from the start (also on iOS, where it is off by default). Breath of the Wild at 60 fps (M2 Max, macmon each second for 180 s): without it the clock fell to 444 MHz after 70 s and stayed (304-346 late frames every 30 s); with it 1398 MHz throughout (11-17).
…nth, as the frame step counts late frames (a quarter and one in 10 never started it in Breath of the Wild's Zora's Domain, which ran at 444 MHz with 11% of its frames late)
|
Independent validation on Apple silicon M3 Pro, and two notes that may matter for the default. Machine / title: M3 Pro 12-core, 36 GB, macOS 26A434 (Darwin 27.0.0); Breath of the Wild Method: one save snapshot restored before every arm (
The GPU-time trend is the clearest part: at constant workload the no-filler arm ends the run spending ~4× the GPU time per frame it started with, and the filler arm ~2.4× less than that end state. That is exactly the 1398 → 444 MHz story from the issue, and it also explains why 60–150 s smoke tests look perfect: the onset lands after the run ended. Note 1 — mode 2 flaps on this title. Two identical Note 2 — it fixes the clock, not everything. With the filler on, one 300 s arm still had 6 frames over 300 ms and a 1,018 ms maximum. Those frames show GPU 5–7 ms, Also measured and not worth blaming: |
|
Thanks a lot for the independent run, and for controlling the save. That's exactly what my early runs lacked. Note 1, mode 2 flaps: I see the same thing. In Zora's Domain the filler started, went off after its 60 s hold, the clock fell to about 1,100 MHz, frames came late again, and it came back on with a 120 s hold. Your two identical default runs (12 vs 49 frames over 60 ms) show that this matters more than I thought. If this PR goes in, defaulting macOS to There is also an alternative now that needs no filler at all: #87.
If you have time, an M3 Pro run of #87 with your method (same save, same route, Note 2, it fixes the clock, not everything: agreed. I'll add a limits section to the description. I found two other sources of long frames, which may also matter for your method:
Your PlacementMgr frames (CPU, no uploads, no pipelines) are a third source on top of these. |
|
Parking this PR. With #87 (present snapshots plus a frame step that judges lateness by the screen), the filler made no visible difference on my M2 Max. In Zora's Domain the GPU stays at 444 MHz and 60 fps holds: 0–1 frames late on screen per 300 with the filler on (1398 MHz) and with it off. The reasoning behind that:
So I'd rather wait for feedback than ship busy work. @HougeLangley, if you have time, a run of #87 on your M3 Pro with your method (same save and route, Kept locally in case it comes back: a version stacked on #87 whose automatic mode counts frames late on screen. It still started during BotW's load, so it would also need a check on GPU time. |
|
Thanks for the investigation and the detailed measurements. I’m closing this in favor of pursuing #87. Your latest results show no visible benefit from the filler with present snapshots enabled, and the automatic mode’s inconsistent behavior adds maintenance cost without a demonstrated remaining need. We can revisit this if testing on other hardware identifies a reproducible case that #87 cannot address. |
…ain textures can run a frame ahead of the screen Breath of the Wild has two swapchain textures and gets one back only when the display link has taken its previous present, so each frame's CPU work starts on a tick and the GPU idles from the end of one frame to the first work of the next. macOS reads that idle time as room and holds the GPU at its lowest clock (444 MHz on an M2 Max) even while frames miss the screen. With DM_PRESENT_SNAP=1 each present is copied on the game's queue, right after the frame's work, into one of two host textures (nvn_mtl.m snap_take), the display link shows the copy, and the game's texture is free at once: the game runs up to a frame ahead of the screen and a frame whose GPU work runs long is absorbed instead of shown late. The presenting thread's wait for a free ring slot paces the game; AcquireTexture then does not wait for a display link tick, and the frame step counts the slot wait as waiting, not as the frame's cost (counted as cost, it stepped Breath of the Wild down to 30 fps). Presents from another thread while Metal encoding runs on its own thread (DM_NVN_ENC_THREAD) are not copied. Off by default. Checked on the same change on the previous base (the Breath of the Wild Mac shader library here is of that chain): Zora's Domain from a Cemu save, M2 Max, 144 Hz screen at 120 Hz, about 145 s each, frames on screen longer than 1/60 s by a quarter: 64 of 8,684 with neither, 53 with snapshots alone (at 444 MHz the GPU work does not fit for stretches, which no buffer absorbs), 41 with the GPU filler of PR seedds#81 alone, 4 of 9,000 with both. On this branch the Mac host builds and t_present_crop, t_pace and t_fstep pass. docs/development.md says so
…ain textures can run a frame ahead of the screen Breath of the Wild has two swapchain textures and gets one back only when the display link has taken its previous present, so each frame's CPU work starts on a tick and the GPU idles from the end of one frame to the first work of the next. macOS reads that idle time as room and holds the GPU at its lowest clock (444 MHz on an M2 Max) even while frames miss the screen. With DM_PRESENT_SNAP=1 each present is copied on the game's queue, right after the frame's work, into one of two host textures (nvn_mtl.m snap_take), the display link shows the copy, and the game's texture is free at once: the game runs up to a frame ahead of the screen and a frame whose GPU work runs long is absorbed instead of shown late. The presenting thread's wait for a free ring slot paces the game; AcquireTexture then does not wait for a display link tick, and the frame step counts the slot wait as waiting, not as the frame's cost (counted as cost, it stepped Breath of the Wild down to 30 fps). Presents from another thread while Metal encoding runs on its own thread (DM_NVN_ENC_THREAD) are not copied. Off by default. Checked on the same change on the previous base (the Breath of the Wild Mac shader library here is of that chain): Zora's Domain from a Cemu save, M2 Max, 144 Hz screen at 120 Hz, about 145 s each, frames on screen longer than 1/60 s by a quarter: 64 of 8,684 with neither, 53 with snapshots alone (at 444 MHz the GPU work does not fit for stretches, which no buffer absorbs), 41 with the GPU filler of PR seedds#81 alone, 4 of 9,000 with both. On this branch the Mac host builds and t_present_crop, t_pace and t_fstep pass. docs/development.md says so
…ain textures can run a frame ahead of the screen Breath of the Wild has two swapchain textures and gets one back only when the display link has taken its previous present, so each frame's CPU work starts on a tick and the GPU idles from the end of one frame to the first work of the next. macOS reads that idle time as room and holds the GPU at its lowest clock (444 MHz on an M2 Max) even while frames miss the screen. With DM_PRESENT_SNAP=1 each present is copied on the game's queue, right after the frame's work, into one of two host textures (nvn_mtl.m snap_take), the display link shows the copy, and the game's texture is free at once: the game runs up to a frame ahead of the screen and a frame whose GPU work runs long is absorbed instead of shown late. The presenting thread's wait for a free ring slot paces the game; AcquireTexture then does not wait for a display link tick, and the frame step counts the slot wait as waiting, not as the frame's cost (counted as cost, it stepped Breath of the Wild down to 30 fps). Presents from another thread while Metal encoding runs on its own thread (DM_NVN_ENC_THREAD) are not copied. Off by default. Checked on the same change on the previous base (the Breath of the Wild Mac shader library here is of that chain): Zora's Domain from a Cemu save, M2 Max, 144 Hz screen at 120 Hz, about 145 s each, frames on screen longer than 1/60 s by a quarter: 64 of 8,684 with neither, 53 with snapshots alone (at 444 MHz the GPU work does not fit for stretches, which no buffer absorbs), 41 with the GPU filler of PR seedds#81 alone, 4 of 9,000 with both. On this branch the Mac host builds and t_present_crop, t_pace and t_fstep pass. docs/development.md says so
…ain textures can run a frame ahead of the screen Breath of the Wild has two swapchain textures and gets one back only when the display link has taken its previous present, so each frame's CPU work starts on a tick and the GPU idles from the end of one frame to the first work of the next. macOS reads that idle time as room and holds the GPU at its lowest clock (444 MHz on an M2 Max) even while frames miss the screen. With DM_PRESENT_SNAP=1 each present is copied on the game's queue, right after the frame's work, into one of two host textures (nvn_mtl.m snap_take), the display link shows the copy, and the game's texture is free at once: the game runs up to a frame ahead of the screen and a frame whose GPU work runs long is absorbed instead of shown late. The presenting thread's wait for a free ring slot paces the game; AcquireTexture then does not wait for a display link tick, and the frame step counts the slot wait as waiting, not as the frame's cost (counted as cost, it stepped Breath of the Wild down to 30 fps). Presents from another thread while Metal encoding runs on its own thread (DM_NVN_ENC_THREAD) are not copied. Off by default. Checked on the same change on the previous base (the Breath of the Wild Mac shader library here is of that chain): Zora's Domain from a Cemu save, M2 Max, 144 Hz screen at 120 Hz, about 145 s each, frames on screen longer than 1/60 s by a quarter: 64 of 8,684 with neither, 53 with snapshots alone (at 444 MHz the GPU work does not fit for stretches, which no buffer absorbs), 41 with the GPU filler of PR seedds#81 alone, 4 of 9,000 with both. On this branch the Mac host builds and t_present_crop, t_pace and t_fstep pass. docs/development.md says so
…ain textures can run a frame ahead of the screen Breath of the Wild has two swapchain textures and gets one back only when the display link has taken its previous present, so each frame's CPU work starts on a tick and the GPU idles from the end of one frame to the first work of the next. macOS reads that idle time as room and holds the GPU at its lowest clock (444 MHz on an M2 Max) even while frames miss the screen. With DM_PRESENT_SNAP=1 each present is copied on the game's queue, right after the frame's work, into one of two host textures (nvn_mtl.m snap_take), the display link shows the copy, and the game's texture is free at once: the game runs up to a frame ahead of the screen and a frame whose GPU work runs long is absorbed instead of shown late. The presenting thread's wait for a free ring slot paces the game; AcquireTexture then does not wait for a display link tick, and the frame step counts the slot wait as waiting, not as the frame's cost (counted as cost, it stepped Breath of the Wild down to 30 fps). Presents from another thread while Metal encoding runs on its own thread (DM_NVN_ENC_THREAD) are not copied. Off by default. Checked on the same change on the previous base (the Breath of the Wild Mac shader library here is of that chain): Zora's Domain from a Cemu save, M2 Max, 144 Hz screen at 120 Hz, about 145 s each, frames on screen longer than 1/60 s by a quarter: 64 of 8,684 with neither, 53 with snapshots alone (at 444 MHz the GPU work does not fit for stretches, which no buffer absorbs), 41 with the GPU filler of PR seedds#81 alone, 4 of 9,000 with both. On this branch the Mac host builds and t_present_crop, t_pace and t_fstep pass. docs/reference/frame-rate.md (Present snapshots) and the note of Breath of the Wild say so
A narrower version of #62's GPU filler for #71 (Breath of the Wild's frame rate drops on the Mac as macOS lowers the GPU clock). Split out of #76. Draft. The alternative that changes presentation instead is now #87 (present snapshots plus a frame step that judges lateness by the screen). In Zora's Domain it held 60 fps at 444 MHz without this filler. Which one to keep, or both, is up to you; see the comparison in the comments.
Your two objections on #62, and how this version handles them:
DM_GPU_FILL=1as the macOS default.Measured on BotW at 60 fps (M2 Max,
macmonevery second for 180 s):I see this as a workaround to ship now rather than the fix. macOS has no API for the GPU clock. On the developer forums an Apple engineer advised against GPU busy-work and asked for feedback reports (thread 768160). Instruments' "Performance State" setting is for profiling only. A fundamental fix still has to be found: one that removes the idle GPU time macOS reacts to, or gets macOS to treat the game's work as latency-bound. One known approach is LASRecomp's:
nvnSyncWaitwaits for the fence before the newest, so the GPU runs one frame behind (PR #241). That approach brings readback and race questions of its own, and I don't want to settle on it yet. I'll look for a proper solution separately and propose it on its own. Until then the filler is off unless frames come late, andDM_GPU_FILL=0turns it off entirely.Limits. The filler fixes the clock, not every long frame. Three other sources remain:
dmhoststarted without an Info.plist, the Metal shader cache is shared with other command-line tools and keeps only three rotating files.