perf: PPSA12544 on Legion Go (Ryzen Z1 Extreme, Windows): queue worker 99 % busy, mostly import comparisons and GpuMutex waits #6045

Open
opened 2026-10-14 20:29:27 +00:00 by keravyn-ops · 3 comments
keravyn-ops commented 2026-10-14 20:29:27 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-14T20:29:27Z.


Title and scene

PPSA12544 (Hollow Knight: Silksong) v01.000.010 (master 01.02), gameplay right after loading a save at a bench (Moss Grotto area), standing still, no input, 1920x1080 window.

What is slow or what changed

Device: Lenovo Legion Go (83E1, BIOS N3CN40WW), AMD Ryzen Z1 Extreme (8C/16T) with Radeon 780M graphics (shared memory, 16 GiB, 12.7 GiB visible to Windows), AMD driver 25.10.20.01 (Windows 32.0.21020.1007), Windows 11 Home 10.0.26100. AnyPS5 main e27ff7c545 built locally with WinLibs GCC 15.2.0 r7, relinked with --windows --module-dir Media/Modules --module-dir Media/Plugins.

Frame p50 34.2 ms (about 29 fps). The queue worker is the limit: worker_busy_pct 99.2 %; the GPU is busy 24.3 ms per present. The native PC version of the same game on the same device runs with its busiest thread at 18 % of a core and the GPU at 40 %.

Where the queue worker's time goes (APS5_SAMPLE_WORKER, 7686 samples in the same scene, frames symbolized against my local build of e27ff7c):

share leaf driver frame
33 % ucrtbase (memcmp) GuestMemory::EqualsCommittedUnsynced
32 % ntdll (wait) GuestMemory::GpuMutexType::lock()
17 % ucrtbase (memcpy) GuestMemory::ReadCommittedUnsynced
3 % libSceAgcDriver Recorder::Keep
3 % ntdll DriverDetail::PollSleep

The log says [write-watch] Windows direct host imports use comparisons, and APS5_WRITE_WATCH_IMPORTS is Linux only, so this looks like the Windows comparison path plus contention on the GPU mutex. The digest also shows Driver.Draw.gpu_mutex_wait waits of up to 11 ms on the queue worker.

The host import budget is small on this APU: the default comes out at 1056 MiB (the largest host heap is about 3 GiB, less the 2 GiB reserve), it is full within seconds and imports are refused ([gpu] host import budget: 1053 MiB live of 1056 MiB (APS5_HOST_IMPORT_MIB); 46 imports (618 MiB) refused so far). Raising it does not help:

switches (same scene, warm caches) fps
none 28-29
APS5_THREAD_PRIORITY=high 31-32
APS5_STORE_AT_FLIP=1 22-23
APS5_STORE_AT_FLIP=1 APS5_THREAD_PRIORITY=high 22-23
APS5_STORE_AT_LABEL=1 APS5_THREAD_PRIORITY=high 9
APS5_STORE_AT_FLIP=1 APS5_HOST_IMPORT_MIB=2560 5.7
APS5_STORE_AT_FLIP=1 APS5_HOST_IMPORT_MIB=256 21-29

(The fps column is the window title's counter, sampled four times after the scene settled.)

APS5_STORE_AT_FLIP=1 is needed on this device: without it the title crashed while the save loaded in 7 of 13 runs (2 of 7 without any trace or sampling switch), and in none of 7 runs with it. Details and crash logs are in #726.

Summary lines

{"commit":"e27ff7c545cb","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_THREAD_PRIORITY":"high","APS5_TRACE_SECONDS":"90:20"},"gpu":"AMD Radeon Graphics","driver":"AMD proprietary driver 25.10.20.01 (LLPC)","os":"Windows 10.0.26100","resolution":"1920x1080","window":{"spec":"seconds 90:20","first_present":4462,"ms":20023.069},"presents":576,"frame_ms":{"p50":34.169,"p90":39.320,"p99":41.857,"max":42.695},"gpu_busy_ms_per_present":24.265,"worker_busy_pct":{"queue worker 0x0":99.226},"top_phases_ms_per_frame":{"Driver.Packet":34.421,"Driver.Packet.draw":30.597,"Driver.Draw":30.517,"Driver.Draw.draw_and_resource_release":23.538,"Graphics.Draw":23.332,"Graphics.Draw.draw_and_resource_release":22.313,"Driver.Present":12.171,"Driver.Present.present_display_buffer":6.037},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":9.047,"events_lost":316973,"totals_full":false}},"trace":"aps5-trace-e27ff7c545cb-16016.json.gz"}

Traces

aps5-trace-e27ff7c545cb-16016.json.gz is in the attached zip, together with aps5-summary.jsonl, digest.txt, the worker stacks and the crash logs referenced in #726.

APS5_PAD_INPUT_FILE only loaded the save (two presses before the window). The queue worker's event buffer filled after 9 s. Shorter windows (90:8) would have avoided that, but those runs crashed while the save loaded, so this is the capture I have.

anyps5-report-attachments.zip

Digest

Full output in digest.txt (in the zip), from python tools/trace_digest.py. Excerpt:

seconds 90:20 from present 4462: 576 presents, frame p50 34.2 / p90 39.3 / p99 41.9 / max 42.7 ms, GPU busy 24.3 ms per present
Longest waits: Driver.Draw.gpu_mutex_wait (queue worker 0x0) 11.1 ms, 10.9 ms, 10.9 ms, 10.7 ms, 10.0 ms ...

Worker stacks

worker.collapsed.txt and worker.txt (in the zip), from a separate run of the same scene with APS5_SAMPLE_WORKER, APS5_STORE_AT_FLIP=1 and APS5_THREAD_PRIORITY=high. Module offsets are from my local build of e27ff7c (WinLibs GCC 15.2.0 r7).

Capture

  • The caches were warm (the scene ran once and the title was restarted)
  • No other APS5_TRACE_* or APS5_PROFILE_* switch was set and the log was not redirected
  • Captures compared here come from the same machine, scene and settings
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5855146447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6045). Originally posted by [keravyn-ops](https://github.com/keravyn-ops) on 2026-10-14T20:29:27Z. --- ### Title and scene PPSA12544 (Hollow Knight: Silksong) v01.000.010 (master 01.02), gameplay right after loading a save at a bench (Moss Grotto area), standing still, no input, 1920x1080 window. ### What is slow or what changed Device: Lenovo Legion Go (83E1, BIOS N3CN40WW), AMD Ryzen Z1 Extreme (8C/16T) with Radeon 780M graphics (shared memory, 16 GiB, 12.7 GiB visible to Windows), AMD driver 25.10.20.01 (Windows 32.0.21020.1007), Windows 11 Home 10.0.26100. AnyPS5 `main` e27ff7c545cb built locally with WinLibs GCC 15.2.0 r7, relinked with `--windows --module-dir Media/Modules --module-dir Media/Plugins`. Frame p50 34.2 ms (about 29 fps). The queue worker is the limit: `worker_busy_pct` 99.2 %; the GPU is busy 24.3 ms per present. The native PC version of the same game on the same device runs with its busiest thread at 18 % of a core and the GPU at 40 %. Where the queue worker's time goes (`APS5_SAMPLE_WORKER`, 7686 samples in the same scene, frames symbolized against my local build of e27ff7c): | share | leaf | driver frame | |---|---|---| | 33 % | ucrtbase (memcmp) | `GuestMemory::EqualsCommittedUnsynced` | | 32 % | ntdll (wait) | `GuestMemory::GpuMutexType::lock()` | | 17 % | ucrtbase (memcpy) | `GuestMemory::ReadCommittedUnsynced` | | 3 % | libSceAgcDriver | `Recorder::Keep` | | 3 % | ntdll | `DriverDetail::PollSleep` | The log says `[write-watch] Windows direct host imports use comparisons`, and `APS5_WRITE_WATCH_IMPORTS` is Linux only, so this looks like the Windows comparison path plus contention on the GPU mutex. The digest also shows `Driver.Draw.gpu_mutex_wait` waits of up to 11 ms on the queue worker. The host import budget is small on this APU: the default comes out at 1056 MiB (the largest host heap is about 3 GiB, less the 2 GiB reserve), it is full within seconds and imports are refused (`[gpu] host import budget: 1053 MiB live of 1056 MiB (APS5_HOST_IMPORT_MIB); 46 imports (618 MiB) refused so far`). Raising it does not help: | switches (same scene, warm caches) | fps | |---|---| | none | 28-29 | | `APS5_THREAD_PRIORITY=high` | 31-32 | | `APS5_STORE_AT_FLIP=1` | 22-23 | | `APS5_STORE_AT_FLIP=1 APS5_THREAD_PRIORITY=high` | 22-23 | | `APS5_STORE_AT_LABEL=1 APS5_THREAD_PRIORITY=high` | 9 | | `APS5_STORE_AT_FLIP=1 APS5_HOST_IMPORT_MIB=2560` | 5.7 | | `APS5_STORE_AT_FLIP=1 APS5_HOST_IMPORT_MIB=256` | 21-29 | (The fps column is the window title's counter, sampled four times after the scene settled.) `APS5_STORE_AT_FLIP=1` is needed on this device: without it the title crashed while the save loaded in 7 of 13 runs (2 of 7 without any trace or sampling switch), and in none of 7 runs with it. Details and crash logs are in #726. ### Summary lines ```json {"commit":"e27ff7c545cb","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_THREAD_PRIORITY":"high","APS5_TRACE_SECONDS":"90:20"},"gpu":"AMD Radeon Graphics","driver":"AMD proprietary driver 25.10.20.01 (LLPC)","os":"Windows 10.0.26100","resolution":"1920x1080","window":{"spec":"seconds 90:20","first_present":4462,"ms":20023.069},"presents":576,"frame_ms":{"p50":34.169,"p90":39.320,"p99":41.857,"max":42.695},"gpu_busy_ms_per_present":24.265,"worker_busy_pct":{"queue worker 0x0":99.226},"top_phases_ms_per_frame":{"Driver.Packet":34.421,"Driver.Packet.draw":30.597,"Driver.Draw":30.517,"Driver.Draw.draw_and_resource_release":23.538,"Graphics.Draw":23.332,"Graphics.Draw.draw_and_resource_release":22.313,"Driver.Present":12.171,"Driver.Present.present_display_buffer":6.037},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":9.047,"events_lost":316973,"totals_full":false}},"trace":"aps5-trace-e27ff7c545cb-16016.json.gz"} ``` ### Traces `aps5-trace-e27ff7c545cb-16016.json.gz` is in the attached zip, together with `aps5-summary.jsonl`, `digest.txt`, the worker stacks and the crash logs referenced in #726. `APS5_PAD_INPUT_FILE` only loaded the save (two presses before the window). The queue worker's event buffer filled after 9 s. Shorter windows (`90:8`) would have avoided that, but those runs crashed while the save loaded, so this is the capture I have. [anyps5-report-attachments.zip](https://github.com/user-attachments/files/33457483/anyps5-report-attachments.zip) ### Digest Full output in `digest.txt` (in the zip), from `python tools/trace_digest.py`. Excerpt: ``` seconds 90:20 from present 4462: 576 presents, frame p50 34.2 / p90 39.3 / p99 41.9 / max 42.7 ms, GPU busy 24.3 ms per present Longest waits: Driver.Draw.gpu_mutex_wait (queue worker 0x0) 11.1 ms, 10.9 ms, 10.9 ms, 10.7 ms, 10.0 ms ... ``` ### Worker stacks `worker.collapsed.txt` and `worker.txt` (in the zip), from a separate run of the same scene with `APS5_SAMPLE_WORKER`, `APS5_STORE_AT_FLIP=1` and `APS5_THREAD_PRIORITY=high`. Module offsets are from my local build of e27ff7c (WinLibs GCC 15.2.0 r7). ### Capture - [x] The caches were warm (the scene ran once and the title was restarted) - [x] No other APS5_TRACE_* or APS5_PROFILE_* switch was set and the log was not redirected - [x] Captures compared here come from the same machine, scene and settings
MarcZX10 commented 2026-10-14 20:41:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T20:41:10Z.


I traced the reported memcmp frames to GuestMemory::EqualsCommittedUnsynced in the current tree. Before changing the Windows comparison path, one useful discriminator is an APS5_PROFILE_DRAW=1 capture for the same scene: it emits per-site GPU-mutex wait totals, hold times, and which holder/site those waits occurred behind (with additional profiler overhead). If comparisons account for most of the lock hold, that points to a different fix than a long draw/present/flush critical section. I do not have a Windows reproduction here, so this is a profiling suggestion rather than a diagnosis.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177984205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6045#issuecomment-6177984205). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T20:41:10Z. --- I traced the reported `memcmp` frames to `GuestMemory::EqualsCommittedUnsynced` in the current tree. Before changing the Windows comparison path, one useful discriminator is an `APS5_PROFILE_DRAW=1` capture for the same scene: it emits per-site GPU-mutex wait totals, hold times, and which holder/site those waits occurred behind (with additional profiler overhead). If comparisons account for most of the lock hold, that points to a different fix than a long draw/present/flush critical section. I do not have a Windows reproduction here, so this is a profiling suggestion rather than a diagnosis.
keravyn-ops commented 2026-10-15 16:49:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-15T16:49:46Z.


Update on main 0c4816f611: about 45 fps instead of 29, and the comparisons are gone

Same device, scene and capture method as in the report. AnyPS5 built locally from a clean main 0c4816f611, and the title relinked with that relinker.

e27ff7c (report) 0c4816f611
frame p50 34.2 ms 22.1 ms
GPU busy per present 24.3 ms 14.6 ms
queue worker busy 99.2 % 98.8 %
fps, APS5_THREAD_PRIORITY=high 31-32 44-46 (medians of 8 runs)
fps, plus APS5_STORE_AT_FLIP=1 22-23 38

On this AMD driver the startup log now says host imports of write-watched memory keep the write watch: yes, and [guestmem] counts 35 compares (4 MiB) since start. So #6060 removed the comparison cost reported above. Pipelined draws are on (the default).

APS5_PROFILE_DRAW=1 in the same scene, as @MarcZX100 suggested. This is a separate run with profiler overhead (42-44 fps). The figures are per 10 s, the same in each window from 50 s to 90 s:

  • [draw] pipelined: about 94,000 commits at 101 µs each on the committer, so it is busy about 9.5 s of every 10 s. The queue worker enqueues behind about 5 items (depth 8) and waits 36 µs per draw for room. Packet drains take 5.0 s.
  • [lock], untagged threads: the GPU mutex is held 9.3 s, 9.07 s of that at the draw site (64k holds, max 105 ms), with locked GPU waits 2161 / 5424 ms.
  • [hooksync]: 1271 pending-write syncs waited 5512 ms. All of them are listed under queue 0 DRAW_INDEX_2, over ranges of about 139K.
  • [draw] driver phases on the queue worker: lock wait 49.7 of 63.9 µs per draw packet.
  • The presenter waits 0.78 s, behind untagged/draw.

So the limit is now the draw committer under the GPU mutex, and comparisons play no part. More than half of the committer's lock time is reported as GPU waits.

The lines of one 10 s window (80-90 s) and the cumulative [guestmem] line
[draw] pipelined (10 s, depth 8): 93904 commits at 100.9 us each on the committer, 0 failed; 93907 enqueued behind 4.98 on average, waiting 35.7 us per draw for room; drains: packet 5488 (5047.7 ms) flush 0 (0.0 ms) labels 0 (0.0 ms) capture 0 (0.0 ms) indirect 0 (0.0 ms) submission 184 (8.7 ms); packet drains by opcode: 0x15 x4644 0x10 x422 0xff x422
[lock] untagged thread waited 148 ms for the GPU mutex in 877 of 155877 acquisitions (10 s); by site (acquisitions/waits, waited): other 60591/0 0 ms draw 63977/508 147 ms hook 1270/0 0 ms label 26653/93 1 ms fill 2963/257 0 ms end 423/19 0 ms; held 9301 ms in total, by site (holds, held, max): draw 63976 9069 ms (max 105.2) fill 2964 118 ms (max 40.6) label 26653 95 ms (max 0.1) end 423 18 ms (max 0.1); waited behind (holder/site ms): presenter/present 146; lock() 155877 / try 0 / try failed 0; locked GPU waits 2161 / 5424 ms
[lock] queue 0x0 waited 8 ms for the GPU mutex in 430 of 6362 acquisitions (10 s); by site (acquisitions/waits, waited): dispatch 2544/0 0 ms flush 848/0 0 ms fill 2970/430 8 ms; held 68 ms in total, by site (holds, held, max): dispatch 2544 44 ms (max 0.1) flush 848 17 ms (max 0.1) fill 2970 6 ms (max 0.0) try 903 1 ms (max 0.0); waited behind (holder/site ms): untagged/fill 6; lock() 6362 / try 1030 / try failed 127; locked GPU waits 0 / 0 ms
[lock] presenter waited 778 ms for the GPU mutex in 788 of 846 acquisitions (10 s); by site (acquisitions/waits, waited): present 846/788 778 ms; held 147 ms in total, by site (holds, held, max): present 846 147 ms (max 0.7); waited behind (holder/site ms): untagged/draw 1208 untagged/end 14 untagged/label 1; lock() 846 / try 0 / try failed 0; locked GPU waits 0 / 0 ms
[hooksync] 1271 pending-write syncs waited 5512 ms (10 s); read bytes after the wait: unchanged 0 (target open 0, in flight unsignaled 0, signaled 0), changed 423; stores 0, unchecked 848; targets: 1237 open, 0 already signaled, 2651 batches finished; noted range: <=64K 423 <=1M 848; access: <=64K 423 <=1M 848; top by wait (queue packet site frames: count/ms, unchanged open/unsignaled/signaled, changed, stores, avg range/access): [0x0 DRAW_INDEX_2 unknown +0x0/+0x0/+0x0/+0x0/+0x0/+0x0: 1271/5512ms u0/0/0 c423 s0 139K/139K]
[draw] driver phases (10 s, 63945 draw packets, 63945 drawn, 5954 captures), us per packet: prologue 0.4 precheck 1.0 decode 1.3 program prepare 0.6 capture 0.6 capture hook waits 0.0 recompile 0.6 rect-list 0.0 vectors 1.9 key/lookup/validate 7.1 validate GPU wait 0.0 lock wait 49.7 labels 0.0 Graphics::Draw 0.0 skipped 0.0 epilogue 0.6, total 63.9 (4083.8 ms; Graphics::Draw 0.0 ms, skipped 0.0 ms)
[guestmem] read 1146579 calls 6447 MiB 0.9 s compare 35 calls 4 MiB 0.0 s write 18857 calls 2316 MiB 1.0 s write-changed 0 calls 0 MiB 0.0 s collect 507356 calls 687239 MiB 4.5 s verify 6361439 calls 126534 MiB 0.9 s query 6154 calls 0 MiB 0.1 s collect-memo hits 3947183, collect epochs 27560 collect-dirty 264091 tracker waits 1039 / 6291229

Summary line of the trace run (no profiler):

{"commit":"0c4816f6119e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_THREAD_PRIORITY":"high","APS5_TRACE_SECONDS":"90:20"},"gpu":"AMD Radeon Graphics","driver":"AMD proprietary driver 25.10.20.01 (LLPC)","os":"Windows 10.0.26100","resolution":"1920x1080","window":{"spec":"seconds 90:20","first_present":5620,"ms":20003.059},"presents":906,"frame_ms":{"p50":22.061,"p90":22.812,"p99":23.258,"max":23.637},"gpu_busy_ms_per_present":14.563,"worker_busy_pct":{"queue worker 0x0":98.792},"top_phases_ms_per_frame":{"Driver.Packet":21.787,"Driver.Packet.device_lock":9.602,"Driver.Packet.draw":8.813,"Driver.Draw":8.742,"Driver.Draw.draw_enqueued":6.876,"Driver.Present":3.671,"Driver.Packet.dispatch":2.054,"Driver.Present.gpu_mutex_wait":1.752},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":15.254,"events_lost":82203,"totals_full":false}},"trace":"aps5-trace-0c4816f6119e-896.json.gz"}

I can attach the trace (2.3 MB) and the full profile log if they help.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6197436371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6045#issuecomment-6197436371). Originally posted by [keravyn-ops](https://github.com/keravyn-ops) on 2026-10-15T16:49:46Z. --- **Update on `main` 0c4816f611: about 45 fps instead of 29, and the comparisons are gone** Same device, scene and capture method as in the report. AnyPS5 built locally from a clean `main` 0c4816f611, and the title relinked with that relinker. | | e27ff7c (report) | 0c4816f611 | |---|---|---| | frame p50 | 34.2 ms | 22.1 ms | | GPU busy per present | 24.3 ms | 14.6 ms | | queue worker busy | 99.2 % | 98.8 % | | fps, `APS5_THREAD_PRIORITY=high` | 31-32 | 44-46 (medians of 8 runs) | | fps, plus `APS5_STORE_AT_FLIP=1` | 22-23 | 38 | On this AMD driver the startup log now says `host imports of write-watched memory keep the write watch: yes`, and `[guestmem]` counts 35 compares (4 MiB) since start. So #6060 removed the comparison cost reported above. Pipelined draws are on (the default). `APS5_PROFILE_DRAW=1` in the same scene, as @MarcZX100 suggested. This is a separate run with profiler overhead (42-44 fps). The figures are per 10 s, the same in each window from 50 s to 90 s: - `[draw] pipelined`: about 94,000 commits at 101 µs each on the committer, so it is busy about 9.5 s of every 10 s. The queue worker enqueues behind about 5 items (depth 8) and waits 36 µs per draw for room. Packet drains take 5.0 s. - `[lock]`, untagged threads: the GPU mutex is held 9.3 s, 9.07 s of that at the draw site (64k holds, max 105 ms), with `locked GPU waits 2161 / 5424 ms`. - `[hooksync]`: 1271 pending-write syncs waited 5512 ms. All of them are listed under queue 0 `DRAW_INDEX_2`, over ranges of about 139K. - `[draw] driver phases` on the queue worker: lock wait 49.7 of 63.9 µs per draw packet. - The presenter waits 0.78 s, behind `untagged/draw`. So the limit is now the draw committer under the GPU mutex, and comparisons play no part. More than half of the committer's lock time is reported as GPU waits. <details><summary>The lines of one 10 s window (80-90 s) and the cumulative [guestmem] line</summary> ``` [draw] pipelined (10 s, depth 8): 93904 commits at 100.9 us each on the committer, 0 failed; 93907 enqueued behind 4.98 on average, waiting 35.7 us per draw for room; drains: packet 5488 (5047.7 ms) flush 0 (0.0 ms) labels 0 (0.0 ms) capture 0 (0.0 ms) indirect 0 (0.0 ms) submission 184 (8.7 ms); packet drains by opcode: 0x15 x4644 0x10 x422 0xff x422 [lock] untagged thread waited 148 ms for the GPU mutex in 877 of 155877 acquisitions (10 s); by site (acquisitions/waits, waited): other 60591/0 0 ms draw 63977/508 147 ms hook 1270/0 0 ms label 26653/93 1 ms fill 2963/257 0 ms end 423/19 0 ms; held 9301 ms in total, by site (holds, held, max): draw 63976 9069 ms (max 105.2) fill 2964 118 ms (max 40.6) label 26653 95 ms (max 0.1) end 423 18 ms (max 0.1); waited behind (holder/site ms): presenter/present 146; lock() 155877 / try 0 / try failed 0; locked GPU waits 2161 / 5424 ms [lock] queue 0x0 waited 8 ms for the GPU mutex in 430 of 6362 acquisitions (10 s); by site (acquisitions/waits, waited): dispatch 2544/0 0 ms flush 848/0 0 ms fill 2970/430 8 ms; held 68 ms in total, by site (holds, held, max): dispatch 2544 44 ms (max 0.1) flush 848 17 ms (max 0.1) fill 2970 6 ms (max 0.0) try 903 1 ms (max 0.0); waited behind (holder/site ms): untagged/fill 6; lock() 6362 / try 1030 / try failed 127; locked GPU waits 0 / 0 ms [lock] presenter waited 778 ms for the GPU mutex in 788 of 846 acquisitions (10 s); by site (acquisitions/waits, waited): present 846/788 778 ms; held 147 ms in total, by site (holds, held, max): present 846 147 ms (max 0.7); waited behind (holder/site ms): untagged/draw 1208 untagged/end 14 untagged/label 1; lock() 846 / try 0 / try failed 0; locked GPU waits 0 / 0 ms [hooksync] 1271 pending-write syncs waited 5512 ms (10 s); read bytes after the wait: unchanged 0 (target open 0, in flight unsignaled 0, signaled 0), changed 423; stores 0, unchecked 848; targets: 1237 open, 0 already signaled, 2651 batches finished; noted range: <=64K 423 <=1M 848; access: <=64K 423 <=1M 848; top by wait (queue packet site frames: count/ms, unchanged open/unsignaled/signaled, changed, stores, avg range/access): [0x0 DRAW_INDEX_2 unknown +0x0/+0x0/+0x0/+0x0/+0x0/+0x0: 1271/5512ms u0/0/0 c423 s0 139K/139K] [draw] driver phases (10 s, 63945 draw packets, 63945 drawn, 5954 captures), us per packet: prologue 0.4 precheck 1.0 decode 1.3 program prepare 0.6 capture 0.6 capture hook waits 0.0 recompile 0.6 rect-list 0.0 vectors 1.9 key/lookup/validate 7.1 validate GPU wait 0.0 lock wait 49.7 labels 0.0 Graphics::Draw 0.0 skipped 0.0 epilogue 0.6, total 63.9 (4083.8 ms; Graphics::Draw 0.0 ms, skipped 0.0 ms) [guestmem] read 1146579 calls 6447 MiB 0.9 s compare 35 calls 4 MiB 0.0 s write 18857 calls 2316 MiB 1.0 s write-changed 0 calls 0 MiB 0.0 s collect 507356 calls 687239 MiB 4.5 s verify 6361439 calls 126534 MiB 0.9 s query 6154 calls 0 MiB 0.1 s collect-memo hits 3947183, collect epochs 27560 collect-dirty 264091 tracker waits 1039 / 6291229 ``` </details> Summary line of the trace run (no profiler): ```json {"commit":"0c4816f6119e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_THREAD_PRIORITY":"high","APS5_TRACE_SECONDS":"90:20"},"gpu":"AMD Radeon Graphics","driver":"AMD proprietary driver 25.10.20.01 (LLPC)","os":"Windows 10.0.26100","resolution":"1920x1080","window":{"spec":"seconds 90:20","first_present":5620,"ms":20003.059},"presents":906,"frame_ms":{"p50":22.061,"p90":22.812,"p99":23.258,"max":23.637},"gpu_busy_ms_per_present":14.563,"worker_busy_pct":{"queue worker 0x0":98.792},"top_phases_ms_per_frame":{"Driver.Packet":21.787,"Driver.Packet.device_lock":9.602,"Driver.Packet.draw":8.813,"Driver.Draw":8.742,"Driver.Draw.draw_enqueued":6.876,"Driver.Present":3.671,"Driver.Packet.dispatch":2.054,"Driver.Present.gpu_mutex_wait":1.752},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":15.254,"events_lost":82203,"totals_full":false}},"trace":"aps5-trace-0c4816f6119e-896.json.gz"} ``` I can attach the trace (2.3 MB) and the full profile log if they help.
keravyn-ops commented 2026-10-15 17:05:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-15T17:05:23Z.


Follow-up: the GPU waits under the lock come from the HTILE read in storeBackClearedHtile

All pending-write syncs in the profile above come from one caller. [recorder] lists a single top sync site, pending-write@+0x1be2a9, which resolves to FlushForAccess (against my local build of the same commit), and [hooksync] charges all 1271 per 10 s to queue 0 DRAW_INDEX_2. The [guestmem] read callers of that run put the matching reads in DepthSurfaceView (+0x12c5, about 1,500 per 10 s, with its writes at +0x17db). That is the GuestMemory::Read of the HTILE words in storeBackClearedHtile (DepthSurface.cpp), inlined.

The title clears its depth targets with buffer fill kernels (fill HLE in [packets], about 300 per second), which are recorded as GPU fills and noted through NoteDepthMetadataFill. At the next bind of the target, storeBackClearedHtile finds a pending write over the HTILE and reads the words on the CPU. The hook then submits the batch and waits for it: 1237 of the 1271 targets were the open batch. Each wait takes about 4.3 ms, three times a frame, under the GPU mutex.

To confirm it, I ran a local experiment that makes storeBackClearedHtile return 0 while PendingWriteOverlaps(htileAddress, bytes) holds. This is not a fix, because it would miss a clear that the read is there to find.

main 0c4816f611 experiment
[hooksync] 1271 syncs, 5512 ms no line
locked GPU waits (untagged) 2161 / 5424 ms 0 / 0 ms
[draw] pipelined 94k commits at 101 µs 111k commits at 76.5 µs
fps, profiler on 42-44 51-53
fps, profiler off 44-46 58-70 (2 runs)

The frames dumped at the bench look the same.

A fix along the lines of the DCC key path (KeysAfterPendingWrites / StoreUncompressedOnGpu) looks possible: work out the HTILE words from the pending fills and store the expanded words as a GPU fill recorded behind them, instead of reading. VulkanDevice::FillBuffer notes only byte-uniform patterns today, so the notes would also need the 32-bit word. I'm trying that locally and will open a PR if it holds up, unless someone closer to this code would rather take it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6197748634 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6045#issuecomment-6197748634). Originally posted by [keravyn-ops](https://github.com/keravyn-ops) on 2026-10-15T17:05:23Z. --- **Follow-up: the GPU waits under the lock come from the HTILE read in `storeBackClearedHtile`** All pending-write syncs in the profile above come from one caller. `[recorder]` lists a single top sync site, `pending-write@+0x1be2a9`, which resolves to `FlushForAccess` (against my local build of the same commit), and `[hooksync]` charges all 1271 per 10 s to queue 0 `DRAW_INDEX_2`. The `[guestmem]` read callers of that run put the matching reads in `DepthSurfaceView` (+0x12c5, about 1,500 per 10 s, with its writes at +0x17db). That is the `GuestMemory::Read` of the HTILE words in `storeBackClearedHtile` (DepthSurface.cpp), inlined. The title clears its depth targets with buffer fill kernels (`fill HLE` in `[packets]`, about 300 per second), which are recorded as GPU fills and noted through `NoteDepthMetadataFill`. At the next bind of the target, `storeBackClearedHtile` finds a pending write over the HTILE and reads the words on the CPU. The hook then submits the batch and waits for it: 1237 of the 1271 targets were the open batch. Each wait takes about 4.3 ms, three times a frame, under the GPU mutex. To confirm it, I ran a local experiment that makes `storeBackClearedHtile` return 0 while `PendingWriteOverlaps(htileAddress, bytes)` holds. This is not a fix, because it would miss a clear that the read is there to find. | | `main` 0c4816f611 | experiment | |---|---|---| | `[hooksync]` | 1271 syncs, 5512 ms | no line | | `locked GPU waits` (untagged) | 2161 / 5424 ms | 0 / 0 ms | | `[draw] pipelined` | 94k commits at 101 µs | 111k commits at 76.5 µs | | fps, profiler on | 42-44 | 51-53 | | fps, profiler off | 44-46 | 58-70 (2 runs) | The frames dumped at the bench look the same. A fix along the lines of the DCC key path (`KeysAfterPendingWrites` / `StoreUncompressedOnGpu`) looks possible: work out the HTILE words from the pending fills and store the expanded words as a GPU fill recorded behind them, instead of reading. `VulkanDevice::FillBuffer` notes only byte-uniform patterns today, so the notes would also need the 32-bit word. I'm trying that locally and will open a PR if it holds up, unless someone closer to this code would rather take it.
Sign in to join this conversation.
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#6045
No description provided.