perf(agc): fill-cleared linear targets fall back to a whole-target store after every draw on macOS (PPSA02070) #18785
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 krishalivaibhav on 2026-11-12T08:42:34Z.
Title and scene
PPSA02070 (Don't Starve Together: Console Edition 02.009.002), character intro cutscene, seconds 40–50 after launch, 3840x2160
What is slow or what changed
On macOS (Apple M2, MoltenVK, Rosetta), most of the draw committer's time goes to whole-image write-backs of linear render targets right after draws (
linear target): ~1,900 stores / ~25.6 GB per 10 s.Cause, traced with temporary instrumentation: the title clears its linear targets every frame with buffer fills (
Driver::storeBufferFill→StorageTexture::FillClear→MarkDirty). Because no draw is being recorded,markLayersPendingsetspendingFromOthers, so the nextMarkDrawnreturns false andkeepRecordedDraw(Draw.cpp~2540) stores the whole target after every draw. 17,995 of 18,000 sampledMarkDrawncalls hit this.Two prototypes, same binary at
65351c2931, switched by env:StoreDrawnLinear("flip")at 45.6 GB / 10 s.APS5_DEFER_LINEAR_STORE=1(diff below): when the draw-time store would run and the target isCached(),MarkDirty()instead, leaving the store to the next flip/label. The frame looks correct by eye, but correctness is not checked beyond that.Deferring helps the median, but the bytes only move:
Driver.Packet.flip_flush/Recorder.Syncnow costs ~16 ms/frame on the queue worker and creates 35–47 ms spikes. Extending the macOS label read traps toStoreDrawnLinear("flip")(same eligibility asStoreReadbackBeforeLabel) trapped nothing here; these targets presumably fail the shared-page test.Relation to #9685 and #8152: #9685 stores resident linear targets only at completion points and over their drawn rectangles, but a fill clear sets
pendingFromOthers, which turns that tracking off, so this title falls back to the per-draw whole store. Prototype 2 stores whole images later, so it likely reintroduces the #8152 hazard (CPU stores made after the draw get overwritten); it is a measurement, not a fix.Open question for the AGC maintainers: is the whole-target store after a fill-cleared draw needed for correctness? Fill clears could instead keep rectangle tracking (or be recorded as a known clear value) so only the drawn rectangles are stored, without falling back to a full store per draw. I have not opened a PR; the prototype is not something I would propose as-is.
Measured on
65351c2931(main has moved since, including #11485). I will re-measure on current main if useful.Summary lines
Traces
Not attached yet (the GitHub CLI cannot upload files); available on request:
aps5-trace-65351c2931ec-16195.json.gz(base),aps5-trace-65351c2931ec-17101.json.gz(deferred).Digest
base
seconds 40:10 from present 1623: 420 presents, frame p50 23.4 / p90 26.8 / p99 28.9 / max 29.5 ms, GPU busy 19.1 ms per present
Apple M2, MoltenVK 1.4.2, Darwin 27.3.0, 3840x2160, commit
65351c2931(dirty), dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 19.1, Driver.Packet 11.7, Driver.WorkerWait 11.6, Driver.WorkerWait.idle_and_completion_poll 11.6, VideoOut.Flip 11.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
APS5_DEFER_LINEAR_STORE=1
seconds 40:10 from present 1823: 458 presents, frame p50 21.5 / p90 22.9 / p99 28.2 / max 47.3 ms, GPU busy 16.6 ms per present
Apple M2, MoltenVK 1.4.2, Darwin 27.3.0, 3840x2160, commit
65351c2931(dirty), dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 17.2, batch 16.6, Driver.Packet.flip_flush 16.0, Recorder.Sync 15.6, Driver.WorkerWait 4.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Capture