perf: Squirrel with a Gun (PPSA22102) spawn runs at ~1 FPS while streaming #7947
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 Rajkamalcode on 2026-10-19T15:42:23Z.
Title and scene:
PPSA22102(Squirrel with a Gun, 01.000.000), in-game at the save-game spawn (tutorial area), 3840x2160 fullscreen, title default settings (sg.ResolutionQuality=100). The window covers frames after entering the world while the scene is still streaming in.What is slow: The spawn streams content for several minutes after the save loads; during that time frames take about one second (p50 912 ms in the 30 s capture, p50 1007 ms in the 60 s companion). The same spot runs about 7-8x faster once streaming has finished (observed in earlier sessions on this machine, ~129 ms / 7.7 FPS, not part of these traces). To reproduce: load the tutorial save and watch the first minutes in the world.
Build:
cbdf973fd568(dirty) - the local fix-branch tree (carries the AGC storage write-back fix now in #7912 and the libc fixes of #7905/#7906; not a cleanmainbuild).Summary lines (
aps5-summary.jsonl, as written):Traces
aps5-trace-cbdf973fd568-8088.json.gz- primary capture, 30 s window, no dropped events.aps5-trace-cbdf973fd568-20912.json.gz- companion capture, 60 s window;trace_droppedon queue worker 0x0 after 37 s (its totals are complete; a prefix of its event slices was dropped before the buffer filled).Digest -
python tools/trace_digest.py <trace>- primary capture (30 s):seconds 420:30 from present 1478: 33 presents, frame p50 912.3 / p90 957.4 / p99 1011.5 / max 1011.5 ms, GPU busy 466.7 ms per present
NVIDIA GeForce RTX 3070, NVIDIA 610.88, Windows 10.0.22635, 3840x2160, commit cbdf973fd568 (dirty), dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 1549.0, Driver.Packet.dispatch 657.1, Driver.Dispatch 625.4, Resources.Complete 480.5, batch 466.1, Vulkan.Dispatch 443.3, Vulkan.Dispatch.shader_resources 432.1, Driver.Packet.draw 293.5, Driver.Draw 292.8, Driver.WorkerWait 245.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Companion capture (60 s):
seconds 400:60 from present 1408: 61 presents, frame p50 1007.3 / p90 1060.0 / p99 1122.9 / max 1122.9 ms, GPU busy 500.5 ms per present
NVIDIA GeForce RTX 3070, NVIDIA 610.88, Windows 10.0.22635, 3840x2160, commit cbdf973fd568 (dirty), dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 1303.5, Driver.Packet.dispatch 563.0, Driver.Dispatch 535.1, batch 499.7, Resources.Complete 463.5, Vulkan.Dispatch 397.4, Vulkan.Dispatch.shader_resources 388.6, Driver.Packet.memory_wait 309.6, Driver.WorkerWait 267.0, Driver.WorkerWait.dequeue_order 266.9
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Capture protocol
APS5_TRACE_*orAPS5_PROFILE_*switch was set and the log was not redirected: the only variables set are the two shown in the summary lines;APS5_PAD_INPUT_FILEsupplies recorded controller presses to get through the intro (no presses fall inside the captured windows).Reporter's analysis (AI-assisted - kept separate from the measured data above)
Driver.WorkerWait.dequeue_order(waiting on the neighbouring worker) and 34 % executingDriver.Packet.dispatch(the summary's top phase, ~660 ms/frame), dominated byVulkan.Dispatch.shader_resources(~390-435 ms/frame).Driver.Packet(~590 ms/frame largest slice) with ~403 ms/frame in sub-20 us slices (many tiny writes/packets) plusDriver.Packet.memory_wait(~310 ms/frame).aps5-trace-cbdf973fd568-8088.json.gz
aps5-trace-cbdf973fd568-20912.json.gz
Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-19T16:48:01Z.
Addendum: queue-worker 0 stacks (sampler)
The trace above has a blind spot for queue worker 0 itself: nearly all of its work happens in sub-20 µs slices, so the profile shows that it is busy but not where. To fill that in I re-ran the same spawn area with the driver's worker sampler enabled, replaying the same pad input.
Sampler settings, for the record:
APS5_SAMPLE_WORKER=<file>— queue worker 0, sampled every timer tick (in practice ~64 Hz on this machine;# samples=38278over ~10 min, 5,619 distinct stacks, 15 truncated walks, mean suspension 96 µs)APS5_PAD_INPUT_FILE=<file>— same menu/pad replay as the capturesThe sampler suspends the worker for every walk, so these are attribution numbers, not timing numbers.
Self time by module (leaf frame)
About three quarters of this worker's wall time is parked in kernel waits. Grouping the samples by the nearest driver frame above the wait:
DriverDetail::DrawPipeline::Enqueueidle.waitinEnqueue)DriverDetail::DrawPipeline::Drainidle.waitinDrain, plus libstdc++ futures)Graphics::Recorder::finish/SyncThrough/SyncGuestMemory::GpuMutexType::lockLockSpinning<std::recursive_mutex>contentionDriverDetail::waitMemoryPollSleep()— the sleep half of the memory wait (the trace'smemory_waitphase)Graphics::StorageTexture::release()/ dtormakeSlab,Texturector,BufferPool::AllocateMemory,createView)Graphics::Recorder::SubmitDriver CPU work — 9.7 % self, 28.7 % inclusive under
DriverDetail::Driver::execute. The dominant CPU path is resource preparation for dispatches:VulkanDevice::dispatch21.9 % inclusive, essentially all of itShaderResources::Complete()(21.9 %); the sampled PCs concentrate inbuildComplete()andresolveImageBinding(). This is the trace'sdispatch.shader_resourcesphase, and it is CPU, not GPU wait. The dispatch resource cache is not the problem here: the[rescache]counters from these runs report ~99 % hits (12,990 hits / 148 misses), so this is the completion cost of the deferred compute builds.draw15.0 %,dispatch13.4 %,dispatchIndirect12.2 %.ResourceCache::RemoveImageis the hottest single self frame (0.7 % across offsets), followed byAllKeysEqual,dropReleasedTextures, andShaderRecompiler::Specialization::prune/fold.StorageTexture::release()in the waits. The run log also has the device-local heap at 6,705 of 6,700 MiB with 1,597,440 bytes placed in host memory across 2,048 allocations, so part of this is spill rather than steady state.What this adds to the trace story
PollSleep,LockSpinning, and the pipeline condition variables wake often and do little between wakes.Enqueue(~15 %) and the GPU-mutex contention inGuestMemory::GpuMutexType::lock(~9 %). Pipeline depth and the single committer thread are the first thing to look at; the GPU mutex is worth a look from whoever owns the guest-memory write tracking.Caveats: the sampler window is the whole ~10 min run, while the trace window sat inside a stall, so absolute shares are not directly comparable — the trace's "busy" fraction and the sampler's wait fraction describe the same worker in different phases.
graphics-hook64.dll(OBS capture hook) is loaded in the process and appears in ~1.7 % of chains; it should be excluded for future runs. RVA→symbol mapping usedlibSceAgcDriver.prxwith PE timestamp0x6ad60e21— the binary in the game'slibs/directory.Raw collapsed stacks (speedscope/flamegraph format, RVAs plus the module table headers) are attached below.
(AI-generated analysis, labeled per
docs/dev/GAME_TESTING.md; raw data attached.)Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-19T16:50:53Z.
swag-worker-samples.collapsed.txt
Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-19T17:23:32Z.
Heavy-state profile, and a drain-removal A/B (6-minute runs at the 1 FPS spot, RTX 3070, Windows 11)
Four runs on the same save with the same pad-file entry (
APS5_PROFILE_DRAW=1, no trace capture, window closed at +360 s). Values are per 10 s windows in the steady part of the run (2nd-6th minute), which is the ~1 FPS state.APS5_PIPELINE_DMA=1Drain removal alone does not move this title. Run 14 removes the DMA drains (0x50 -> 0, ~1.7-2.1k fewer packet drains per 10 s) and the frame rate stays inside the baseline spread (9-12 presents / 10 s; run 7 and run 15 are both baselines at opposite ends of it). The drain waits are symptom, not gate: the committer keeps working while queue 0 waits, and the frame is set by the recording chain below. This matches the Sword of the Sea data point in #7895, where pipelined DMA and dispatch drains moved the wait but not the frame time. Run 13 is a degradation mode (same workload, 5-8 presents, GPU busy rising to 750 ms) that looks driven by VRAM/streaming pressure rather than by drain count.
Where the committer's time goes
Draw-side
[draws]totals in the last window of each run (draws recorded per 10 s):Per kind: template hit 79 us, full build 1,437-1,792 us, address-based (BDA) build 122-149 us. The single draw committer records ~2,000 commits per frame at ~205-250 us each (22-24k commits / 10 s at 11 presents), i.e. ~400-430 ms of the ~0.9 s frame on one thread, and the GPU is busy only 414-487 ms of it (426-579 ms idle gaps). ~13k of the 22k commits per 10 s are non-draw items (labels/stores/fills) sharing the same committer.
readTarget is the largest single draw-side phase. Each resident-target lookup runs
StorageTexture::Refresh:CompletePendingCpuWrites,FlushPending,CollectWritesover the surface, the DCC key scan, thenUnchangedSince. In these runs there were 9,281-10,661 resident lookups per 10 s; only 190-219 of them were >= 1 ms, but those consumed 853-988 ms of the 1,020-1,147 ms. 4.4-4.9M pages were walked per 10 s (most draws are partial-scissor: 7.7-9.4k partial vs 0.9-1.3k full, and the walk still covers the surface). The committer's collect memo is invalidated whenever the queue worker passes a CPU-visible ordering point:Driver::bumpEpochadvancesDrawPipeline::EpochToken(WaitStatistics.cpp:36) and the committer'sFollowEpochbumps its own collect epoch (DrawPipeline.cpp:63), so the next target refresh after a bump re-walks. This is ~85-100 ms per frame on its own.Resource builds are the second-largest.
[resources]cumulative in run 15: 156,187 builds, stage B 140.3 s, of which images 123.0 s (~0.79 ms per build in image resolution), stage A 13.8 s, upload 16.5 s. On the draw side, 1,181-1,294 builds per 10 s at 1.4-1.8 ms each (~90-110 ms per frame), while the 5.8-6.7k template hits cost 79 us each (~35 ms per frame).Texture churn.
[texture]over a run: 44-94k storage images created, 600 GB-1.29 TB of image memory churned (create 52-87 s CPU, GPU-side write-back 34-57 s), 142-227k reused, 38-74k direct uploads. With 8 GB of VRAM this is the background pressure behind the run 13 spiral and the "GPU busy grows over the run" behaviour already noted for this title.Reading
The frame at this spot is a serial recording chain: ~2,000 commits/frame on one committer, a third of the draw time in per-draw resource completion and the target-refresh page walk, plus the queue worker's packet work and waits; the GPU idles about half the frame and drain waits are downstream symptoms. This is the same shape as #7895 (parallel draw preparation/recording) and the generic findings in #6754. The concrete levers the numbers point to, in order: (1) get draw recording/preparation off the single committer, (2) make per-draw resource completion cheaper (the images stage and 1.4-1.8 ms builds), (3) share or avoid the committer's target-refresh page walks after ordering points, (4) keep more of the streamed images resident.
AI-assisted: the runs, the log mining and this text were produced by an AI-assisted workflow on the reporter's machine. Raw per-10 s logs and the extracted tables can be shared on request.
Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-20T04:40:12Z.
Follow-up: stock-settings determinism, per-frame timeline, worker sampler (runs 24-26)
Same title and spawn as above:
PPSA22102(Squirrel with a Gun, 01.000.000), tutorial save, 3840x2160, title defaults (stockgameusersettings.ini0156186E,sg.ResolutionQuality=100, all scalability groups 3), buildcbdf973fd568(dirty), driver prx5AB0413B. Shader caches warm.The input is now a deterministic pad schedule instead of a hand-driven replay: reset to
0 0 1, then sequence 1-4 Cross (16384) for 1000 ms at 15/30/45/60 s (APS5_PAD_INPUT_FILE). Three 360 s runs: two baselines withAPS5_PROFILE_DRAW=1, traceAPS5_TRACE_SECONDS=60:30,APS5_TRACE_SUMMARY_EVERY=10; one worker-sampler run withAPS5_SAMPLE_WORKERand no trace.Measured: the two baseline runs agree on the scene and workload
Tail 20 ten-second windows (steady part of each run):
Trace summary, steady intervals 120-345 s (medians):
run24lost trace events on queue worker 0x0 (events_lost11,541) buttotals_fullis false, so the summary totals are valid;run25is clean.The
readTargetspread is not input timing or scene drift: the slow-lookup count is 199.5 vs 190, the slow time is 982.8 vs 832 ms, and per-slow-lookup cost is 4,926 vs 4,379 us. A single-pairreadTargetA/B is not trustworthy at this spread; a readTarget comparison needs paired runs and normalization by slow lookups. The scene/workload gate itself passes (draws/present 0.9%, commit us/draw 7.2%, trace p50 0.5%).Measured: per-frame timeline (run24/run25 traces, 60:30 window)
Method: Chrome-trace complete slices grouped by thread; for each interval between
Driver.Presentevents, union of the queue-worker, draw-committer, and GPU-track slices, plus pairwise overlaps. 31 frames (run24) and 28 frames (run25).The trace-window p50 (912/1005 ms) reproduces the earlier 912/1007 ms observation; the 120-345 s steady tail is heavier (1,135/1,141 ms p50) as the spawn streams in.
Worker trace scopes (ms/frame):
Committer trace scopes (ms/frame):
Measured: worker sampler at stock (run26)
APS5_SAMPLE_WORKERon queue worker 0x0, no trace, same pad schedule. Final window 22,952 samples; a 17,933-sample mid-run window was also taken. Worker busy 99.9%.ShaderResources::Complete(viaVulkanDevice::dispatch)DrawPipeline::DrainDrawPipeline::EnqueueShaderResources::buildComplete(viaDriver::draw)Recorder::finish->CompletePendingCpuWrites->UploadFinishShaderResources::resolveImageBindingcachedStorageTextureGpuMutex::lockRecorder::SyncThroughVulkanDevice::DrawThe sampler suspends the worker for each walk, so these are attribution numbers, not timing numbers.
Diagnostic: low-settings profile (not a default-settings result)
These runs intentionally lowered the in-game settings to make the committer the wall and inspect the producer path. They are diagnostic only and are not part of the default-settings claim above.
DrawPipeline::run(12,616 + 7,659),commitDraw6,284,refreshResidentTarget2,412,ShaderResourcesctor/buildComplete/resolveImageBinding 1,151/999/958,fprintf1,323 (5.8% of samples).AI-generated analysis (separate from the measured data above)
Resources.Complete(~24%),device_lock(~23%), anddraw_enqueued(~16%) are the largest named worker costs. The committer's 29%/24%GpuMutex.wait.drawsays the shared GpuMutex is a first-order contention point, not just a symptom. This profile supports the maintainer-directed prepare/record split (move the enqueue/prepare work to the committer with headroom) and GpuMutex sharding; a split alone that still serializes on the same lock would leave the wait in place.Artifacts
ghcannot attach files from the CLI, so I will add these in a follow-up drag-and-drop:swag-run26-worker.collapsed.txt(worker sampler stacks, 22,952 samples)timeline-run24.txt,timeline-run25.txt(per-frame overlap tables and scope lists)swag-run24-err.log,swag-run25-err.log(full 360 s logs)