perf(libc): wait on a critical kernel timer in macOS PreciseSleep #15583

Merged
Gonic0 merged 3 commits from upstream-pr/15583 into main 2026-11-07 12:45:47 +00:00
Gonic0 commented 2026-11-03 20:22:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gonic0 on 2026-11-03T20:22:28Z.


What

PreciseSleep on macOS sleeps for 70 % of a wait with nanosleep and spins through the rest, capped at 5 ms (#12127), to absorb the wake latency of nanosleep. A guest that sleeps in short steps keeps a core busy that way. In PPSA21564's gameplay about 1000 waits of 1.8 ms a second reach PreciseSleep (guest sceKernelUsleep/nanosleep), and they spin about 4.3 s of CPU every 10 s.

The wait now arms a one-shot EVFILT_TIMER with NOTE_CRITICAL and zero leeway on a per-thread kqueue, then spins only the last 30 us. A wait of 30 us or less spins as before, and the nanosleep path stays as the fallback when the kqueue cannot be created. The timer lives in src/PreciseWait.cpp, because <sys/event.h> in the header clashes with the EVFILT_* names in Equeue.hpp.

Tested

macOS 27.2, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2, on main 086c0686c8.

  • precise_wait_tests gains a macOS check: the kernel timer waits until its wake time, and 20 PreciseSleepUs(2000) calls take less than 3 ms of process CPU time (getrusage; CLOCK_THREAD_CPUTIME_ID does not count the spin under Rosetta 2). With this change: 3 of 3 runs pass, including the existing median bounds (PreciseSleepUs(1500) under 1650 us). With the timer disabled: the check fails in 2 of 3 runs (spun for 6786 us of thread CPU time over 20 sleeps); the third skipped the bound on a busy machine, as the existing checks do.
  • The kernel timer is declared extern "C": libc.prx exports only the C names of its _nid_no_patch functions, so with C++ linkage libSceVideoOut.prx failed to load (Symbol not found: __Z36PreciseKernelTimerSleep_nid_no_patchy). Every file that includes PreciseWait.hpp compiles on this branch. libkernel does not link on macOS on this main without the open macOS port pull requests.
  • PPSA21564 on KosmicKrisp: the game ran on a tree with those pull requests, built once at a commit with main's PreciseWait.hpp (4ef0c8c5d034) and once with this change (78f5788e6bcf), alternating, 140 s each, the same pad input, capture APS5_TRACE_FRAMES=1100:300. Process CPU is sampled every 5 s with ps from 60 s on:
run commit process CPU frame p50 p90 p99 GPU busy per present
base 1 4ef0c8c5d034 347 % 83.3 ms 96.3 144.5 64.0 ms
this change 1 78f5788e6bcf 261 % 78.8 ms 91.4 133.4 61.1 ms
base 2 4ef0c8c5d034 333 % 81.9 ms 98.8 157.3 63.1 ms
this change 2 78f5788e6bcf 301 % 77.9 ms 92.3 104.7 60.4 ms

An earlier pair on that tree with the timer behind a switch counted the spin: 4.2 to 4.4 s every 10 s before, 0.11 to 0.12 s after; the mean lateness of a wait went from 1 to 2 us to about 4 us, with a maximum of 1.1 to 2.5 ms in both. Both traces below lost events of queue worker 0x0 after about 14.5 s (buffer full); the summary statistics cover the whole window.

Summary lines of pair 2 (traces attached: base, 4ef0c8c5d034, this change, 78f5788e6bcf):

{"commit":"4ef0c8c5d034","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":25369.456},"presents":300,"frame_ms":{"p50":81.852,"p90":98.830,"p99":157.339,"max":259.677},"gpu_busy_ms_per_present":63.090,"worker_busy_pct":{"queue worker 0x0":98.617,"queue worker 0x40":99.615,"queue worker 0x48":98.439,"queue worker 0x3a":0.000,"queue worker 0x46":0.546},"top_phases_ms_per_frame":{"Driver.Packet":250.781,"Driver.Packet.memory_wait":162.354,"Driver.Packet.prepare_memory":30.517,"Exp.FenceWait.idle":28.351,"Driver.Packet.draw":26.053,"Driver.Draw":25.983,"Graphics.Draw":22.531,"Graphics.Draw.draw_and_resource_release":15.349},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.367,"events_lost":251708,"totals_full":false}},"trace":"aps5-trace-4ef0c8c5d034-82982.json.gz"}
{"commit":"78f5788e6bcf","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":23469.562},"presents":300,"frame_ms":{"p50":77.866,"p90":92.309,"p99":104.691,"max":131.074},"gpu_busy_ms_per_present":60.375,"worker_busy_pct":{"queue worker 0x0":99.177,"queue worker 0x40":99.640,"queue worker 0x48":98.758,"queue worker 0x3a":0.000},"top_phases_ms_per_frame":{"Driver.Packet":232.349,"Driver.Packet.memory_wait":150.957,"Driver.Packet.prepare_memory":29.948,"Exp.FenceWait.idle":28.117,"Driver.Packet.draw":24.260,"Driver.Draw":24.202,"Graphics.Draw":21.205,"Graphics.Draw.draw_and_resource_release":13.175},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.661,"events_lost":220656,"totals_full":false}},"trace":"aps5-trace-78f5788e6bcf-83849.json.gz"}
tools/trace_digest.py, base (4ef0c8c5d034)

frames 1100:300 from present 1100: 300 presents, frame p50 81.9 / p90 98.8 / p99 157.3 / max 259.7 ms, GPU busy 63.1 ms per present
Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 4ef0c8c5d034, dropped: yes

{"commit":"4ef0c8c5d034","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":25369.456},"presents":300,"frame_ms":{"p50":81.852,"p90":98.83,"p99":157.339,"max":259.677},"gpu_busy_ms_per_present":63.09,"worker_busy_pct":{"queue worker 0x0":98.617,"queue worker 0x40":99.615,"queue worker 0x48":98.439,"queue worker 0x3a":0.0,"queue worker 0x46":0.546},"top_phases_ms_per_frame":{"Driver.Packet":250.781,"Driver.Packet.memory_wait":162.354,"Driver.Packet.prepare_memory":30.517,"Exp.FenceWait.idle":28.351,"Driver.Packet.draw":26.053,"Driver.Draw":25.983,"Graphics.Draw":22.531,"Graphics.Draw.draw_and_resource_release":15.349},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.367,"events_lost":251708,"totals_full":false}},"trace":"aps5-trace-4ef0c8c5d034-82982.json.gz"}

Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.

  • queue worker 0x0: 251708 events lost; buffer full at 14367.2 ms

Slowest frames (largest slices inside each, inclusive)

  • present 1390: 259.7 ms at 24003 ms: Driver.Packet (queue worker 0x40) 258.6, Driver.Packet (queue worker 0x48) 258.2, Driver.Packet.memory_wait (queue worker 0x48) 256.7, Driver.Packet.memory_wait (queue worker 0x40) 250.4
  • present 1392: 234.9 ms at 24379 ms: Driver.Packet (queue worker 0x48) 234.7, Driver.Packet (queue worker 0x40) 234.2, Driver.Packet.memory_wait (queue worker 0x48) 233.7, Driver.Packet.memory_wait (queue worker 0x40) 229.5
  • present 1258: 157.3 ms at 12282 ms: Driver.Packet (queue worker 0x48) 157.1, Driver.Packet (queue worker 0x40) 156.5, Driver.Packet.memory_wait (queue worker 0x48) 155.5, Driver.Packet (queue worker 0x0) 150.4
  • present 1397: 146.9 ms at 25021 ms: Driver.Packet (queue worker 0x48) 146.7, Driver.Packet (queue worker 0x40) 146.0, Driver.Packet.memory_wait (queue worker 0x48) 145.2, Driver.Packet.memory_wait (queue worker 0x40) 140.3
  • present 1349: 122.2 ms at 20106 ms: Driver.Packet (queue worker 0x48) 121.9, Driver.Packet (queue worker 0x40) 121.5, Driver.Packet.memory_wait (queue worker 0x48) 120.3, Driver.Packet.memory_wait (queue worker 0x40) 115.1

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 1390: 259.7 ms at 24003 ms, persistence 199.4 ms
  • present 1392: 234.9 ms at 24379 ms, persistence 118.2 ms
  • present 1258: 157.3 ms at 12282 ms, persistence 87.0 ms
  • present 1397: 146.9 ms at 25021 ms, persistence 53.3 ms
  • present 1225: 107.7 ms at 10016 ms, persistence 42.9 ms
  • present 1164: 104.3 ms at 5280 ms, persistence 38.7 ms
  • present 1349: 122.2 ms at 20106 ms, persistence 35.3 ms
  • present 1288: 108.4 ms at 14750 ms, persistence 31.9 ms
  • present 1304: 100.7 ms at 16055 ms, persistence 23.3 ms
  • present 1188: 97.2 ms at 7328 ms, persistence 22.8 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 24.0 (28 %) 19.4 (23 %) 41.2 13.9 Driver.Packet 43.3, Driver.EndSubmission 0.1
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.5 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.5 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.5 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Shader.PrepareArtifact 0.0
title 0.1 (0 %) 0.0 (0 %) 84.5 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 84.5 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 84.5 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 84.5 0.5 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.4 (0 %) 0.0 (0 %) 84.2 0.0 Shader.ResolveAbi 0.3, Shader.Register 0.0
queue worker 0x40 2.3 (3 %) 81.5 (96 %) 0.8 1.9 Driver.Packet 83.5, Driver.EndSubmission 0.2
queue worker 0x48 0.3 (0 %) 83.8 (99 %) 0.4 0.2 Driver.Packet 83.1, Driver.EndSubmission 0.1
draw committer 22.4 (26 %) 1.4 (2 %) 60.8 11.2 Graphics.Draw 15.7, Recorder.Reap 3.2
presenter 1.5 (2 %) 1.7 (2 %) 81.4 0.1 VideoOut.Flip 3.2, Driver.Present 0.0
title 0.0 (0 %) 0.0 (0 %) 84.6 0.0 Recorder.Sync 0.0, Recorder.Submit 0.0
title 0.1 (0 %) 0.0 (0 %) 84.5 0.0 Shader.ResolveAbi 0.1, Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 84.5 0.0 Shader.ResolveGraphicsStagesAbi 0.0
queue worker 0x46 0.5 (1 %) 0.7 (1 %) 83.4 0.0 Driver.Packet 0.5, Driver.EndSubmission 0.0
gpu 63.2 (75 %) 0.0 (0 %) 21.4 0.0 batch 63.2

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 210.3, Driver.Packet.memory_wait 162.2, batch 63.2, Graphics.Draw 19.8, Driver.Packet.prepare_memory 19.0, Exp.FenceWait.idle 17.6, Graphics.Draw.draw_and_resource_release 14.6, Driver.Packet.draw 13.6, Driver.Draw 13.6, Driver.Packet.dispatch 9.2

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x48) 259.0 ms at 24011 ms, present 1390
  • Driver.Packet.memory_wait (queue worker 0x48) 246.8 ms at 24274 ms, present 1391
  • Driver.Packet.memory_wait (queue worker 0x40) 234.5 ms at 24290 ms, present 1391
  • Driver.Packet.memory_wait (queue worker 0x48) 154.8 ms at 12289 ms, present 1258
  • Driver.Packet.memory_wait (queue worker 0x48) 144.5 ms at 25028 ms, present 1397
  • Driver.Packet.memory_wait (queue worker 0x40) 136.0 ms at 24021 ms, present 1390
  • Driver.Packet.memory_wait (queue worker 0x40) 133.9 ms at 25044 ms, present 1397
  • Driver.Packet.memory_wait (queue worker 0x48) 120.5 ms at 20113 ms, present 1349
  • Driver.Packet.memory_wait (queue worker 0x40) 118.2 ms at 24157 ms, present 1390
  • Driver.Packet.memory_wait (queue worker 0x48) 114.0 ms at 19997 ms, present 1348

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 4068: 40.1 ms at 5120 ms, present 1162: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 31.6, Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.0
  • batch 4204: 39.9 ms at 5322 ms, present 1164: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 26.8, Graphics.Draw (draw committer) 2.0, Graphics.Draw.draw_and_resource_release (draw committer) 1.8, Recorder.Submit (draw committer) 0.1
  • batch 3936: 38.8 ms at 4915 ms, present 1160: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.3, Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.1
  • batch 3808: 38.1 ms at 4728 ms, present 1158: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 31.4, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.0
  • batch 2713: 36.5 ms at 3172 ms, present 1141: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.2, Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.0
tools/trace_digest.py, this change (78f5788e6bcf)

frames 1100:300 from present 1100: 300 presents, frame p50 77.9 / p90 92.3 / p99 104.7 / max 131.1 ms, GPU busy 60.4 ms per present
Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 78f5788e6bcf, dropped: yes

{"commit":"78f5788e6bcf","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":23469.562},"presents":300,"frame_ms":{"p50":77.866,"p90":92.309,"p99":104.691,"max":131.074},"gpu_busy_ms_per_present":60.375,"worker_busy_pct":{"queue worker 0x0":99.177,"queue worker 0x40":99.64,"queue worker 0x48":98.758,"queue worker 0x3a":0.0},"top_phases_ms_per_frame":{"Driver.Packet":232.349,"Driver.Packet.memory_wait":150.957,"Driver.Packet.prepare_memory":29.948,"Exp.FenceWait.idle":28.117,"Driver.Packet.draw":24.26,"Driver.Draw":24.202,"Graphics.Draw":21.205,"Graphics.Draw.draw_and_resource_release":13.175},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.661,"events_lost":220656,"totals_full":false}},"trace":"aps5-trace-78f5788e6bcf-83849.json.gz"}

Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.

  • queue worker 0x0: 220656 events lost; buffer full at 14660.7 ms

Slowest frames (largest slices inside each, inclusive)

  • present 1272: 131.1 ms at 13146 ms: Driver.Packet (queue worker 0x40) 130.6, Driver.Packet (queue worker 0x48) 130.2, Driver.Packet.memory_wait (queue worker 0x48) 129.0, Driver.Packet.memory_wait (queue worker 0x40) 127.6
  • present 1234: 109.5 ms at 10617 ms: Driver.Packet (queue worker 0x48) 109.4, Driver.Packet (queue worker 0x40) 108.8, Driver.Packet.memory_wait (queue worker 0x48) 108.0, Driver.Packet.memory_wait (queue worker 0x40) 105.7
  • present 1303: 104.7 ms at 15567 ms: Driver.Packet (queue worker 0x48) 104.6, Driver.Packet (queue worker 0x40) 104.1, Driver.Packet.memory_wait (queue worker 0x48) 103.9, Driver.Packet.memory_wait (queue worker 0x40) 101.0
  • present 1170: 99.5 ms at 5650 ms: Driver.Packet (queue worker 0x48) 99.3, Driver.Packet (queue worker 0x40) 98.8, Driver.Packet.memory_wait (queue worker 0x48) 98.4, Driver.Packet.memory_wait (queue worker 0x40) 96.5
  • present 1166: 99.1 ms at 5260 ms: Driver.Packet (queue worker 0x48) 98.9, Driver.Packet (queue worker 0x40) 98.5, Driver.Packet.memory_wait (queue worker 0x48) 98.2, Driver.Packet.memory_wait (queue worker 0x40) 95.7

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 1272: 131.1 ms at 13146 ms, persistence 70.2 ms
  • present 1234: 109.5 ms at 10617 ms, persistence 46.2 ms
  • present 1303: 104.7 ms at 15567 ms, persistence 36.9 ms
  • present 1170: 99.5 ms at 5650 ms, persistence 35.0 ms
  • present 1197: 98.4 ms at 7944 ms, persistence 21.5 ms
  • present 1349: 93.2 ms at 19224 ms, persistence 19.8 ms
  • present 1217: 85.6 ms at 9454 ms, persistence 19.6 ms
  • present 1202: 91.4 ms at 8352 ms, persistence 16.0 ms
  • present 1280: 87.8 ms at 13790 ms, persistence 12.9 ms
  • present 1145: 97.9 ms at 3301 ms, persistence 8.1 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 23.6 (30 %) 20.5 (26 %) 34.1 14.1 Driver.Packet 44.1, Driver.EndSubmission 0.1
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.PrepareArtifact 0.0
title 0.1 (0 %) 0.0 (0 %) 78.2 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 78.1 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 78.2 0.1 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.4 (1 %) 0.0 (0 %) 77.8 0.0 Shader.ResolveAbi 0.4, Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.2 0.5 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
queue worker 0x40 2.0 (3 %) 75.5 (97 %) 0.7 1.9 Driver.Packet 77.3, Driver.EndSubmission 0.1
queue worker 0x48 0.3 (0 %) 77.6 (99 %) 0.3 0.2 Driver.Packet 77.1, Driver.EndSubmission 0.1
draw committer 18.5 (24 %) 1.1 (1 %) 58.6 11.6 Graphics.Draw 13.3, Recorder.Submit 2.3
presenter 1.3 (2 %) 1.7 (2 %) 75.2 0.0 VideoOut.Flip 3.0, Driver.Present 0.0
title 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.ResolveAbi 0.0, Shader.Register 0.0
title 0.0 (0 %) 0.0 (0 %) 78.2 0.0 Shader.ResolveGraphicsStagesAbi 0.0
gpu 60.4 (77 %) 0.0 (0 %) 17.8 0.0 batch 60.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 198.5, Driver.Packet.memory_wait 150.8, batch 60.4, Driver.Packet.prepare_memory 19.5, Exp.FenceWait.idle 18.3, Graphics.Draw 18.0, Driver.Packet.draw 13.9, Driver.Draw 13.9, Graphics.Draw.draw_and_resource_release 12.3, Driver.Packet.dispatch 8.1

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x48) 129.5 ms at 13152 ms, present 1272
  • Driver.Packet.memory_wait (queue worker 0x48) 108.1 ms at 10621 ms, present 1234
  • Driver.Packet.memory_wait (queue worker 0x48) 102.8 ms at 15572 ms, present 1303
  • Driver.Packet.memory_wait (queue worker 0x40) 100.0 ms at 13098 ms, present 1271
  • Driver.Packet.memory_wait (queue worker 0x40) 98.1 ms at 15583 ms, present 1303
  • Driver.Packet.memory_wait (queue worker 0x48) 98.0 ms at 5265 ms, present 1166
  • Driver.Packet.memory_wait (queue worker 0x48) 97.6 ms at 5655 ms, present 1170
  • Driver.Packet.memory_wait (queue worker 0x48) 97.3 ms at 5556 ms, present 1169
  • Driver.Packet.memory_wait (queue worker 0x48) 96.5 ms at 5459 ms, present 1168
  • Driver.Packet.memory_wait (queue worker 0x48) 96.0 ms at 3307 ms, present 1145

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 4562: 39.0 ms at 5684 ms, present 1170: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 29.9, Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0
  • batch 4627: 38.3 ms at 5783 ms, present 1171: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 30.2, Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0
  • batch 4823: 37.7 ms at 6064 ms, present 1174: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 29.6, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.1
  • batch 3855: 36.6 ms at 4636 ms, present 1159: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 27.6, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.1
  • batch 4370: 36.5 ms at 5395 ms, present 1167: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.0, Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0
  • Linux and Windows: not affected; the change is inside __APPLE__ blocks.
  • tools/check_conventions.py passes. tools/pr_overlap.py finds no overlapping pull request; the ones it could not compare (they conflict with main) share only the source list in core/libs/prx/libc/CMakeLists.txt, and none of them touches PreciseWait.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5143965866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15583). Originally posted by [Gonic0](https://github.com/Gonic0) on 2026-11-03T20:22:28Z. --- ### What `PreciseSleep` on macOS sleeps for 70 % of a wait with `nanosleep` and spins through the rest, capped at 5 ms (#12127), to absorb the wake latency of `nanosleep`. A guest that sleeps in short steps keeps a core busy that way. In PPSA21564's gameplay about 1000 waits of 1.8 ms a second reach `PreciseSleep` (guest `sceKernelUsleep`/`nanosleep`), and they spin about 4.3 s of CPU every 10 s. The wait now arms a one-shot `EVFILT_TIMER` with `NOTE_CRITICAL` and zero leeway on a per-thread `kqueue`, then spins only the last 30 us. A wait of 30 us or less spins as before, and the `nanosleep` path stays as the fallback when the `kqueue` cannot be created. The timer lives in `src/PreciseWait.cpp`, because `<sys/event.h>` in the header clashes with the `EVFILT_*` names in `Equeue.hpp`. ### Tested macOS 27.2, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2, on `main` `086c0686c8`. - `precise_wait_tests` gains a macOS check: the kernel timer waits until its wake time, and 20 `PreciseSleepUs(2000)` calls take less than 3 ms of process CPU time (`getrusage`; `CLOCK_THREAD_CPUTIME_ID` does not count the spin under Rosetta 2). With this change: 3 of 3 runs pass, including the existing median bounds (`PreciseSleepUs(1500)` under 1650 us). With the timer disabled: the check fails in 2 of 3 runs (`spun for 6786 us of thread CPU time over 20 sleeps`); the third skipped the bound on a busy machine, as the existing checks do. - The kernel timer is declared `extern "C"`: `libc.prx` exports only the C names of its `_nid_no_patch` functions, so with C++ linkage `libSceVideoOut.prx` failed to load (`Symbol not found: __Z36PreciseKernelTimerSleep_nid_no_patchy`). Every file that includes `PreciseWait.hpp` compiles on this branch. `libkernel` does not link on macOS on this `main` without the open macOS port pull requests. - PPSA21564 on KosmicKrisp: the game ran on a tree with those pull requests, built once at a commit with `main`'s `PreciseWait.hpp` (`4ef0c8c5d034`) and once with this change (`78f5788e6bcf`), alternating, 140 s each, the same pad input, capture `APS5_TRACE_FRAMES=1100:300`. Process CPU is sampled every 5 s with `ps` from 60 s on: | run | commit | process CPU | frame p50 | p90 | p99 | GPU busy per present | |---|---|---|---|---|---|---| | base 1 | `4ef0c8c5d034` | 347 % | 83.3 ms | 96.3 | 144.5 | 64.0 ms | | this change 1 | `78f5788e6bcf` | 261 % | 78.8 ms | 91.4 | 133.4 | 61.1 ms | | base 2 | `4ef0c8c5d034` | 333 % | 81.9 ms | 98.8 | 157.3 | 63.1 ms | | this change 2 | `78f5788e6bcf` | 301 % | 77.9 ms | 92.3 | 104.7 | 60.4 ms | An earlier pair on that tree with the timer behind a switch counted the spin: 4.2 to 4.4 s every 10 s before, 0.11 to 0.12 s after; the mean lateness of a wait went from 1 to 2 us to about 4 us, with a maximum of 1.1 to 2.5 ms in both. Both traces below lost events of `queue worker 0x0` after about 14.5 s (buffer full); the summary statistics cover the whole window. Summary lines of pair 2 (traces attached: [base, `4ef0c8c5d034`](https://github.com/user-attachments/files/34341606/aps5-trace-4ef0c8c5d034-82982.json.gz), [this change, `78f5788e6bcf`](https://github.com/user-attachments/files/34341614/aps5-trace-78f5788e6bcf-83849.json.gz)): ```json {"commit":"4ef0c8c5d034","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":25369.456},"presents":300,"frame_ms":{"p50":81.852,"p90":98.830,"p99":157.339,"max":259.677},"gpu_busy_ms_per_present":63.090,"worker_busy_pct":{"queue worker 0x0":98.617,"queue worker 0x40":99.615,"queue worker 0x48":98.439,"queue worker 0x3a":0.000,"queue worker 0x46":0.546},"top_phases_ms_per_frame":{"Driver.Packet":250.781,"Driver.Packet.memory_wait":162.354,"Driver.Packet.prepare_memory":30.517,"Exp.FenceWait.idle":28.351,"Driver.Packet.draw":26.053,"Driver.Draw":25.983,"Graphics.Draw":22.531,"Graphics.Draw.draw_and_resource_release":15.349},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.367,"events_lost":251708,"totals_full":false}},"trace":"aps5-trace-4ef0c8c5d034-82982.json.gz"} ``` ```json {"commit":"78f5788e6bcf","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":23469.562},"presents":300,"frame_ms":{"p50":77.866,"p90":92.309,"p99":104.691,"max":131.074},"gpu_busy_ms_per_present":60.375,"worker_busy_pct":{"queue worker 0x0":99.177,"queue worker 0x40":99.640,"queue worker 0x48":98.758,"queue worker 0x3a":0.000},"top_phases_ms_per_frame":{"Driver.Packet":232.349,"Driver.Packet.memory_wait":150.957,"Driver.Packet.prepare_memory":29.948,"Exp.FenceWait.idle":28.117,"Driver.Packet.draw":24.260,"Driver.Draw":24.202,"Graphics.Draw":21.205,"Graphics.Draw.draw_and_resource_release":13.175},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.661,"events_lost":220656,"totals_full":false}},"trace":"aps5-trace-78f5788e6bcf-83849.json.gz"} ``` <details><summary><code>tools/trace_digest.py</code>, base (<code>4ef0c8c5d034</code>)</summary> **frames 1100:300** from present 1100: 300 presents, frame p50 81.9 / p90 98.8 / p99 157.3 / max 259.7 ms, GPU busy 63.1 ms per present Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 4ef0c8c5d034, dropped: yes ```json {"commit":"4ef0c8c5d034","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":25369.456},"presents":300,"frame_ms":{"p50":81.852,"p90":98.83,"p99":157.339,"max":259.677},"gpu_busy_ms_per_present":63.09,"worker_busy_pct":{"queue worker 0x0":98.617,"queue worker 0x40":99.615,"queue worker 0x48":98.439,"queue worker 0x3a":0.0,"queue worker 0x46":0.546},"top_phases_ms_per_frame":{"Driver.Packet":250.781,"Driver.Packet.memory_wait":162.354,"Driver.Packet.prepare_memory":30.517,"Exp.FenceWait.idle":28.351,"Driver.Packet.draw":26.053,"Driver.Draw":25.983,"Graphics.Draw":22.531,"Graphics.Draw.draw_and_resource_release":15.349},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.367,"events_lost":251708,"totals_full":false}},"trace":"aps5-trace-4ef0c8c5d034-82982.json.gz"} ``` **Incomplete trace:** recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately. - queue worker 0x0: 251708 events lost; buffer full at 14367.2 ms **Slowest frames** (largest slices inside each, inclusive) - present 1390: 259.7 ms at 24003 ms: Driver.Packet (queue worker 0x40) 258.6, Driver.Packet (queue worker 0x48) 258.2, Driver.Packet.memory_wait (queue worker 0x48) 256.7, Driver.Packet.memory_wait (queue worker 0x40) 250.4 - present 1392: 234.9 ms at 24379 ms: Driver.Packet (queue worker 0x48) 234.7, Driver.Packet (queue worker 0x40) 234.2, Driver.Packet.memory_wait (queue worker 0x48) 233.7, Driver.Packet.memory_wait (queue worker 0x40) 229.5 - present 1258: 157.3 ms at 12282 ms: Driver.Packet (queue worker 0x48) 157.1, Driver.Packet (queue worker 0x40) 156.5, Driver.Packet.memory_wait (queue worker 0x48) 155.5, Driver.Packet (queue worker 0x0) 150.4 - present 1397: 146.9 ms at 25021 ms: Driver.Packet (queue worker 0x48) 146.7, Driver.Packet (queue worker 0x40) 146.0, Driver.Packet.memory_wait (queue worker 0x48) 145.2, Driver.Packet.memory_wait (queue worker 0x40) 140.3 - present 1349: 122.2 ms at 20106 ms: Driver.Packet (queue worker 0x48) 121.9, Driver.Packet (queue worker 0x40) 121.5, Driver.Packet.memory_wait (queue worker 0x48) 120.3, Driver.Packet.memory_wait (queue worker 0x40) 115.1 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 1390: 259.7 ms at 24003 ms, persistence 199.4 ms - present 1392: 234.9 ms at 24379 ms, persistence 118.2 ms - present 1258: 157.3 ms at 12282 ms, persistence 87.0 ms - present 1397: 146.9 ms at 25021 ms, persistence 53.3 ms - present 1225: 107.7 ms at 10016 ms, persistence 42.9 ms - present 1164: 104.3 ms at 5280 ms, persistence 38.7 ms - present 1349: 122.2 ms at 20106 ms, persistence 35.3 ms - present 1288: 108.4 ms at 14750 ms, persistence 31.9 ms - present 1304: 100.7 ms at 16055 ms, persistence 23.3 ms - present 1188: 97.2 ms at 7328 ms, persistence 22.8 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 24.0 (28 %) | 19.4 (23 %) | 41.2 | 13.9 | Driver.Packet 43.3, Driver.EndSubmission 0.1 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Shader.PrepareArtifact 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 84.5 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 84.5 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 84.5 | 0.5 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.4 (0 %) | 0.0 (0 %) | 84.2 | 0.0 | Shader.ResolveAbi 0.3, Shader.Register 0.0 | | queue worker 0x40 | 2.3 (3 %) | 81.5 (96 %) | 0.8 | 1.9 | Driver.Packet 83.5, Driver.EndSubmission 0.2 | | queue worker 0x48 | 0.3 (0 %) | 83.8 (99 %) | 0.4 | 0.2 | Driver.Packet 83.1, Driver.EndSubmission 0.1 | | draw committer | 22.4 (26 %) | 1.4 (2 %) | 60.8 | 11.2 | Graphics.Draw 15.7, Recorder.Reap 3.2 | | presenter | 1.5 (2 %) | 1.7 (2 %) | 81.4 | 0.1 | VideoOut.Flip 3.2, Driver.Present 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 84.6 | 0.0 | Recorder.Sync 0.0, Recorder.Submit 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.ResolveAbi 0.1, Shader.Register 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 84.5 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0 | | queue worker 0x46 | 0.5 (1 %) | 0.7 (1 %) | 83.4 | 0.0 | Driver.Packet 0.5, Driver.EndSubmission 0.0 | | gpu | 63.2 (75 %) | 0.0 (0 %) | 21.4 | 0.0 | batch 63.2 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 210.3, Driver.Packet.memory_wait 162.2, batch 63.2, Graphics.Draw 19.8, Driver.Packet.prepare_memory 19.0, Exp.FenceWait.idle 17.6, Graphics.Draw.draw_and_resource_release 14.6, Driver.Packet.draw 13.6, Driver.Draw 13.6, Driver.Packet.dispatch 9.2 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x48) 259.0 ms at 24011 ms, present 1390 - Driver.Packet.memory_wait (queue worker 0x48) 246.8 ms at 24274 ms, present 1391 - Driver.Packet.memory_wait (queue worker 0x40) 234.5 ms at 24290 ms, present 1391 - Driver.Packet.memory_wait (queue worker 0x48) 154.8 ms at 12289 ms, present 1258 - Driver.Packet.memory_wait (queue worker 0x48) 144.5 ms at 25028 ms, present 1397 - Driver.Packet.memory_wait (queue worker 0x40) 136.0 ms at 24021 ms, present 1390 - Driver.Packet.memory_wait (queue worker 0x40) 133.9 ms at 25044 ms, present 1397 - Driver.Packet.memory_wait (queue worker 0x48) 120.5 ms at 20113 ms, present 1349 - Driver.Packet.memory_wait (queue worker 0x40) 118.2 ms at 24157 ms, present 1390 - Driver.Packet.memory_wait (queue worker 0x48) 114.0 ms at 19997 ms, present 1348 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 4068: 40.1 ms at 5120 ms, present 1162: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 31.6, Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.0 - batch 4204: 39.9 ms at 5322 ms, present 1164: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 26.8, Graphics.Draw (draw committer) 2.0, Graphics.Draw.draw_and_resource_release (draw committer) 1.8, Recorder.Submit (draw committer) 0.1 - batch 3936: 38.8 ms at 4915 ms, present 1160: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.3, Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.1 - batch 3808: 38.1 ms at 4728 ms, present 1158: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 31.4, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.0 - batch 2713: 36.5 ms at 3172 ms, present 1141: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.2, Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.6, Recorder.Submit (draw committer) 0.0 </details> <details><summary><code>tools/trace_digest.py</code>, this change (<code>78f5788e6bcf</code>)</summary> **frames 1100:300** from present 1100: 300 presents, frame p50 77.9 / p90 92.3 / p99 104.7 / max 131.1 ms, GPU busy 60.4 ms per present Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 78f5788e6bcf, dropped: yes ```json {"commit":"78f5788e6bcf","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"1100:300"},"gpu":"Apple M5 Pro","driver":"KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964)","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 1100:300","first_present":1100,"ms":23469.562},"presents":300,"frame_ms":{"p50":77.866,"p90":92.309,"p99":104.691,"max":131.074},"gpu_busy_ms_per_present":60.375,"worker_busy_pct":{"queue worker 0x0":99.177,"queue worker 0x40":99.64,"queue worker 0x48":98.758,"queue worker 0x3a":0.0},"top_phases_ms_per_frame":{"Driver.Packet":232.349,"Driver.Packet.memory_wait":150.957,"Driver.Packet.prepare_memory":29.948,"Exp.FenceWait.idle":28.117,"Driver.Packet.draw":24.26,"Driver.Draw":24.202,"Graphics.Draw":21.205,"Graphics.Draw.draw_and_resource_release":13.175},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":14.661,"events_lost":220656,"totals_full":false}},"trace":"aps5-trace-78f5788e6bcf-83849.json.gz"} ``` **Incomplete trace:** recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately. - queue worker 0x0: 220656 events lost; buffer full at 14660.7 ms **Slowest frames** (largest slices inside each, inclusive) - present 1272: 131.1 ms at 13146 ms: Driver.Packet (queue worker 0x40) 130.6, Driver.Packet (queue worker 0x48) 130.2, Driver.Packet.memory_wait (queue worker 0x48) 129.0, Driver.Packet.memory_wait (queue worker 0x40) 127.6 - present 1234: 109.5 ms at 10617 ms: Driver.Packet (queue worker 0x48) 109.4, Driver.Packet (queue worker 0x40) 108.8, Driver.Packet.memory_wait (queue worker 0x48) 108.0, Driver.Packet.memory_wait (queue worker 0x40) 105.7 - present 1303: 104.7 ms at 15567 ms: Driver.Packet (queue worker 0x48) 104.6, Driver.Packet (queue worker 0x40) 104.1, Driver.Packet.memory_wait (queue worker 0x48) 103.9, Driver.Packet.memory_wait (queue worker 0x40) 101.0 - present 1170: 99.5 ms at 5650 ms: Driver.Packet (queue worker 0x48) 99.3, Driver.Packet (queue worker 0x40) 98.8, Driver.Packet.memory_wait (queue worker 0x48) 98.4, Driver.Packet.memory_wait (queue worker 0x40) 96.5 - present 1166: 99.1 ms at 5260 ms: Driver.Packet (queue worker 0x48) 98.9, Driver.Packet (queue worker 0x40) 98.5, Driver.Packet.memory_wait (queue worker 0x48) 98.2, Driver.Packet.memory_wait (queue worker 0x40) 95.7 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 1272: 131.1 ms at 13146 ms, persistence 70.2 ms - present 1234: 109.5 ms at 10617 ms, persistence 46.2 ms - present 1303: 104.7 ms at 15567 ms, persistence 36.9 ms - present 1170: 99.5 ms at 5650 ms, persistence 35.0 ms - present 1197: 98.4 ms at 7944 ms, persistence 21.5 ms - present 1349: 93.2 ms at 19224 ms, persistence 19.8 ms - present 1217: 85.6 ms at 9454 ms, persistence 19.6 ms - present 1202: 91.4 ms at 8352 ms, persistence 16.0 ms - present 1280: 87.8 ms at 13790 ms, persistence 12.9 ms - present 1145: 97.9 ms at 3301 ms, persistence 8.1 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 23.6 (30 %) | 20.5 (26 %) | 34.1 | 14.1 | Driver.Packet 44.1, Driver.EndSubmission 0.1 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.PrepareArtifact 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 78.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.1 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.4 (1 %) | 0.0 (0 %) | 77.8 | 0.0 | Shader.ResolveAbi 0.4, Shader.Register 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.5 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | queue worker 0x40 | 2.0 (3 %) | 75.5 (97 %) | 0.7 | 1.9 | Driver.Packet 77.3, Driver.EndSubmission 0.1 | | queue worker 0x48 | 0.3 (0 %) | 77.6 (99 %) | 0.3 | 0.2 | Driver.Packet 77.1, Driver.EndSubmission 0.1 | | draw committer | 18.5 (24 %) | 1.1 (1 %) | 58.6 | 11.6 | Graphics.Draw 13.3, Recorder.Submit 2.3 | | presenter | 1.3 (2 %) | 1.7 (2 %) | 75.2 | 0.0 | VideoOut.Flip 3.0, Driver.Present 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.ResolveAbi 0.0, Shader.Register 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 78.2 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0 | | gpu | 60.4 (77 %) | 0.0 (0 %) | 17.8 | 0.0 | batch 60.4 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 198.5, Driver.Packet.memory_wait 150.8, batch 60.4, Driver.Packet.prepare_memory 19.5, Exp.FenceWait.idle 18.3, Graphics.Draw 18.0, Driver.Packet.draw 13.9, Driver.Draw 13.9, Graphics.Draw.draw_and_resource_release 12.3, Driver.Packet.dispatch 8.1 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x48) 129.5 ms at 13152 ms, present 1272 - Driver.Packet.memory_wait (queue worker 0x48) 108.1 ms at 10621 ms, present 1234 - Driver.Packet.memory_wait (queue worker 0x48) 102.8 ms at 15572 ms, present 1303 - Driver.Packet.memory_wait (queue worker 0x40) 100.0 ms at 13098 ms, present 1271 - Driver.Packet.memory_wait (queue worker 0x40) 98.1 ms at 15583 ms, present 1303 - Driver.Packet.memory_wait (queue worker 0x48) 98.0 ms at 5265 ms, present 1166 - Driver.Packet.memory_wait (queue worker 0x48) 97.6 ms at 5655 ms, present 1170 - Driver.Packet.memory_wait (queue worker 0x48) 97.3 ms at 5556 ms, present 1169 - Driver.Packet.memory_wait (queue worker 0x48) 96.5 ms at 5459 ms, present 1168 - Driver.Packet.memory_wait (queue worker 0x48) 96.0 ms at 3307 ms, present 1145 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 4562: 39.0 ms at 5684 ms, present 1170: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 29.9, Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0 - batch 4627: 38.3 ms at 5783 ms, present 1171: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 30.2, Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0 - batch 4823: 37.7 ms at 6064 ms, present 1174: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 29.6, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.1 - batch 3855: 36.6 ms at 4636 ms, present 1159: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 27.6, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, Recorder.Submit (draw committer) 0.1 - batch 4370: 36.5 ms at 5395 ms, present 1167: GPU no ranges; recorded by Exp.FenceWait.idle (queue worker 0x0) 28.0, Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5, Recorder.Submit (draw committer) 0.0 </details> - Linux and Windows: not affected; the change is inside `__APPLE__` blocks. - `tools/check_conventions.py` passes. `tools/pr_overlap.py` finds no overlapping pull request; the ones it could not compare (they conflict with `main`) share only the source list in `core/libs/prx/libc/CMakeLists.txt`, and none of them touches `PreciseWait`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15583
No description provided.