perf: GTA V Story, queue 0 spends a third of its time waiting for GPU writes it reads while preparing dispatches #5694
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T07:09:58Z.
Title and scene
PPSA04264 (GTA V), the Story prologue inside the bank, about 100 s after the first 3D frame. Window 3840x2160.
What is slow or what changed
Queue worker 0 is the critical path: it is busy 94 % of each frame, and the other queues mostly wait on it (
Driver.Packet.memory_wait). About a third of worker 0's time is spent waiting for the GPU while it prepares dispatches. That happens when the CPU reads guest memory that recorded GPU work is still writing. The GPU writes are real: the bytes read after the wait have almost always changed.Stack samples of worker 0 (
APS5_SAMPLE_WORKER, 8,967 samples over the 150 s of Story; menu and loading subtracted; symbolized withnm):Recorder::SyncThrough, all callers:ShaderMemory::page→GuestMemory::Read→FlushForAccess(17.7 %), andStorageTexture::compareUntracked(10.7 %)GpuMutexinsyncThroughUnlocked, plus about 15 % of fence waits in the NVIDIA driverrecordQueuedLabelsFromHookwaiting forGpuMutex, reached fromShaderMemory::pagereadsmemcmp/memcpy:EqualsCommittedinShaderResources::resolveImageTables(7.1 %, from #757's table check),compareUntracked(6.4 %),captureGuestBytes(2.9 %)The
[hooksync]lines (APS5_PROFILE_DRAW=1) come from a separate run of the same scene on the same stack, at 180 s:So it's about 210 pending-write syncs per 10 s, waiting 2 to 2.6 s in all. In 64-74 of the 66-76 checked cases, the bytes read after the wait had changed. Two kinds stand out:
DISPATCH_DIRECTon queue 0.capturesite): 5-10 syncs per 10 s on single 4 KiB pages cost 0.5-1.3 s. GTA's JobManager kernels write V# blocks on the GPU that later dispatches take their descriptors from (see #3055), so capturing those descriptors on the CPU has to wait for the producing batch.I'm not proposing a fix here. The capture-side waits look structural to me, since GTA builds descriptors on the GPU and AnyPS5 resolves them on the CPU before recording the dispatch. #1193 makes captures of pages with no pending GPU writes cheaper, but leaves these pages as they are.
Stack:
maind8888df9bplus #757 (4dcf657a2), fdfawef324's #448 port, #1186 and #1189, plus a local change that skips dispatches whose shader fails to compile; none did in this run.Summary lines
Traces
Digest
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 2815.9, Driver.Packet.memory_wait 1472.2, Driver.Packet.dispatch 1044.2, Driver.Dispatch 1027.8, Driver.WorkerWait 881.6, Driver.WorkerWait.idle_and_completion_poll 881.6, Vulkan.Dispatch 579.3, Vulkan.Dispatch.shader_resources 566.7, Resources.Complete 564.8, Driver.Packet.draw 296.0
Capture
APS5_SAMPLE_WORKERwas set together with the trace, and stdout went to a log file. The[hooksync]numbers come from a separate run withAPS5_PROFILE_DRAW=1.AI-assisted (Claude Code).