perf(libc,agc): skip never-written guest pages in Windows heap mirror zero scans #15967

Merged
sktharunbalaji13-cmd merged 3 commits from upstream-pr/15967 into main 2026-11-09 19:57:51 +00:00
sktharunbalaji13-cmd commented 2026-11-05 04:01:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sktharunbalaji13-cmd on 2026-11-05T04:01:05Z.


What

On Windows, the heap mirror zero scans (GuestNonzeroBlocks, GuestBytesZero in ResidentMirror.cpp) read every page of their range, because Windows has no /proc/self/pagemap to skip unpopulated pages the way possiblyNonzero does on Linux. Reading a committed page that was never written makes Windows allocate a physical zero page for it, so a scan over a large, mostly empty heap fills the RAM by itself.

  • The Windows guest arena (WindowsMappings.hpp) keeps a bitmap of the 4 KiB pages it committed fresh under a write watch (Commit with write watch, commitResident) that nothing has written since. Bits are cleared for every page a GetWriteWatch call reports (all calls go through one wrapper), atomically with the reset that replaced ResetWriteWatch where bits remain, and on reset, demote, evict, restored saved content, host writes and host imports (GPU writes through an import are not seen by the write watch). GuestArenaKnownZero_nid_no_patch reports the pages of a range that are still known zero, after a non-resetting GetWriteWatch of the range and taking the arena lock one 2 MiB chunk at a time.
  • possiblyNonzero and GuestBytesZero on Windows skip those pages.
  • On Windows the first read of such a page also sets its write-watch bit (measured: commit 16 pages with MEM_WRITE_WATCH, read pages 0 and 5, GetWriteWatch reports 0 and 5). The old scans read everything early, so that report was consumed before anyone cared. With the scans skipping those pages, the first read could happen after a storage image took its layer generation and then pass for a CPU store, so the flush hook's CPU-kept fast path dropped a GPU result (agc_driver_resident_heap_mirror, StorageImageTests). A reported page that is still known zero and still reads as zero (checked with ReadProcessMemory, only when the report is complete) is therefore no longer reported: its bytes have not changed since the commit.

Generic behaviour: nothing depends on a title, address or size.

Tested

Windows 11 26200, RTX 4060 Laptop GPU (8 GB), NVIDIA driver 617.42, 16 GB RAM, MinGW GCC (winlibs) Release, on main 0540ef0ef2 and on this branch, same machine:

  • New tests in core/libs/tests/WindowsWriteWatch.cpp (CheckKnownZeroPrivate, CheckKnownZeroResident, CheckKnownZeroShared, CheckKnownZeroFirstReads): fresh commits are known zero and clipped to the query, CPU stores, resetting/fresh/armed collects, host write windows, host imports, resets, an evict plus remap with restored bytes, memory without a write watch and shared memory; a first read or a zero store of a fresh page is not collected as a write while a real store is.
  • New test StorageImageZeroStoreTests in ResidentHeapMirror.cpp (review follow-up): an image store into a never-written block, a CPU store of 0, then a read must return 0. It fails without the GPU-write forgetting (the GPU value 0x12345678 wins) and passes with it. Every recorded GPU write (pending writes, fills, label stores, storage image layers, MarkWritten/MarkPossiblyWritten) forgets the range, and a storage image upload reads its still known-zero pages before taking its write generation.
  • ctest -R "windows_write_watch|agc_driver_resident_heap_mirror|heap_mirror|agc_write_tracking$" with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: 12/12 pass (agc_driver_resident_heap_mirror failed with the first version of this change and passes now).
  • 41 more suites around write tracking, imports and guest memory (host_import_*, guest_memory*, guest_owned_memory*, committed_read_mapping, copied_writer_*, linear_target_*, private_collect, write_watch_coverage, storage_write_back_*, read_only_lease_writer, partially_resident_snapshot, copy_guest_bytes): pass, except agc_driver_direct_write_completion, which fails the same way on main on this machine (3 of 3 runs, "the completion of a buffer write dropped image results recorded after it").
  • VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation runs of the focused tests: the 12 focused tests above on main and on this branch: no VUID- errors in either log, and neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS.
  • Ghost of Tsushima Director's Cut (PPSA02225), boot to the PlayStation Studios intro, back-to-back runs on the same machine:

tools/trace_digest.py summary lines, APS5_TRACE_SECONDS=0:40, same machine and scene, back-to-back runs (APS5_SKIP_REFUSED_DRAWS=1 APS5_PROFILE_DRAW=1):

main 0540ef0ef2ec: seconds 0:40 from present 0: 206 presents, frame p50 16.9 / p90 87.8 / p99 3326.6 / max 18738.7 ms, GPU busy 19.4 ms per present
this branch d28560cdca1a: seconds 0:40 from present 0: 310 presents, frame p50 17.8 / p90 414.3 / p99 1017.9 / max 5108.1 ms, GPU busy 24.1 ms per present

Traces: main, this branch (summaries: main, this branch). Both traces lost events once their buffers filled (about 35-38 s).

aps5-summary.jsonl lines of the two captures:

main 0540ef0ef2:

{"commit":"0540ef0ef2ec","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":41661.251},"presents":206,"frame_ms":{"p50":16.941,"p90":87.768,"p99":3326.594,"max":18738.701},"gpu_busy_ms_per_present":19.443,"worker_busy_pct":{"queue worker 0x0":68.571,"queue worker 0x40":0.108,"queue worker 0x20":43.126,"queue worker 0x48":2.304,"queue worker 0x38":58.010,"queue worker 0x52":8.212,"queue worker 0x30":11.413},"top_phases_ms_per_frame":{"Driver.Packet":386.779,"Driver.Packet.memory_wait":221.979,"Driver.Packet.dispatch":153.109,"Driver.Dispatch":143.336,"Vulkan.Dispatch":102.638,"Vulkan.Dispatch.shader_resources":101.679,"Shader.Register":24.634,"Driver.Dispatch.prepared_invocation":12.667},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":38.372,"events_lost":29304,"totals_full":false}},"trace":"aps5-trace-0540ef0ef2ec-24556.json.gz"}

this branch d28560cdca1a:

{"commit":"d28560cdca1a","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":40110.376},"presents":310,"frame_ms":{"p50":17.756,"p90":414.348,"p99":1017.909,"max":5108.052},"gpu_busy_ms_per_present":24.137,"worker_busy_pct":{"queue worker 0x0":64.681,"queue worker 0x40":0.685,"queue worker 0x20":31.676,"queue worker 0x48":3.541,"queue worker 0x38":46.533,"queue worker 0x52":4.772,"queue worker 0x30":7.795},"top_phases_ms_per_frame":{"Driver.Packet":205.300,"Driver.Packet.memory_wait":103.823,"Driver.Packet.dispatch":89.295,"Driver.Dispatch":80.776,"Vulkan.Dispatch":53.573,"Vulkan.Dispatch.shader_resources":52.561,"Shader.Register":16.180,"Recorder.Sync":10.411},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":34.843,"events_lost":35178,"totals_full":false}},"trace":"aps5-trace-d28560cdca1a-25536.json.gz"}
tools/trace_digest.py output, main

seconds 0:40 from present 0: 206 presents, frame p50 16.9 / p90 87.8 / p99 3326.6 / max 18738.7 ms, GPU busy 19.4 ms per present
NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit 0540ef0ef2, dropped: yes

{"commit":"0540ef0ef2ec","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":41661.251},"presents":206,"frame_ms":{"p50":16.941,"p90":87.768,"p99":3326.594,"max":18738.701},"gpu_busy_ms_per_present":19.443,"worker_busy_pct":{"queue worker 0x0":68.571,"queue worker 0x40":0.108,"queue worker 0x20":43.126,"queue worker 0x48":2.304,"queue worker 0x38":58.01,"queue worker 0x52":8.212,"queue worker 0x30":11.413},"top_phases_ms_per_frame":{"Driver.Packet":386.779,"Driver.Packet.memory_wait":221.979,"Driver.Packet.dispatch":153.109,"Driver.Dispatch":143.336,"Vulkan.Dispatch":102.638,"Vulkan.Dispatch.shader_resources":101.679,"Shader.Register":24.634,"Driver.Dispatch.prepared_invocation":12.667},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":38.372,"events_lost":29304,"totals_full":false}},"trace":"aps5-trace-0540ef0ef2ec-24556.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.

  • title: 29304 events lost; buffer full at 38372.5 ms

Slowest frames (largest slices inside each, inclusive)

  • present 94: 18738.7 ms at 4137 ms: Driver.WorkerWait (queue worker 0x48) 18690.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 18689.9, Driver.Packet (queue worker 0x0) 17892.8, Driver.Packet.dispatch (queue worker 0x0) 17217.2
  • present 205: 5339.5 ms at 36322 ms: Driver.WorkerWait (queue worker 0x0) 5326.7, Driver.WorkerWait (queue worker 0x48) 5326.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 5326.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5326.4
  • present 103: 3326.6 ms at 26876 ms: Driver.WorkerWait (queue worker 0x48) 3260.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 3260.8, Driver.Packet (queue worker 0x0) 3061.8, Driver.Packet (queue worker 0x38) 3044.9
  • present 8: 1093.0 ms at 1200 ms: Driver.WorkerWait (queue worker 0x20) 1087.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1087.3, Driver.WorkerWait (queue worker 0x48) 1079.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1079.0
  • present 138: 1032.6 ms at 34064 ms: Driver.WorkerWait (queue worker 0x20) 1026.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1026.2, Driver.WorkerWait (queue worker 0x48) 1019.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1019.6

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

  • present 94: 18738.7 ms at 4137 ms, persistence 18734.2 ms
  • present 205: 5339.5 ms at 36322 ms, persistence 5333.7 ms
  • present 103: 3326.6 ms at 26876 ms, persistence 3299.2 ms
  • present 8: 1093.0 ms at 1200 ms, persistence 1088.5 ms
  • present 4: 1030.9 ms at 132 ms, persistence 1026.2 ms
  • present 138: 1032.6 ms at 34064 ms, persistence 1019.6 ms
  • present 76: 386.6 ms at 3469 ms, persistence 372.9 ms
  • present 0: 87.8 ms at 0 ms, persistence 76.4 ms
  • present 71: 81.3 ms at 3336 ms, persistence 68.9 ms
  • present 125: 71.8 ms at 33765 ms, persistence 61.6 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 13.2 (7 %) 6.9 (3 %) 182.1 0.1 Shader.Register 8.9, Shader.ResolveAbi 3.7
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
queue worker 0x0 125.1 (62 %) 76.5 (38 %) 0.7 1.0 Driver.Packet 138.0, Driver.EndSubmission 0.3
queue worker 0x40 0.2 (0 %) 0.0 (0 %) 202.0 0.0 Driver.Packet 0.2, Driver.EndSubmission 0.0
queue worker 0x20 0.5 (0 %) 201.6 (100 %) 0.1 0.1 Driver.Packet 86.8, Driver.EndSubmission 0.4
draw committer 7.4 (4 %) 2.0 (1 %) 192.8 0.1 Graphics.Draw 5.4, Recorder.Submit 1.2
queue worker 0x48 2.0 (1 %) 200.1 (99 %) 0.2 0.3 Driver.Packet 4.4, Driver.EndSubmission 0.2
presenter 6.4 (3 %) 4.0 (2 %) 191.8 0.1 VideoOut.Flip 10.3, Driver.Present 0.1
queue worker 0x38 17.7 (9 %) 120.0 (59 %) 64.5 0.1 Driver.Packet 117.2, Driver.EndSubmission 0.1
queue worker 0x52 1.3 (1 %) 26.6 (13 %) 174.3 0.0 Driver.Packet 16.6, Driver.EndSubmission 0.0
title 0.2 (0 %) 0.0 (0 %) 202.0 0.0 Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1
title 0.2 (0 %) 0.0 (0 %) 202.0 0.0 Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1
title 0.2 (0 %) 0.0 (0 %) 202.0 0.0 Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1
queue worker 0x30 3.7 (2 %) 26.1 (13 %) 172.4 0.0 Driver.Packet 23.1, Driver.EndSubmission 0.0
title 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 202.2 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
gpu 19.3 (10 %) 0.0 (0 %) 183.0 0.0 batch 19.3

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 414.1, Driver.WorkerWait.idle_and_completion_poll 413.9, Driver.Packet 386.4, Driver.Packet.memory_wait 222.0, Driver.Packet.dispatch 153.1, Driver.Dispatch 143.3, Vulkan.Dispatch 102.6, Vulkan.Dispatch.shader_resources 101.7, batch 19.3, Driver.Dispatch.prepared_invocation 12.7

Longest waits

  • Driver.WorkerWait (queue worker 0x48) 17860.8 ms at 5015 ms, present 94
  • Driver.Packet.memory_wait (queue worker 0x38) 12939.5 ms at 5014 ms, present 94
  • Driver.Packet.memory_wait (queue worker 0x20) 12793.9 ms at 5011 ms, present 94
  • Driver.WorkerWait (queue worker 0x20) 5329.5 ms at 36318 ms, present 204
  • Driver.WorkerWait (queue worker 0x48) 5327.4 ms at 36321 ms, present 204
  • Driver.WorkerWait (queue worker 0x0) 5326.4 ms at 36322 ms, present 204
  • Driver.WorkerWait (queue worker 0x20) 5110.7 ms at 17807 ms, present 94
  • Driver.WorkerWait (queue worker 0x48) 3028.8 ms at 27201 ms, present 103
  • Driver.Packet.memory_wait (queue worker 0x38) 2178.8 ms at 27136 ms, present 103
  • Driver.Packet.memory_wait (queue worker 0x20) 2103.7 ms at 27137 ms, present 103

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

  • batch 720: 333.0 ms at 17526 ms, present 94: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12213.3, Driver.Packet.dispatch (queue worker 0x0) 12212.2, Driver.Dispatch (queue worker 0x0) 12209.0, Vulkan.Dispatch (queue worker 0x0) 11951.0
  • batch 1244: 108.2 ms at 29930 ms, present 103: GPU no ranges; recorded by GpuMutex.wait.end (draw committer) 75.5, Graphics.Draw (draw committer) 3.6, Graphics.Draw.draw_and_resource_release (draw committer) 3.4, Recorder.Submit (draw committer) 0.5
  • batch 719: 95.8 ms at 9212 ms, present 94: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 244.7, Driver.Packet.dispatch (queue worker 0x0) 244.7, Driver.Dispatch (queue worker 0x0) 244.7, Vulkan.Dispatch (queue worker 0x0) 127.0
  • batch 758: 79.6 ms at 22055 ms, present 94: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 81.0, Graphics.Wait (queue worker 0x0) 1.1, Graphics.Wait.fence_wait (queue worker 0x0) 1.1, Recorder.Submit (queue worker 0x0) 0.2
  • batch 1196: 69.2 ms at 29078 ms, present 103: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 70.7, Driver.Dispatch.capture_resources (queue worker 0x0) 43.4, Resources.Prepare (queue worker 0x0) 13.3, Driver.Dispatch.materialize (queue worker 0x0) 3.0
tools/trace_digest.py output, this branch

seconds 0:40 from present 0: 310 presents, frame p50 17.8 / p90 414.3 / p99 1017.9 / max 5108.1 ms, GPU busy 24.1 ms per present
NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit d28560cdca1a, dropped: yes

{"commit":"d28560cdca1a","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":40110.376},"presents":310,"frame_ms":{"p50":17.756,"p90":414.348,"p99":1017.909,"max":5108.052},"gpu_busy_ms_per_present":24.137,"worker_busy_pct":{"queue worker 0x0":64.681,"queue worker 0x40":0.685,"queue worker 0x20":31.676,"queue worker 0x48":3.541,"queue worker 0x38":46.533,"queue worker 0x52":4.772,"queue worker 0x30":7.795},"top_phases_ms_per_frame":{"Driver.Packet":205.3,"Driver.Packet.memory_wait":103.823,"Driver.Packet.dispatch":89.295,"Driver.Dispatch":80.776,"Vulkan.Dispatch":53.573,"Vulkan.Dispatch.shader_resources":52.561,"Shader.Register":16.18,"Recorder.Sync":10.411},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":34.843,"events_lost":35178,"totals_full":false}},"trace":"aps5-trace-d28560cdca1a-25536.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.

  • title: 35178 events lost; buffer full at 34843.4 ms

Slowest frames (largest slices inside each, inclusive)

  • present 90: 5108.1 ms at 3882 ms: Driver.WorkerWait (queue worker 0x48) 5066.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 5066.3, Driver.Packet (queue worker 0x0) 4968.5, Driver.Packet.dispatch (queue worker 0x0) 4836.2
  • present 237: 4883.2 ms at 32931 ms: Driver.WorkerWait (queue worker 0x40) 4883.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x40) 4883.2, Driver.WorkerWait (queue worker 0x20) 4883.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 4882.9
  • present 131: 1490.4 ms at 25685 ms: Driver.Packet (queue worker 0x0) 1433.2, Driver.Packet (queue worker 0x38) 1425.8, Driver.WorkerWait (queue worker 0x48) 1416.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1416.0
  • present 8: 1017.9 ms at 1161 ms: Driver.WorkerWait (queue worker 0x20) 1007.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1007.8, Driver.WorkerWait (queue worker 0x48) 995.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 995.4
  • present 4: 1017.7 ms at 109 ms: Driver.WorkerWait (queue worker 0x20) 1016.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1016.5, Driver.WorkerWait (queue worker 0x48) 1013.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1012.9

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

  • present 90: 5108.1 ms at 3882 ms, persistence 5104.5 ms
  • present 237: 4883.2 ms at 32931 ms, persistence 4879.6 ms
  • present 131: 1490.4 ms at 25685 ms, persistence 1463.0 ms
  • present 8: 1017.9 ms at 1161 ms, persistence 1013.4 ms
  • present 4: 1017.7 ms at 109 ms, persistence 1013.0 ms
  • present 163: 905.2 ms at 30678 ms, persistence 892.1 ms
  • present 309: 333.7 ms at 39777 ms, persistence 318.3 ms
  • present 73: 316.7 ms at 3313 ms, persistence 308.9 ms
  • present 290: 266.3 ms at 39038 ms, persistence 248.5 ms
  • present 93: 562.0 ms at 10173 ms, persistence 81.5 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 6.0 (5 %) 4.0 (3 %) 119.4 0.1 Shader.Register 5.5, Shader.ResolveAbi 0.4
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
shader prepare 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Vulkan.GraphicsPipelinePrebuild 0.0
queue worker 0x0 71.7 (55 %) 56.9 (44 %) 0.8 1.4 Driver.Packet 82.8, Driver.EndSubmission 0.4
queue worker 0x40 0.9 (1 %) 29.1 (23 %) 99.4 0.1 Driver.Packet 0.9, Driver.EndSubmission 0.0
queue worker 0x20 1.4 (1 %) 127.6 (99 %) 0.4 0.1 Driver.Packet 40.5, Driver.EndSubmission 0.4
queue worker 0x48 1.8 (1 %) 127.5 (99 %) 0.1 0.3 Driver.Packet 4.3, Driver.EndSubmission 0.2
draw committer 6.1 (5 %) 2.1 (2 %) 121.2 0.1 Graphics.Draw 2.9, Recorder.Submit 1.3
presenter 9.9 (8 %) 0.2 (0 %) 119.2 0.1 VideoOut.Flip 10.2, Driver.Present 0.0
queue worker 0x38 12.8 (10 %) 71.1 (55 %) 45.5 0.1 Driver.Packet 60.0, Driver.EndSubmission 0.1
queue worker 0x52 0.4 (0 %) 11.7 (9 %) 117.3 0.0 Driver.Packet 6.2, Driver.EndSubmission 0.0
title 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
queue worker 0x30 1.6 (1 %) 12.1 (9 %) 115.7 0.0 Driver.Packet 10.0, Driver.EndSubmission 0.1
title 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 129.4 0.0 Shader.ResolveGraphicsStagesAbi 0.0
gpu 24.2 (19 %) 0.0 (0 %) 105.2 0.0 batch 24.2

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 320.5, Driver.WorkerWait.idle_and_completion_poll 320.2, Driver.Packet 204.7, Driver.Packet.memory_wait 103.8, Driver.Packet.dispatch 89.3, Driver.Dispatch 80.6, Vulkan.Dispatch 53.5, Vulkan.Dispatch.shader_resources 52.5, batch 24.2, Recorder.Sync 10.4

Longest waits

  • Driver.WorkerWait (queue worker 0x40) 7346.6 ms at 30484 ms, present 151
  • Driver.WorkerWait (queue worker 0x48) 4934.5 ms at 4058 ms, present 90
  • Driver.WorkerWait (queue worker 0x20) 4879.5 ms at 32927 ms, present 236
  • Driver.WorkerWait (queue worker 0x48) 4878.0 ms at 32929 ms, present 236
  • Driver.WorkerWait (queue worker 0x0) 4876.6 ms at 32931 ms, present 236
  • Driver.Packet.memory_wait (queue worker 0x38) 3225.8 ms at 4053 ms, present 90
  • Driver.Packet.memory_wait (queue worker 0x20) 3184.3 ms at 4052 ms, present 90
  • Driver.WorkerWait (queue worker 0x20) 1758.4 ms at 7236 ms, present 90
  • Driver.WorkerWait (queue worker 0x48) 1389.8 ms at 25812 ms, present 131
  • Driver.WorkerWait (queue worker 0x20) 1019.0 ms at 103 ms, present 3

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

  • batch 690: 59.3 ms at 7221 ms, present 90: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 2968.6, Driver.Packet.dispatch (queue worker 0x0) 2968.6, Driver.Dispatch (queue worker 0x0) 2968.6, Vulkan.Dispatch (queue worker 0x0) 2806.5
  • batch 4836: 35.1 ms at 40051 ms, present 309: GPU no ranges; recorded by Driver.Packet (queue worker 0x20) 104.4, Driver.Packet.dispatch (queue worker 0x20) 104.3, Driver.Dispatch (queue worker 0x20) 104.3, Driver.Dispatch.materialize (queue worker 0x20) 39.6
  • batch 2989: 34.8 ms at 27610 ms, present 132: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.6, Graphics.Draw.draw_and_resource_release (draw committer) 2.5, Recorder.Submit (draw committer) 0.4
  • batch 3319: 32.4 ms at 30078 ms, present 137: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.4, Graphics.Draw.draw_and_resource_release (draw committer) 2.3, Recorder.Submit (draw committer) 0.3
  • batch 3120: 31.5 ms at 28646 ms, present 134: GPU no ranges; recorded by Graphics.Draw (draw committer) 7.6, Graphics.Draw.draw_and_resource_release (draw committer) 7.6, Recorder.Submit (draw committer) 0.3, Recorder.Reap (draw committer) 0.1

From the same two runs (APS5_PROFILE_DRAW and the process counters):

main this branch
64 KiB blocks zero-scanned by the first address-based build 70,067 10
longest stall of the frame counter 18 s (12-30 s) 4 s (12-16 s)
presents by 40 s 110 238
lowest free RAM 4 MB 67 MB
PlayStation logo frames captured (4 fps window capture) 0 24

In the main run the game's working set rose from 3.2 to 8.2 GB between 10 and 14 s, during that first build, while its commit stayed at 11.8-12.1 GB: the scan allocating zero pages. A separate check on the same machine: reading 1 GiB of committed, never-written memory adds 1024 MiB to the working set.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA02225 #4461 (the intro freeze and RAM exhaustion on 16 GB machines, #5166)
  • GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU, driver 617.42, Windows 11 26200
  • AI-assisted: yes

tools/pr_overlap.py: #15900 also edits WindowsWriteWatch.cpp (a different test); 14 conflicting PRs share ResidentMirror.cpp, GuestArena.cpp or WindowsMappings.hpp and could not be compared automatically; none of them adds a known-zero query (checked by hand: #13809, #15295, #15296, #15900).

🤖 Generated with Claude Code, OpenCode, Command Code and Gemini

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5165907097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15967). Originally posted by [sktharunbalaji13-cmd](https://github.com/sktharunbalaji13-cmd) on 2026-11-05T04:01:05Z. --- ### What On Windows, the heap mirror zero scans (`GuestNonzeroBlocks`, `GuestBytesZero` in `ResidentMirror.cpp`) read every page of their range, because Windows has no `/proc/self/pagemap` to skip unpopulated pages the way `possiblyNonzero` does on Linux. Reading a committed page that was never written makes Windows allocate a physical zero page for it, so a scan over a large, mostly empty heap fills the RAM by itself. - The Windows guest arena (`WindowsMappings.hpp`) keeps a bitmap of the 4 KiB pages it committed fresh under a write watch (`Commit` with write watch, `commitResident`) that nothing has written since. Bits are cleared for every page a `GetWriteWatch` call reports (all calls go through one wrapper), atomically with the reset that replaced `ResetWriteWatch` where bits remain, and on `reset`, `demote`, `evict`, restored saved content, host writes and host imports (GPU writes through an import are not seen by the write watch). `GuestArenaKnownZero_nid_no_patch` reports the pages of a range that are still known zero, after a non-resetting `GetWriteWatch` of the range and taking the arena lock one 2 MiB chunk at a time. - `possiblyNonzero` and `GuestBytesZero` on Windows skip those pages. - On Windows the first *read* of such a page also sets its write-watch bit (measured: commit 16 pages with `MEM_WRITE_WATCH`, read pages 0 and 5, `GetWriteWatch` reports 0 and 5). The old scans read everything early, so that report was consumed before anyone cared. With the scans skipping those pages, the first read could happen after a storage image took its layer generation and then pass for a CPU store, so the flush hook's CPU-kept fast path dropped a GPU result (`agc_driver_resident_heap_mirror`, StorageImageTests). A reported page that is still known zero and still reads as zero (checked with `ReadProcessMemory`, only when the report is complete) is therefore no longer reported: its bytes have not changed since the commit. Generic behaviour: nothing depends on a title, address or size. ### Tested Windows 11 26200, RTX 4060 Laptop GPU (8 GB), NVIDIA driver 617.42, 16 GB RAM, MinGW GCC (winlibs) Release, on `main` 0540ef0ef2 and on this branch, same machine: - New tests in `core/libs/tests/WindowsWriteWatch.cpp` (`CheckKnownZeroPrivate`, `CheckKnownZeroResident`, `CheckKnownZeroShared`, `CheckKnownZeroFirstReads`): fresh commits are known zero and clipped to the query, CPU stores, resetting/fresh/armed collects, host write windows, host imports, resets, an evict plus remap with restored bytes, memory without a write watch and shared memory; a first read or a zero store of a fresh page is not collected as a write while a real store is. - New test `StorageImageZeroStoreTests` in `ResidentHeapMirror.cpp` (review follow-up): an image store into a never-written block, a CPU store of 0, then a read must return 0. It fails without the GPU-write forgetting (the GPU value `0x12345678` wins) and passes with it. Every recorded GPU write (pending writes, fills, label stores, storage image layers, `MarkWritten`/`MarkPossiblyWritten`) forgets the range, and a storage image upload reads its still known-zero pages before taking its write generation. - `ctest -R "windows_write_watch|agc_driver_resident_heap_mirror|heap_mirror|agc_write_tracking$"` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`: 12/12 pass (`agc_driver_resident_heap_mirror` failed with the first version of this change and passes now). - 41 more suites around write tracking, imports and guest memory (`host_import_*`, `guest_memory*`, `guest_owned_memory*`, `committed_read_mapping`, `copied_writer_*`, `linear_target_*`, `private_collect`, `write_watch_coverage`, `storage_write_back_*`, `read_only_lease_writer`, `partially_resident_snapshot`, `copy_guest_bytes`): pass, except `agc_driver_direct_write_completion`, which fails the same way on `main` on this machine (3 of 3 runs, "the completion of a buffer write dropped image results recorded after it"). - `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` runs of the focused tests: the 12 focused tests above on `main` and on this branch: no `VUID-` errors in either log, and neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`. - Ghost of Tsushima Director's Cut (PPSA02225), boot to the PlayStation Studios intro, back-to-back runs on the same machine: `tools/trace_digest.py` summary lines, `APS5_TRACE_SECONDS=0:40`, same machine and scene, back-to-back runs (`APS5_SKIP_REFUSED_DRAWS=1 APS5_PROFILE_DRAW=1`): ``` main 0540ef0ef2ec: seconds 0:40 from present 0: 206 presents, frame p50 16.9 / p90 87.8 / p99 3326.6 / max 18738.7 ms, GPU busy 19.4 ms per present this branch d28560cdca1a: seconds 0:40 from present 0: 310 presents, frame p50 17.8 / p90 414.3 / p99 1017.9 / max 5108.1 ms, GPU busy 24.1 ms per present ``` Traces: [main](https://github.com/sktharunbalaji13-cmd/AnyPS5/blob/evidence/got-ram-logo/ghost-of-tsushima/lowmem-2026-11-05/traces/main-aps5-trace-0540ef0ef2ec-24556.json.gz), [this branch](https://github.com/sktharunbalaji13-cmd/AnyPS5/blob/evidence/got-ram-logo/ghost-of-tsushima/lowmem-2026-11-05/traces/pr1b-aps5-trace-d28560cdca1a-25536.json.gz) (summaries: [main](https://github.com/sktharunbalaji13-cmd/AnyPS5/blob/evidence/got-ram-logo/ghost-of-tsushima/lowmem-2026-11-05/traces/main-aps5-summary.jsonl), [this branch](https://github.com/sktharunbalaji13-cmd/AnyPS5/blob/evidence/got-ram-logo/ghost-of-tsushima/lowmem-2026-11-05/traces/pr1b-aps5-summary.jsonl)). Both traces lost events once their buffers filled (about 35-38 s). `aps5-summary.jsonl` lines of the two captures: `main` 0540ef0ef2ec: ```json {"commit":"0540ef0ef2ec","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":41661.251},"presents":206,"frame_ms":{"p50":16.941,"p90":87.768,"p99":3326.594,"max":18738.701},"gpu_busy_ms_per_present":19.443,"worker_busy_pct":{"queue worker 0x0":68.571,"queue worker 0x40":0.108,"queue worker 0x20":43.126,"queue worker 0x48":2.304,"queue worker 0x38":58.010,"queue worker 0x52":8.212,"queue worker 0x30":11.413},"top_phases_ms_per_frame":{"Driver.Packet":386.779,"Driver.Packet.memory_wait":221.979,"Driver.Packet.dispatch":153.109,"Driver.Dispatch":143.336,"Vulkan.Dispatch":102.638,"Vulkan.Dispatch.shader_resources":101.679,"Shader.Register":24.634,"Driver.Dispatch.prepared_invocation":12.667},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":38.372,"events_lost":29304,"totals_full":false}},"trace":"aps5-trace-0540ef0ef2ec-24556.json.gz"} ``` this branch d28560cdca1a: ```json {"commit":"d28560cdca1a","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":40110.376},"presents":310,"frame_ms":{"p50":17.756,"p90":414.348,"p99":1017.909,"max":5108.052},"gpu_busy_ms_per_present":24.137,"worker_busy_pct":{"queue worker 0x0":64.681,"queue worker 0x40":0.685,"queue worker 0x20":31.676,"queue worker 0x48":3.541,"queue worker 0x38":46.533,"queue worker 0x52":4.772,"queue worker 0x30":7.795},"top_phases_ms_per_frame":{"Driver.Packet":205.300,"Driver.Packet.memory_wait":103.823,"Driver.Packet.dispatch":89.295,"Driver.Dispatch":80.776,"Vulkan.Dispatch":53.573,"Vulkan.Dispatch.shader_resources":52.561,"Shader.Register":16.180,"Recorder.Sync":10.411},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":34.843,"events_lost":35178,"totals_full":false}},"trace":"aps5-trace-d28560cdca1a-25536.json.gz"} ``` <details><summary><code>tools/trace_digest.py</code> output, <code>main</code></summary> **seconds 0:40** from present 0: 206 presents, frame p50 16.9 / p90 87.8 / p99 3326.6 / max 18738.7 ms, GPU busy 19.4 ms per present NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit 0540ef0ef2ec, dropped: yes ```json {"commit":"0540ef0ef2ec","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":41661.251},"presents":206,"frame_ms":{"p50":16.941,"p90":87.768,"p99":3326.594,"max":18738.701},"gpu_busy_ms_per_present":19.443,"worker_busy_pct":{"queue worker 0x0":68.571,"queue worker 0x40":0.108,"queue worker 0x20":43.126,"queue worker 0x48":2.304,"queue worker 0x38":58.01,"queue worker 0x52":8.212,"queue worker 0x30":11.413},"top_phases_ms_per_frame":{"Driver.Packet":386.779,"Driver.Packet.memory_wait":221.979,"Driver.Packet.dispatch":153.109,"Driver.Dispatch":143.336,"Vulkan.Dispatch":102.638,"Vulkan.Dispatch.shader_resources":101.679,"Shader.Register":24.634,"Driver.Dispatch.prepared_invocation":12.667},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":38.372,"events_lost":29304,"totals_full":false}},"trace":"aps5-trace-0540ef0ef2ec-24556.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. - title: 29304 events lost; buffer full at 38372.5 ms **Slowest frames** (largest slices inside each, inclusive) - present 94: 18738.7 ms at 4137 ms: Driver.WorkerWait (queue worker 0x48) 18690.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 18689.9, Driver.Packet (queue worker 0x0) 17892.8, Driver.Packet.dispatch (queue worker 0x0) 17217.2 - present 205: 5339.5 ms at 36322 ms: Driver.WorkerWait (queue worker 0x0) 5326.7, Driver.WorkerWait (queue worker 0x48) 5326.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 5326.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 5326.4 - present 103: 3326.6 ms at 26876 ms: Driver.WorkerWait (queue worker 0x48) 3260.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 3260.8, Driver.Packet (queue worker 0x0) 3061.8, Driver.Packet (queue worker 0x38) 3044.9 - present 8: 1093.0 ms at 1200 ms: Driver.WorkerWait (queue worker 0x20) 1087.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1087.3, Driver.WorkerWait (queue worker 0x48) 1079.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1079.0 - present 138: 1032.6 ms at 34064 ms: Driver.WorkerWait (queue worker 0x20) 1026.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1026.2, Driver.WorkerWait (queue worker 0x48) 1019.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1019.6 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 94: 18738.7 ms at 4137 ms, persistence 18734.2 ms - present 205: 5339.5 ms at 36322 ms, persistence 5333.7 ms - present 103: 3326.6 ms at 26876 ms, persistence 3299.2 ms - present 8: 1093.0 ms at 1200 ms, persistence 1088.5 ms - present 4: 1030.9 ms at 132 ms, persistence 1026.2 ms - present 138: 1032.6 ms at 34064 ms, persistence 1019.6 ms - present 76: 386.6 ms at 3469 ms, persistence 372.9 ms - present 0: 87.8 ms at 0 ms, persistence 76.4 ms - present 71: 81.3 ms at 3336 ms, persistence 68.9 ms - present 125: 71.8 ms at 33765 ms, persistence 61.6 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | title | 13.2 (7 %) | 6.9 (3 %) | 182.1 | 0.1 | Shader.Register 8.9, Shader.ResolveAbi 3.7 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | queue worker 0x0 | 125.1 (62 %) | 76.5 (38 %) | 0.7 | 1.0 | Driver.Packet 138.0, Driver.EndSubmission 0.3 | | queue worker 0x40 | 0.2 (0 %) | 0.0 (0 %) | 202.0 | 0.0 | Driver.Packet 0.2, Driver.EndSubmission 0.0 | | queue worker 0x20 | 0.5 (0 %) | 201.6 (100 %) | 0.1 | 0.1 | Driver.Packet 86.8, Driver.EndSubmission 0.4 | | draw committer | 7.4 (4 %) | 2.0 (1 %) | 192.8 | 0.1 | Graphics.Draw 5.4, Recorder.Submit 1.2 | | queue worker 0x48 | 2.0 (1 %) | 200.1 (99 %) | 0.2 | 0.3 | Driver.Packet 4.4, Driver.EndSubmission 0.2 | | presenter | 6.4 (3 %) | 4.0 (2 %) | 191.8 | 0.1 | VideoOut.Flip 10.3, Driver.Present 0.1 | | queue worker 0x38 | 17.7 (9 %) | 120.0 (59 %) | 64.5 | 0.1 | Driver.Packet 117.2, Driver.EndSubmission 0.1 | | queue worker 0x52 | 1.3 (1 %) | 26.6 (13 %) | 174.3 | 0.0 | Driver.Packet 16.6, Driver.EndSubmission 0.0 | | title | 0.2 (0 %) | 0.0 (0 %) | 202.0 | 0.0 | Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 0.2 (0 %) | 0.0 (0 %) | 202.0 | 0.0 | Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 0.2 (0 %) | 0.0 (0 %) | 202.0 | 0.0 | Shader.ResolveAbi 0.2, Shader.ResolveGraphicsStagesAbi 0.1 | | queue worker 0x30 | 3.7 (2 %) | 26.1 (13 %) | 172.4 | 0.0 | Driver.Packet 23.1, Driver.EndSubmission 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 202.2 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | gpu | 19.3 (10 %) | 0.0 (0 %) | 183.0 | 0.0 | batch 19.3 | **Largest slices** (ms per frame, inclusive, all threads): Driver.WorkerWait 414.1, Driver.WorkerWait.idle_and_completion_poll 413.9, Driver.Packet 386.4, Driver.Packet.memory_wait 222.0, Driver.Packet.dispatch 153.1, Driver.Dispatch 143.3, Vulkan.Dispatch 102.6, Vulkan.Dispatch.shader_resources 101.7, batch 19.3, Driver.Dispatch.prepared_invocation 12.7 **Longest waits** - Driver.WorkerWait (queue worker 0x48) 17860.8 ms at 5015 ms, present 94 - Driver.Packet.memory_wait (queue worker 0x38) 12939.5 ms at 5014 ms, present 94 - Driver.Packet.memory_wait (queue worker 0x20) 12793.9 ms at 5011 ms, present 94 - Driver.WorkerWait (queue worker 0x20) 5329.5 ms at 36318 ms, present 204 - Driver.WorkerWait (queue worker 0x48) 5327.4 ms at 36321 ms, present 204 - Driver.WorkerWait (queue worker 0x0) 5326.4 ms at 36322 ms, present 204 - Driver.WorkerWait (queue worker 0x20) 5110.7 ms at 17807 ms, present 94 - Driver.WorkerWait (queue worker 0x48) 3028.8 ms at 27201 ms, present 103 - Driver.Packet.memory_wait (queue worker 0x38) 2178.8 ms at 27136 ms, present 103 - Driver.Packet.memory_wait (queue worker 0x20) 2103.7 ms at 27137 ms, present 103 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 720: 333.0 ms at 17526 ms, present 94: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12213.3, Driver.Packet.dispatch (queue worker 0x0) 12212.2, Driver.Dispatch (queue worker 0x0) 12209.0, Vulkan.Dispatch (queue worker 0x0) 11951.0 - batch 1244: 108.2 ms at 29930 ms, present 103: GPU no ranges; recorded by GpuMutex.wait.end (draw committer) 75.5, Graphics.Draw (draw committer) 3.6, Graphics.Draw.draw_and_resource_release (draw committer) 3.4, Recorder.Submit (draw committer) 0.5 - batch 719: 95.8 ms at 9212 ms, present 94: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 244.7, Driver.Packet.dispatch (queue worker 0x0) 244.7, Driver.Dispatch (queue worker 0x0) 244.7, Vulkan.Dispatch (queue worker 0x0) 127.0 - batch 758: 79.6 ms at 22055 ms, present 94: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 81.0, Graphics.Wait (queue worker 0x0) 1.1, Graphics.Wait.fence_wait (queue worker 0x0) 1.1, Recorder.Submit (queue worker 0x0) 0.2 - batch 1196: 69.2 ms at 29078 ms, present 103: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 70.7, Driver.Dispatch.capture_resources (queue worker 0x0) 43.4, Resources.Prepare (queue worker 0x0) 13.3, Driver.Dispatch.materialize (queue worker 0x0) 3.0 </details> <details><summary><code>tools/trace_digest.py</code> output, this branch</summary> **seconds 0:40** from present 0: 310 presents, frame p50 17.8 / p90 414.3 / p99 1017.9 / max 5108.1 ms, GPU busy 24.1 ms per present NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit d28560cdca1a, dropped: yes ```json {"commit":"d28560cdca1a","dirty":false,"env":{"APS5_PROFILE_DRAW":"1","APS5_SKIP_REFUSED_DRAWS":"1","APS5_TRACE_SECONDS":"0:40"},"gpu":"NVIDIA GeForce RTX 4060 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 7 7840HS w/ Radeon 780M Graphics","cpu_threads":16,"memory_mib":15654,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 0:40","first_present":0,"ms":40110.376},"presents":310,"frame_ms":{"p50":17.756,"p90":414.348,"p99":1017.909,"max":5108.052},"gpu_busy_ms_per_present":24.137,"worker_busy_pct":{"queue worker 0x0":64.681,"queue worker 0x40":0.685,"queue worker 0x20":31.676,"queue worker 0x48":3.541,"queue worker 0x38":46.533,"queue worker 0x52":4.772,"queue worker 0x30":7.795},"top_phases_ms_per_frame":{"Driver.Packet":205.3,"Driver.Packet.memory_wait":103.823,"Driver.Packet.dispatch":89.295,"Driver.Dispatch":80.776,"Vulkan.Dispatch":53.573,"Vulkan.Dispatch.shader_resources":52.561,"Shader.Register":16.18,"Recorder.Sync":10.411},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":34.843,"events_lost":35178,"totals_full":false}},"trace":"aps5-trace-d28560cdca1a-25536.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. - title: 35178 events lost; buffer full at 34843.4 ms **Slowest frames** (largest slices inside each, inclusive) - present 90: 5108.1 ms at 3882 ms: Driver.WorkerWait (queue worker 0x48) 5066.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 5066.3, Driver.Packet (queue worker 0x0) 4968.5, Driver.Packet.dispatch (queue worker 0x0) 4836.2 - present 237: 4883.2 ms at 32931 ms: Driver.WorkerWait (queue worker 0x40) 4883.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x40) 4883.2, Driver.WorkerWait (queue worker 0x20) 4883.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 4882.9 - present 131: 1490.4 ms at 25685 ms: Driver.Packet (queue worker 0x0) 1433.2, Driver.Packet (queue worker 0x38) 1425.8, Driver.WorkerWait (queue worker 0x48) 1416.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1416.0 - present 8: 1017.9 ms at 1161 ms: Driver.WorkerWait (queue worker 0x20) 1007.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1007.8, Driver.WorkerWait (queue worker 0x48) 995.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 995.4 - present 4: 1017.7 ms at 109 ms: Driver.WorkerWait (queue worker 0x20) 1016.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x20) 1016.5, Driver.WorkerWait (queue worker 0x48) 1013.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 1012.9 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 90: 5108.1 ms at 3882 ms, persistence 5104.5 ms - present 237: 4883.2 ms at 32931 ms, persistence 4879.6 ms - present 131: 1490.4 ms at 25685 ms, persistence 1463.0 ms - present 8: 1017.9 ms at 1161 ms, persistence 1013.4 ms - present 4: 1017.7 ms at 109 ms, persistence 1013.0 ms - present 163: 905.2 ms at 30678 ms, persistence 892.1 ms - present 309: 333.7 ms at 39777 ms, persistence 318.3 ms - present 73: 316.7 ms at 3313 ms, persistence 308.9 ms - present 290: 266.3 ms at 39038 ms, persistence 248.5 ms - present 93: 562.0 ms at 10173 ms, persistence 81.5 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | title | 6.0 (5 %) | 4.0 (3 %) | 119.4 | 0.1 | Shader.Register 5.5, Shader.ResolveAbi 0.4 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | shader prepare | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.0 | | queue worker 0x0 | 71.7 (55 %) | 56.9 (44 %) | 0.8 | 1.4 | Driver.Packet 82.8, Driver.EndSubmission 0.4 | | queue worker 0x40 | 0.9 (1 %) | 29.1 (23 %) | 99.4 | 0.1 | Driver.Packet 0.9, Driver.EndSubmission 0.0 | | queue worker 0x20 | 1.4 (1 %) | 127.6 (99 %) | 0.4 | 0.1 | Driver.Packet 40.5, Driver.EndSubmission 0.4 | | queue worker 0x48 | 1.8 (1 %) | 127.5 (99 %) | 0.1 | 0.3 | Driver.Packet 4.3, Driver.EndSubmission 0.2 | | draw committer | 6.1 (5 %) | 2.1 (2 %) | 121.2 | 0.1 | Graphics.Draw 2.9, Recorder.Submit 1.3 | | presenter | 9.9 (8 %) | 0.2 (0 %) | 119.2 | 0.1 | VideoOut.Flip 10.2, Driver.Present 0.0 | | queue worker 0x38 | 12.8 (10 %) | 71.1 (55 %) | 45.5 | 0.1 | Driver.Packet 60.0, Driver.EndSubmission 0.1 | | queue worker 0x52 | 0.4 (0 %) | 11.7 (9 %) | 117.3 | 0.0 | Driver.Packet 6.2, Driver.EndSubmission 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | queue worker 0x30 | 1.6 (1 %) | 12.1 (9 %) | 115.7 | 0.0 | Driver.Packet 10.0, Driver.EndSubmission 0.1 | | title | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 129.4 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0 | | gpu | 24.2 (19 %) | 0.0 (0 %) | 105.2 | 0.0 | batch 24.2 | **Largest slices** (ms per frame, inclusive, all threads): Driver.WorkerWait 320.5, Driver.WorkerWait.idle_and_completion_poll 320.2, Driver.Packet 204.7, Driver.Packet.memory_wait 103.8, Driver.Packet.dispatch 89.3, Driver.Dispatch 80.6, Vulkan.Dispatch 53.5, Vulkan.Dispatch.shader_resources 52.5, batch 24.2, Recorder.Sync 10.4 **Longest waits** - Driver.WorkerWait (queue worker 0x40) 7346.6 ms at 30484 ms, present 151 - Driver.WorkerWait (queue worker 0x48) 4934.5 ms at 4058 ms, present 90 - Driver.WorkerWait (queue worker 0x20) 4879.5 ms at 32927 ms, present 236 - Driver.WorkerWait (queue worker 0x48) 4878.0 ms at 32929 ms, present 236 - Driver.WorkerWait (queue worker 0x0) 4876.6 ms at 32931 ms, present 236 - Driver.Packet.memory_wait (queue worker 0x38) 3225.8 ms at 4053 ms, present 90 - Driver.Packet.memory_wait (queue worker 0x20) 3184.3 ms at 4052 ms, present 90 - Driver.WorkerWait (queue worker 0x20) 1758.4 ms at 7236 ms, present 90 - Driver.WorkerWait (queue worker 0x48) 1389.8 ms at 25812 ms, present 131 - Driver.WorkerWait (queue worker 0x20) 1019.0 ms at 103 ms, present 3 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 690: 59.3 ms at 7221 ms, present 90: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 2968.6, Driver.Packet.dispatch (queue worker 0x0) 2968.6, Driver.Dispatch (queue worker 0x0) 2968.6, Vulkan.Dispatch (queue worker 0x0) 2806.5 - batch 4836: 35.1 ms at 40051 ms, present 309: GPU no ranges; recorded by Driver.Packet (queue worker 0x20) 104.4, Driver.Packet.dispatch (queue worker 0x20) 104.3, Driver.Dispatch (queue worker 0x20) 104.3, Driver.Dispatch.materialize (queue worker 0x20) 39.6 - batch 2989: 34.8 ms at 27610 ms, present 132: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.6, Graphics.Draw.draw_and_resource_release (draw committer) 2.5, Recorder.Submit (draw committer) 0.4 - batch 3319: 32.4 ms at 30078 ms, present 137: GPU no ranges; recorded by Graphics.Draw (draw committer) 2.4, Graphics.Draw.draw_and_resource_release (draw committer) 2.3, Recorder.Submit (draw committer) 0.3 - batch 3120: 31.5 ms at 28646 ms, present 134: GPU no ranges; recorded by Graphics.Draw (draw committer) 7.6, Graphics.Draw.draw_and_resource_release (draw committer) 7.6, Recorder.Submit (draw committer) 0.3, Recorder.Reap (draw committer) 0.1 </details> From the same two runs (`APS5_PROFILE_DRAW` and the process counters): | | main | this branch | |---|---|---| | 64 KiB blocks zero-scanned by the first address-based build | 70,067 | 10 | | longest stall of the frame counter | 18 s (12-30 s) | 4 s (12-16 s) | | presents by 40 s | 110 | 238 | | lowest free RAM | 4 MB | 67 MB | | PlayStation logo frames captured (4 fps window capture) | 0 | 24 | In the `main` run the game's working set rose from 3.2 to 8.2 GB between 10 and 14 s, during that first build, while its commit stayed at 11.8-12.1 GB: the scan allocating zero pages. A separate check on the same machine: reading 1 GiB of committed, never-written memory adds 1024 MiB to the working set. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA02225 #4461 (the intro freeze and RAM exhaustion on 16 GB machines, #5166) - [x] GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU, driver 617.42, Windows 11 26200 - [x] AI-assisted: yes `tools/pr_overlap.py`: #15900 also edits `WindowsWriteWatch.cpp` (a different test); 14 conflicting PRs share `ResidentMirror.cpp`, `GuestArena.cpp` or `WindowsMappings.hpp` and could not be compared automatically; none of them adds a known-zero query (checked by hand: #13809, #15295, #15296, #15900). 🤖 Generated with [Claude Code](https://claude.com/claude-code), [OpenCode](https://opencode.ai), [Command Code](https://commandcode.ai) and [Gemini](https://gemini.google.com)
gabichuuuuu commented 2026-11-08 15:48:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T15:48:39Z.

Review: COMMENTED


Ran e59f347f94 merged on main 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Khronos validation layer 1.4.368), ctest -R '^(agc_driver_resident_heap_mirror|windows_write_watch)' -V:

main change, 2 runs each
NVIDIA 3/3 3/3 twice
Intel 3/3 3/3 twice
  • The PR's WindowsWriteWatch.cpp uses WindowsMappings::KnownZero, which this PR adds, so there's no run of the tests without the change.
  • The layer was inserted in every test that opens a device (windows_write_watch, windows_write_watch_verify_direct open none). No log has was not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has a VUID-. To be sure validation messages reach these logs, the same layer with best practices on printed 28 BestPractices- warnings into an agc_driver_recorder log on each GPU.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5818523360 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15967#pullrequestreview-5818523360). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T15:48:39Z. **Review:** COMMENTED --- Ran `e59f347f94` merged on `main` 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Khronos validation layer 1.4.368), `ctest -R '^(agc_driver_resident_heap_mirror|windows_write_watch)' -V`: | | `main` | change, 2 runs each | |---|---|---| | NVIDIA | 3/3 | 3/3 twice | | Intel | 3/3 | 3/3 twice | - The PR's `WindowsWriteWatch.cpp` uses `WindowsMappings::KnownZero`, which this PR adds, so there's no run of the tests without the change. - The layer was inserted in every test that opens a device (`windows_write_watch`, `windows_write_watch_verify_direct` open none). No log has `was not found but was requested by env var VK_INSTANCE_LAYERS`, and no log on either side has a `VUID-`. To be sure validation messages reach these logs, the same layer with best practices on printed 28 `BestPractices-` warnings into an `agc_driver_recorder` log on each GPU. AI-assisted: yes.
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!15967
No description provided.