perf(agc): the queue-0 draw committer bounds draw-heavy titles on the CPU — is parallel draw recording planned? #7895

Open
opened 2026-10-19 12:46:13 +00:00 by SP4C3B4R-8 · 15 comments
SP4C3B4R-8 commented 2026-10-19 12:46:13 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-19T12:46:13Z.


@oneandonlydean @MichonGoddijn231849 asking before anyone starts, so nobody does the same work twice (I asked the same on #1201 on 10-16; posting it here where it is easier to find).

Measured on main 415cd49fd + #6763, Windows 11, RTX 5070 Ti (NVIDIA 617.42), Ryzen 7 7800X3D. Scene: Astro Bot (PPSA21564), Crash Site hub, warm caches, ~3,000 draws per frame, ~10 fps.

  • The draw committer thread is busy ~88 of ~102 ms per frame (APS5_TRACE_SECONDS window: Graphics.Draw plus folded slices). It records ~290k draws per 10 s at ~25 µs each.
  • queue worker 0x0 is blocked ~72% of the samples, mostly in DrawPipeline::Enqueue waiting for room. It is not the limit.
  • The GPU is busy ~62 ms per frame (gpu_busy_ms_per_present).
  • [draws] phases on the committer per 10 s: lookup 2.0 s (mostly ShaderResources::Revalidate), record 1.47 s, vertex 0.82 s, readTarget 0.66 s, everything else under 0.25 s each. Only ~25% of the committer's time is command recording itself.
  • A local counter over the last 16 committed draws: 87.5% of draws read no range (described texture/storage ranges, device and in-place buffer reads) that any of the previous 16 draws writes (color/depth targets, GPU-written buffers, storage images). 10.5% depend on the draw right before.

Things that gave nothing measurable here: a deeper pipeline (APS5_PIPELINED_DRAWS=32/64), APS5_PIPELINE_DISPATCH=1 (drains 7.4k → 4.7k per 10 s, same fps), and moving write-watch walks to the worker.

So the remaining CPU headroom on titles like this seems to need preparation outside the single committer: preparing draws N+1…N+k off the GPU mutex with a validity check at record time, and/or secondary command buffers per render pass. That touches the resource cache, the texture/storage registries and the recorder's snapshot arena, which is your area.

Question: is either of you planning this? If not, would you take it from us as a series of small PRs (first a split of Graphics::Draw into prepare and record with no behavior change), and in what shape?

Written with AI assistance (Claude); measured on the machine above.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5924113619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-19T12:46:13Z. --- @oneandonlydean @MichonGoddijn231849 asking before anyone starts, so nobody does the same work twice (I asked the same on #1201 on 10-16; posting it here where it is easier to find). **Measured** on main 415cd49fd + #6763, Windows 11, RTX 5070 Ti (NVIDIA 617.42), Ryzen 7 7800X3D. Scene: Astro Bot (PPSA21564), Crash Site hub, warm caches, ~3,000 draws per frame, ~10 fps. - The `draw committer` thread is busy ~88 of ~102 ms per frame (`APS5_TRACE_SECONDS` window: `Graphics.Draw` plus folded slices). It records ~290k draws per 10 s at ~25 µs each. - `queue worker 0x0` is blocked ~72% of the samples, mostly in `DrawPipeline::Enqueue` waiting for room. It is not the limit. - The GPU is busy ~62 ms per frame (`gpu_busy_ms_per_present`). - `[draws]` phases on the committer per 10 s: lookup 2.0 s (mostly `ShaderResources::Revalidate`), record 1.47 s, vertex 0.82 s, readTarget 0.66 s, everything else under 0.25 s each. Only ~25% of the committer's time is command recording itself. - A local counter over the last 16 committed draws: 87.5% of draws read no range (described texture/storage ranges, device and in-place buffer reads) that any of the previous 16 draws writes (color/depth targets, GPU-written buffers, storage images). 10.5% depend on the draw right before. Things that gave nothing measurable here: a deeper pipeline (`APS5_PIPELINED_DRAWS=32/64`), `APS5_PIPELINE_DISPATCH=1` (drains 7.4k → 4.7k per 10 s, same fps), and moving write-watch walks to the worker. So the remaining CPU headroom on titles like this seems to need preparation outside the single committer: preparing draws N+1…N+k off the GPU mutex with a validity check at record time, and/or secondary command buffers per render pass. That touches the resource cache, the texture/storage registries and the recorder's snapshot arena, which is your area. **Question:** is either of you planning this? If not, would you take it from us as a series of small PRs (first a split of `Graphics::Draw` into prepare and record with no behavior change), and in what shape? Written with AI assistance (Claude); measured on the machine above.
m335671 commented 2026-10-19 16:37:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by m335671 on 2026-10-19T16:37:26Z.


A data point from the other side of the same problem, and an offer to take a share of it.

Setup: Sword of the Sea (PPSA25344, UE5), Windows 11, RTX 4070, NVIDIA 617.42, Ryzen 9 7900, main from today, in game.

The limit is the queue-0 worker, not the committer:

  • queue worker 0x0 is 98–99 % busy and the draw committer ~40–46 %. Frames take ~400 ms.
  • Per 10 s the worker handles ~65k draws at ~38 µs each (capture 6.5, capture hook waits 6.0, recompile 7.9, Graphics::Draw 7.6) and ~24k dispatches at ~100–120 µs each (capture 8–21, recompile 8–15, prepare stage A 10–23, device call 42–61).
  • Inside an indirect dispatch's device call ([indirect], 27k dispatches per 10 s), per dispatch: B upload ~20 µs, B images ~13 µs, record ~12 µs, resource-template insert ~7 µs. The template cache inserts 26.7k of 27.4k, so nearly every dispatch builds fresh.

What I measured that does not help on this title, so nobody repeats it:

  • Caches. The draw and dispatch caches miss ~99.9 % (draw misses: user data changed in 97 %; APS5_DRAW_CACHE_ENTRIES=32768 changes nothing).
  • Relocating moved user-data pointers. Measured locally on dispatches with a dry-run donor/shift/compare: with the runs shifted, the content is identical in ~0.25 % of misses. Compared with the previous dispatch of the same shape, only descriptor base words differ in ~30 %, and other content differs in ~41 %. So per-command work cannot be cached away here.
  • Draining less (#6501, a local APS5_PIPELINE_DISPATCH=2 that also pipelines dispatch-cache misses, APS5_PIPELINE_DMA=1). Each one removes drains: packet drains go ~160k → ~4k per 10 s. The wait just moves elsewhere, into the captures that read what the queued DMA and dispatch items write. Frame time is unchanged. Details are in #5436.

So I agree with the direction, and both sides need it: the committer on Astro Bot, the worker's per-command preparation on this title. In #5436 I offered to take the dispatch side of the 2.2 split. Concretely, that means moving dispatch preparation (stage A, the guest buffer snapshot upload, the template build) off the queue-0 worker onto helper threads in guest order, with a validity check where the item is recorded, so it fits whatever shape you choose for draws.

Questions for oneandonlydean and MichonGoddijn231849, as above: which shape do you want, per-thread secondary command buffers per render pass or several prepared items feeding one recorder? Would a dispatch-side series in that shape, behind a switch and off by default, be welcome? I can also measure every step of the draw-side series on this title (Windows/NVIDIA, UE5), where the worker is the limit.

AI-assisted: yes (Claude Code). The builds, the runs and this comment were done and written by Claude Code on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272179183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6272179183). Originally posted by [m335671](https://github.com/m335671) on 2026-10-19T16:37:26Z. --- A data point from the other side of the same problem, and an offer to take a share of it. **Setup:** Sword of the Sea (PPSA25344, UE5), Windows 11, RTX 4070, NVIDIA 617.42, Ryzen 9 7900, `main` from today, in game. **The limit is the queue-0 worker, not the committer:** - `queue worker 0x0` is 98–99 % busy and the `draw committer` ~40–46 %. Frames take ~400 ms. - Per 10 s the worker handles ~65k draws at ~38 µs each (capture 6.5, capture hook waits 6.0, recompile 7.9, `Graphics::Draw` 7.6) and ~24k dispatches at ~100–120 µs each (capture 8–21, recompile 8–15, prepare stage A 10–23, device call 42–61). - Inside an indirect dispatch's device call (`[indirect]`, 27k dispatches per 10 s), per dispatch: `B upload` ~20 µs, `B images` ~13 µs, `record` ~12 µs, resource-template insert ~7 µs. The template cache inserts 26.7k of 27.4k, so nearly every dispatch builds fresh. **What I measured that does not help on this title, so nobody repeats it:** - Caches. The draw and dispatch caches miss ~99.9 % (draw misses: user data changed in 97 %; `APS5_DRAW_CACHE_ENTRIES=32768` changes nothing). - Relocating moved user-data pointers. Measured locally on dispatches with a dry-run donor/shift/compare: with the runs shifted, the content is identical in ~0.25 % of misses. Compared with the previous dispatch of the same shape, only descriptor base words differ in ~30 %, and other content differs in ~41 %. So per-command work cannot be cached away here. - Draining less (#6501, a local `APS5_PIPELINE_DISPATCH=2` that also pipelines dispatch-cache misses, `APS5_PIPELINE_DMA=1`). Each one removes drains: packet drains go ~160k → ~4k per 10 s. The wait just moves elsewhere, into the captures that read what the queued DMA and dispatch items write. Frame time is unchanged. Details are in #5436. So I agree with the direction, and both sides need it: the committer on Astro Bot, the worker's per-command preparation on this title. In #5436 I offered to take the **dispatch** side of the 2.2 split. Concretely, that means moving dispatch preparation (stage A, the guest buffer snapshot upload, the template build) off the queue-0 worker onto helper threads in guest order, with a validity check where the item is recorded, so it fits whatever shape you choose for draws. Questions for oneandonlydean and MichonGoddijn231849, as above: which shape do you want, per-thread secondary command buffers per render pass or several prepared items feeding one recorder? Would a dispatch-side series in that shape, behind a switch and off by default, be welcome? I can also measure every step of the draw-side series on this title (Windows/NVIDIA, UE5), where the worker is the limit. AI-assisted: yes (Claude Code). The builds, the runs and this comment were done and written by Claude Code on my machine.
Rajkamalcode commented 2026-10-19 17:28:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-19T17:28:37Z.


Data point from another Windows/NVIDIA title, and a scope question.

SWAG (PPSA22102) in its ~1 FPS spawn/streaming state has the same shape as the Astro Bot scene: the single queue-0 draw committer records ~2,000 commits/frame (about 890 of them draws, the rest label/store items) at 205-250 us each, i.e. ~400-430 ms of a ~0.9 s frame, while the GPU is busy only 414-487 ms and idles 426-579 ms. Queue worker 0 is blocked 14.9 % in DrawPipeline::Enqueue and ~17 % in Drain (10-minute sampler), but the committer is the throughput limit, not the worker.

Per-draw costs at that spot (six-minute APS5_PROFILE_DRAW runs, 8-10k draws/10 s): readTarget 880-1,147 ms/10 s - resident-target page walks, because the committer follows the worker's collect-epoch token (WaitStatistics.cpp:36 -> DrawPipeline::FollowEpoch), so every ordering point re-walks the target (4.4-4.9M pages/10 s; 190-219 lookups >= 1 ms consume ~90 % of the phase); resources 815-889 ms/10 s (1,181-1,294 builds at 1.4-1.8 ms each vs 79 us template hits, mostly the images stage of stage B); record 222-294 ms.

Negative result that may save someone a cycle: removing drain waits does not move this title. APS5_PIPELINE_DMA=1 removed ~2.1k 0x50 packet drains per 10 s and left presents at 10-11/10 s, inside the 9-12 baseline spread; the worker's drain wait is symptom, not gate. Same conclusion m335671 reported for Sword of the Sea. Full logs/tables: #7947.

Before anyone starts on parallel draw preparation/recording: is this claimed? If a maintainer wants it, we can help on the measurement/validation side (Windows 11, RTX 3070, SWAG as a draw-heavy 1 FPS case) and can test candidate branches with numbers. We are not starting an architecture PR without direction.

AI-assisted: the runs, log mining and this text were produced by an AI-assisted workflow on the reporter's machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273171139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6273171139). Originally posted by [Rajkamalcode](https://github.com/Rajkamalcode) on 2026-10-19T17:28:37Z. --- Data point from another Windows/NVIDIA title, and a scope question. SWAG (PPSA22102) in its ~1 FPS spawn/streaming state has the same shape as the Astro Bot scene: the single queue-0 draw committer records ~2,000 commits/frame (about 890 of them draws, the rest label/store items) at 205-250 us each, i.e. **~400-430 ms of a ~0.9 s frame**, while the GPU is busy only 414-487 ms and idles 426-579 ms. Queue worker 0 is blocked 14.9 % in `DrawPipeline::Enqueue` and ~17 % in `Drain` (10-minute sampler), but the committer is the throughput limit, not the worker. Per-draw costs at that spot (six-minute `APS5_PROFILE_DRAW` runs, 8-10k draws/10 s): `readTarget` 880-1,147 ms/10 s - resident-target page walks, because the committer follows the worker's collect-epoch token (`WaitStatistics.cpp:36` -> `DrawPipeline::FollowEpoch`), so every ordering point re-walks the target (4.4-4.9M pages/10 s; 190-219 lookups >= 1 ms consume ~90 % of the phase); `resources` 815-889 ms/10 s (1,181-1,294 builds at 1.4-1.8 ms each vs 79 us template hits, mostly the images stage of stage B); `record` 222-294 ms. Negative result that may save someone a cycle: **removing drain waits does not move this title.** `APS5_PIPELINE_DMA=1` removed ~2.1k `0x50` packet drains per 10 s and left presents at 10-11/10 s, inside the 9-12 baseline spread; the worker's drain wait is symptom, not gate. Same conclusion m335671 reported for Sword of the Sea. Full logs/tables: #7947. Before anyone starts on parallel draw preparation/recording: **is this claimed?** If a maintainer wants it, we can help on the measurement/validation side (Windows 11, RTX 3070, SWAG as a draw-heavy 1 FPS case) and can test candidate branches with numbers. We are not starting an architecture PR without direction. AI-assisted: the runs, log mining and this text were produced by an AI-assisted workflow on the reporter's machine.
oneandonlydean commented 2026-10-19 18:01:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T18:01:48Z.


@SP4C3B4R-8 Thanks for the measurements. Nobody on our side is working on this, and we'd welcome it as a series of small PRs. Please start with the split of Graphics::Draw into a prepare step and a record step with no behaviour change, so it can be reviewed and tested on its own. After that, each step that moves work off the GPU mutex or into per-pass secondary command buffers should bring before/after frame timings from the same scene. The maintainers have the final say on the overall design, so it's worth outlining the end state in this issue before the bigger steps.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273810034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6273810034). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T18:01:48Z. --- @SP4C3B4R-8 Thanks for the measurements. Nobody on our side is working on this, and we'd welcome it as a series of small PRs. Please start with the split of `Graphics::Draw` into a prepare step and a record step with no behaviour change, so it can be reviewed and tested on its own. After that, each step that moves work off the GPU mutex or into per-pass secondary command buffers should bring before/after frame timings from the same scene. The maintainers have the final say on the overall design, so it's worth outlining the end state in this issue before the bigger steps.
johandavidcm commented 2026-10-19 19:34:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-19T19:34:11Z.


Another title with the same shape, in case it helps with the order: PPSA31327 (Yakuza 0 Director's Cut) in gameplay, on the same CPU (Ryzen 7 7800X3D, RTX 4070). About 8,700 draws per frame at 3.3 FPS: the committer's Graphics.Draw takes 252 of the 299 ms frame, and queue worker 0 waits in DrawPipeline::Enqueue in 29 % of its samples.

One part of the committer's time would not need parallel recording: 12 % of its samples rescan the DCC keys of sampled textures in cachedTexture, through TextureClearKeys rather than a proof. Summary lines, traces and the stacks of both threads are in #NNNN.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6275596666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6275596666). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-19T19:34:11Z. --- Another title with the same shape, in case it helps with the order: PPSA31327 (Yakuza 0 Director's Cut) in gameplay, on the same CPU (Ryzen 7 7800X3D, RTX 4070). About 8,700 draws per frame at 3.3 FPS: the committer's `Graphics.Draw` takes 252 of the 299 ms frame, and queue worker 0 waits in `DrawPipeline::Enqueue` in 29 % of its samples. One part of the committer's time would not need parallel recording: 12 % of its samples rescan the DCC keys of sampled textures in `cachedTexture`, through `TextureClearKeys` rather than a proof. Summary lines, traces and the stacks of both threads are in #NNNN. AI-assisted: yes
m335671 commented 2026-10-19 21:05:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by m335671 on 2026-10-19T21:05:04Z.


Here is the dispatch side of the end state, outlined before any code as asked, so it lines up with the draw-side series.

Queue-0 dispatches already have half of the split. PrepareDispatch (stage A) runs without the GPU mutex. VulkanDevice::dispatch then does everything else under it, in this order: reap the presync batches, look up or insert the resource template, complete it (Complete(): images, guest-buffer uploads, descriptor writes) or Revalidate it, build a RecordedDispatch, and hand that to recordDispatch. Proposed series, each step behind a switch and off by default until it shows before/after timings from the same scene:

  1. Split VulkanDevice::dispatch into a complete step and a record step, with no behaviour change. The complete step returns the RecordedDispatch, and the record step is recordDispatch plus the marks and completions around it. This mirrors the Graphics::Draw prepare/record split so that both feed the same recorder interface.
  2. Move the parts of the complete step that do not need the mutex out of it. Candidates are the image lookups that are already lock-free and the staging copies of the guest-buffer uploads (~20 µs per dispatch here). What has to stay under the lock (registry refresh, CPU write-backs, recorded GPU copies) stays there.
  3. Record runs of dispatches between render passes on a helper, into whatever per-thread or per-pass command buffer the draw series introduces. A run is closed by the same hazards that close a draw run. Compute work sits outside render passes, so this depends on the draw series' recorder shape, and it comes after it.
  4. Worker side, for worker-bound titles like this one: resolve queue-0 dispatch capture and recompile ahead on a helper thread. It would take a register snapshot and adopt the result when the existing checks still hold, which is the DispatchAhead adoption protocol. Today DispatchAhead runs on the worker itself and skips queue 0. A rejection falls back to the current path, and a read over a range that a queued pipeline item writes rejects instead of draining. This step is independent of the recorder work.

Steps 1–2 touch VulkanDevice.cpp, ShaderResources, GuestBufferMemory and the dispatch path. Step 4 touches DispatchAhead.cpp, Dispatch.cpp and PacketExecution.cpp. None of them touches Graphics::Draw, so they don't conflict with SP4C3B4R-8's first PRs. I'll measure every step on Sword of the Sea (Windows/NVIDIA, worker-bound), and I'm glad to measure the draw-side steps there too.

As a first-time contributor I can only have one open PR, and #7932 (a 3-line DispatchWriteRanges fix with its test) is waiting for review, so step 1 will follow once that one is settled. If the maintainers prefer a different order or shape for the dispatch side, I'll follow it.

AI-assisted: yes (Claude Code). The analysis and this comment were done and written by Claude Code on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6277297868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6277297868). Originally posted by [m335671](https://github.com/m335671) on 2026-10-19T21:05:04Z. --- Here is the dispatch side of the end state, outlined before any code as asked, so it lines up with the draw-side series. Queue-0 dispatches already have half of the split. `PrepareDispatch` (stage A) runs without the GPU mutex. `VulkanDevice::dispatch` then does everything else under it, in this order: reap the presync batches, look up or insert the resource template, complete it (`Complete()`: images, guest-buffer uploads, descriptor writes) or `Revalidate` it, build a `RecordedDispatch`, and hand that to `recordDispatch`. Proposed series, each step behind a switch and off by default until it shows before/after timings from the same scene: 1. **Split `VulkanDevice::dispatch` into a complete step and a record step, with no behaviour change.** The complete step returns the `RecordedDispatch`, and the record step is `recordDispatch` plus the marks and completions around it. This mirrors the `Graphics::Draw` prepare/record split so that both feed the same recorder interface. 2. **Move the parts of the complete step that do not need the mutex out of it.** Candidates are the image lookups that are already lock-free and the staging copies of the guest-buffer uploads (~20 µs per dispatch here). What has to stay under the lock (registry refresh, CPU write-backs, recorded GPU copies) stays there. 3. **Record runs of dispatches between render passes on a helper,** into whatever per-thread or per-pass command buffer the draw series introduces. A run is closed by the same hazards that close a draw run. Compute work sits outside render passes, so this depends on the draw series' recorder shape, and it comes after it. 4. **Worker side, for worker-bound titles like this one:** resolve queue-0 dispatch capture and recompile ahead on a helper thread. It would take a register snapshot and adopt the result when the existing checks still hold, which is the `DispatchAhead` adoption protocol. Today `DispatchAhead` runs on the worker itself and skips queue 0. A rejection falls back to the current path, and a read over a range that a queued pipeline item writes rejects instead of draining. This step is independent of the recorder work. Steps 1–2 touch `VulkanDevice.cpp`, `ShaderResources`, `GuestBufferMemory` and the dispatch path. Step 4 touches `DispatchAhead.cpp`, `Dispatch.cpp` and `PacketExecution.cpp`. None of them touches `Graphics::Draw`, so they don't conflict with SP4C3B4R-8's first PRs. I'll measure every step on Sword of the Sea (Windows/NVIDIA, worker-bound), and I'm glad to measure the draw-side steps there too. As a first-time contributor I can only have one open PR, and #7932 (a 3-line `DispatchWriteRanges` fix with its test) is waiting for review, so step 1 will follow once that one is settled. If the maintainers prefer a different order or shape for the dispatch side, I'll follow it. AI-assisted: yes (Claude Code). The analysis and this comment were done and written by Claude Code on my machine.
oneandonlydean commented 2026-10-20 04:48:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T04:48:27Z.


@m335671 @SP4C3B4R-8 thanks, both measurements point the same way. On PPSA21564 about a quarter of the committer's time is recording, and in your dispatches the upload, images and template build are well over half of the device call, so preparation is what dominates on both titles.

So the shape we'd like is several prepared items feeding one recorder: prepare off the mutex (on helpers, in guest order), check validity where the item is recorded, and record on one thread in guest order. Per-pass secondary command buffers can come later as a step of their own, if recording itself becomes the limit. Nothing in the prepare/record split should rule them out.

The dispatch outline fits that, and it's welcome as a series, with two things for every step:

  1. Behind a switch, off by default, with before/after frame timings from the same scene (as you proposed).
  2. For steps 2 and 4, the check at record/adopt time has to catch writes that land between prepare and record, both CPU writes and writes by queued GPU items, and fall back when it fails. Each of those PRs should include a test that writes in that window and fails without the check.

Step 4 doesn't depend on the recorder, so it can follow step 1 directly. Step 3 waits for the draw series. #7932 is merged, so your step 1 can follow.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283624052 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6283624052). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T04:48:27Z. --- @m335671 @SP4C3B4R-8 thanks, both measurements point the same way. On PPSA21564 about a quarter of the committer's time is recording, and in your dispatches the upload, images and template build are well over half of the device call, so preparation is what dominates on both titles. So the shape we'd like is **several prepared items feeding one recorder**: prepare off the mutex (on helpers, in guest order), check validity where the item is recorded, and record on one thread in guest order. Per-pass secondary command buffers can come later as a step of their own, if recording itself becomes the limit. Nothing in the prepare/record split should rule them out. The dispatch outline fits that, and it's welcome as a series, with two things for every step: 1. Behind a switch, off by default, with before/after frame timings from the same scene (as you proposed). 2. For steps 2 and 4, the check at record/adopt time has to catch writes that land between prepare and record, both CPU writes and writes by queued GPU items, and fall back when it fails. Each of those PRs should include a test that writes in that window and fails without the check. Step 4 doesn't depend on the recorder, so it can follow step 1 directly. Step 3 waits for the draw series. #7932 is merged, so your step 1 can follow.
m335671 commented 2026-10-20 08:19:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by m335671 on 2026-10-20T08:19:04Z.


Step 1 is up: #8278. It splits VulkanDevice::dispatch into a complete and a record step, with no behaviour change.

Next is step 4: queue-0 dispatch capture and recompile resolved ahead on a helper, behind a switch that is off by default. It comes with a test that writes in the prepare/record window and fails without the check. A capture that would wait on words the GPU is still writing is rejected and falls back to the normal path rather than waiting on the helper. I'll measure the ceiling with APS5_GROUP_CAPTURE_ALL_QUEUES=1 first and post the before/after on the same scene.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286640760 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6286640760). Originally posted by [m335671](https://github.com/m335671) on 2026-10-20T08:19:04Z. --- Step 1 is up: #8278. It splits `VulkanDevice::dispatch` into a complete and a record step, with no behaviour change. Next is step 4: queue-0 dispatch capture and recompile resolved ahead on a helper, behind a switch that is off by default. It comes with a test that writes in the prepare/record window and fails without the check. A capture that would wait on words the GPU is still writing is rejected and falls back to the normal path rather than waiting on the helper. I'll measure the ceiling with `APS5_GROUP_CAPTURE_ALL_QUEUES=1` first and post the before/after on the same scene. AI-assisted: yes (Claude Code).
teepean commented 2026-10-20 18:58:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by teepean on 2026-10-20T18:58:13Z.


@SP4C3B4R-8 a Stray (PPSA02100, UE4) data point for this series, and an offer so we don't do the same work twice. In #5436 I said I'd take the draw-side recording split after the committer's per-draw costs. Your question here came first and the maintainers have set the shape, so I'd rather help with your series than start a second one.

Stray is committer-bound the same way. The setup: the start of the Dead City chapter, Linux, Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), stock engine.ini, 3840x2160. The build is my local stack (showcase/stray-stack: main 64e2a810a9 plus stage instances, repeat-draw paths and #6970), at 16.5 FPS. These are 300 stack samples of the whole process:

  • The draw committer is busy about 92 % of the time. Queue worker 0 is busy about 60 % and waits for room in the draw pipeline 33 % of the time. The GPU is busy about 60 %.
  • About 7 % of the committer's samples are inside the Vulkan driver: command encoding, pipeline binds, barriers and submits. The rest is preparation:
    • resource builds 15 %, most of them the ~165 address-based builds per frame;
    • proofs 14 %;
    • bindings (snapshots, uploads, sets) 12 %;
    • vertex and index inputs 8 %;
    • render-target lookup 6 %;
    • labels and counter dumps 6 %.

So it is the same picture as Astro Bot, with even less of the time in recording.

What I can offer:

  • Measure each step of the series on Stray, a committer-bound UE4 scene on Linux/NVIDIA, with frame dumps and the verify switches.
  • Run your dependency counter on Stray: the share of draws that read a range one of the previous 16 draws writes.
  • Take a piece you'd rather hand off. One example is the tests that write in the prepare/record window, which the maintainers asked for with each step.

Is the prepare/record split already in progress on your side?

AI-assisted: yes (text with Claude Code; the profile is from my machine).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298776012 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6298776012). Originally posted by [teepean](https://github.com/teepean) on 2026-10-20T18:58:13Z. --- @SP4C3B4R-8 a Stray (PPSA02100, UE4) data point for this series, and an offer so we don't do the same work twice. In #5436 I said I'd take the draw-side recording split after the committer's per-draw costs. Your question here came first and the maintainers have set the shape, so I'd rather help with your series than start a second one. Stray is committer-bound the same way. The setup: the start of the Dead City chapter, Linux, Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), stock `engine.ini`, 3840x2160. The build is my local stack ([`showcase/stray-stack`](https://github.com/teepean/AnyPS5/tree/showcase/stray-stack): `main` 64e2a810a9 plus stage instances, repeat-draw paths and #6970), at 16.5 FPS. These are 300 stack samples of the whole process: - The draw committer is busy about 92 % of the time. Queue worker 0 is busy about 60 % and waits for room in the draw pipeline 33 % of the time. The GPU is busy about 60 %. - About 7 % of the committer's samples are inside the Vulkan driver: command encoding, pipeline binds, barriers and submits. The rest is preparation: - resource builds 15 %, most of them the ~165 address-based builds per frame; - proofs 14 %; - bindings (snapshots, uploads, sets) 12 %; - vertex and index inputs 8 %; - render-target lookup 6 %; - labels and counter dumps 6 %. So it is the same picture as Astro Bot, with even less of the time in recording. What I can offer: - Measure each step of the series on Stray, a committer-bound UE4 scene on Linux/NVIDIA, with frame dumps and the verify switches. - Run your dependency counter on Stray: the share of draws that read a range one of the previous 16 draws writes. - Take a piece you'd rather hand off. One example is the tests that write in the prepare/record window, which the maintainers asked for with each step. Is the prepare/record split already in progress on your side? AI-assisted: yes (text with Claude Code; the profile is from my machine).
SleglJan commented 2026-10-21 06:19:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-21T06:19:33Z.


A data point from 007 First Light (PPSA11386) on Linux. On this title neither the committer (Astro Bot, SWAG, Yakuza 0, Stray) nor queue
0's worker (Sword of the Sea) is the busy thread. In gameplay the draw committer waits for work 62% of the frame. While queue 0's worker
waits for room in the draw pipeline, the committer spends 64% of that time waiting for the GPU mutex.

Setup

  • main 68323bae7 + #5799 #6868 #5372 #6918 #7643 #6679 (#5799 and #6679 have merged since), Release (GCC 16.2.1). No APS5_* switch other
    than the pad input file, so the pipeline depth and the spin windows are the defaults.
  • DrawPipeline's waits, HandoffSpin, WaitMemory and GpuMutexType::lock are unchanged on main ec7eacc62d, apart from the committer
    sampler (#8075, Windows only, a no-op here). Only the code was compared; the numbers were not measured again on ec7eacc62d.
  • CachyOS, Linux 7.2.10, GNOME on Wayland with SDL_VIDEODRIVER=x11 (XWayland), RTX 3080 (NVIDIA 615.78.08), Ryzen 9 7950X3D.
  • Gameplay about 4 minutes after Resume, Bond moving, warm shader cache; scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only).
  • One Nsight Systems 2026.3.2 capture:
    • -t vulkan,osrt --vulkan-gpu-workload=individual -s none --cpuctxsw=none --gpu-metrics-devices=0;
    • 23 frame intervals in 29.2 s, 1,269.5 ms per frame;
    • 2.2 million traced calls in the span (96k per frame), each with nsys's own cost. There is no uninstrumented frame time for the same
      stretch.
  • How the thread states are derived:
    • They are inferred from the traced OS runtime and Vulkan calls. CPU sampling and context switches were off; with either on, nsys
      failed to write the report on this setup.
    • "Untraced" is time in no traced call, an upper bound for CPU work. vkCmdDraw* and vkCmdDispatch* do not appear in the trace, so
      command recording counts as untraced. This capture gives no draw count per frame.
    • These are traced-call states, not the sampler or APS5_TRACE_* shares of the reports above, so the percentages are not directly
      comparable.
    • Spins before blocking count as untraced, so those waits are lower bounds:
      • GPU-mutex acquisitions and the committer's wait for work spin up to 150 µs (the automatic HandoffSpin window with more than 8
        usable CPUs);
      • DrawPipeline::Drain spins up to 300 µs;
      • WAIT_REG_MEM waits spin up to 1.5 ms on queue 0 and 100 µs on the other queues before polling;
      • the wait for room does not spin.
  • Threads are identified by their call stacks.

Per thread, ms per frame (share of the frame)

thread untraced waits Vulkan calls
queue 0's worker 690 (54%) 434 (34%): room in the draw pipeline (DrawPipeline::Enqueue, default depth 8) 264, of which 43 from label packets; waits for the pipeline to empty (DrawPipeline::Drain) 115; mutexes 32 136 (fence waits 61)
draw committer 171 (13%) 990 (78%): waiting for work (DrawPipeline::run) 781, GPU mutex 206 (commitDraw 174, commitLabel 26) 103 (fence waits 47)
async queue workers (4) 31–109 each WAIT_REG_MEM polling (PollSleep ← Driver::waitMemory) 855–968 each, mutexes 139–171 each (nearly all the GPU mutex) 5–44 each

The committer while queue 0's worker waits on the pipeline

  • While the worker waits for room (264 ms per frame), the committer is:
    • waiting for the GPU mutex 168 (64%);
    • in Vulkan calls 60 (23%, of which fence waits 24);
    • untraced 33 (13%);
    • waiting for work 0.
  • While the worker waits for the pipeline to empty (115 ms per frame): GPU mutex 36 (31%), untraced 46 (40%), Vulkan calls 31 (27%).

GPU

  • Busy 327 ms per frame (the union of the workloads), idle 74%. GR Active is above 0 in 27.4% of the GPU metrics samples.
  • 6,024 idle gaps, 262 per frame, 2,111 of them under 0.05 ms (p50 0.34 ms, p90 9.2 ms). In all but 0.1% of the idle time, the work
    that ended a gap was submitted inside it.
  • Idle time by the thread whose submit ended the gap, ms per frame:
    • queue 0's worker 283;
    • the committer 229;
    • the async workers 428 together (156, 130, 75, 67).

So on this scene the committer is outside traced calls at most 13% of the frame (171 ms), plus 56 ms (4%) in Vulkan calls other than
fence waits. The time queue 0's worker waits for room is mostly time the committer waits for the GPU mutex, which the async queue
workers and queue 0's worker also wait for. This capture does not show which thread holds it.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309486250 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6309486250). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-21T06:19:33Z. --- A data point from 007 First Light (PPSA11386) on Linux. On this title neither the committer (Astro Bot, SWAG, Yakuza 0, Stray) nor queue 0's worker (Sword of the Sea) is the busy thread. In gameplay the draw committer waits for work 62% of the frame. While queue 0's worker waits for room in the draw pipeline, the committer spends 64% of that time waiting for the GPU mutex. **Setup** - main 68323bae7 + #5799 #6868 #5372 #6918 #7643 #6679 (#5799 and #6679 have merged since), Release (GCC 16.2.1). No `APS5_*` switch other than the pad input file, so the pipeline depth and the spin windows are the defaults. - `DrawPipeline`'s waits, `HandoffSpin`, `WaitMemory` and `GpuMutexType::lock` are unchanged on main ec7eacc62d, apart from the committer sampler (#8075, Windows only, a no-op here). Only the code was compared; the numbers were not measured again on ec7eacc62d. - CachyOS, Linux 7.2.10, GNOME on Wayland with `SDL_VIDEODRIVER=x11` (XWayland), RTX 3080 (NVIDIA 615.78.08), Ryzen 9 7950X3D. - Gameplay about 4 minutes after Resume, Bond moving, warm shader cache; scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only). - One Nsight Systems 2026.3.2 capture: - `-t vulkan,osrt --vulkan-gpu-workload=individual -s none --cpuctxsw=none --gpu-metrics-devices=0`; - 23 frame intervals in 29.2 s, 1,269.5 ms per frame; - 2.2 million traced calls in the span (96k per frame), each with nsys's own cost. There is no uninstrumented frame time for the same stretch. - How the thread states are derived: - They are inferred from the traced OS runtime and Vulkan calls. CPU sampling and context switches were off; with either on, nsys failed to write the report on this setup. - "Untraced" is time in no traced call, an upper bound for CPU work. `vkCmdDraw*` and `vkCmdDispatch*` do not appear in the trace, so command recording counts as untraced. This capture gives no draw count per frame. - These are traced-call states, not the sampler or `APS5_TRACE_*` shares of the reports above, so the percentages are not directly comparable. - Spins before blocking count as untraced, so those waits are lower bounds: - GPU-mutex acquisitions and the committer's wait for work spin up to 150 µs (the automatic `HandoffSpin` window with more than 8 usable CPUs); - `DrawPipeline::Drain` spins up to 300 µs; - WAIT_REG_MEM waits spin up to 1.5 ms on queue 0 and 100 µs on the other queues before polling; - the wait for room does not spin. - Threads are identified by their call stacks. **Per thread, ms per frame (share of the frame)** | thread | untraced | waits | Vulkan calls | |---|---|---|---| | queue 0's worker | 690 (54%) | 434 (34%): room in the draw pipeline (`DrawPipeline::Enqueue`, default depth 8) 264, of which 43 from label packets; waits for the pipeline to empty (`DrawPipeline::Drain`) 115; mutexes 32 | 136 (fence waits 61) | | draw committer | 171 (13%) | 990 (78%): waiting for work (`DrawPipeline::run`) 781, GPU mutex 206 (`commitDraw` 174, `commitLabel` 26) | 103 (fence waits 47) | | async queue workers (4) | 31–109 each | WAIT_REG_MEM polling (`PollSleep` ← `Driver::waitMemory`) 855–968 each, mutexes 139–171 each (nearly all the GPU mutex) | 5–44 each | **The committer while queue 0's worker waits on the pipeline** - While the worker waits for room (264 ms per frame), the committer is: - waiting for the GPU mutex 168 (64%); - in Vulkan calls 60 (23%, of which fence waits 24); - untraced 33 (13%); - waiting for work 0. - While the worker waits for the pipeline to empty (115 ms per frame): GPU mutex 36 (31%), untraced 46 (40%), Vulkan calls 31 (27%). **GPU** - Busy 327 ms per frame (the union of the workloads), idle 74%. GR Active is above 0 in 27.4% of the GPU metrics samples. - 6,024 idle gaps, 262 per frame, 2,111 of them under 0.05 ms (p50 0.34 ms, p90 9.2 ms). In all but 0.1% of the idle time, the work that ended a gap was submitted inside it. - Idle time by the thread whose submit ended the gap, ms per frame: - queue 0's worker 283; - the committer 229; - the async workers 428 together (156, 130, 75, 67). So on this scene the committer is outside traced calls at most 13% of the frame (171 ms), plus 56 ms (4%) in Vulkan calls other than fence waits. The time queue 0's worker waits for room is mostly time the committer waits for the GPU mutex, which the async queue workers and queue 0's worker also wait for. This capture does not show which thread holds it. AI-assisted: yes (Claude Code)
SP4C3B4R-8 commented 2026-10-21 08:52:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-21T08:52:59Z.


@oneandonlydean thanks. Here is the draw-side end state, outlined before the bigger steps as you asked, with the same shape as the dispatch side (several prepared items feeding one recorder). Step 1 is up: #8992.

Where the committer's time goes now (main f894ba69d, Astro Bot Crash Site, Windows 11, RTX 5070 Ti, Ryzen 7 7800X3D, warm caches, 10.2 fps, APS5_PROFILE_DRAW=1, per 10 s): ~219k draws at 28 µs. lookup 1.90 s, record 1.48 s, vertex 0.93 s, readTarget 0.77 s (315k resident lookups walking 18.4M pages), pipeline 0.24 s, resources 0.22 s, keep 0.20 s, prepare 0.20 s, validate 0.12 s. Record + keep is ~27%; the rest is preparation. The GPU is busy ~65 ms of the ~98 ms frame, so the ceiling for this scene is roughly 15 fps.

Steps (each behind a switch, off by default, with before/after timings from the same scene):

  1. Graphics::Draw split into prepareDraw and recordPreparedDraw, no behaviour change (#8992).
  2. Make the prepare step's side effects explicit and movable. Today it calls, under the GPU mutex: recorder->Sync/PendingLabelIn (indirect records' path), BoundKeptBytes, SharedResourceCache().Insert, RetireDepthSurfaces/FlushDepthPlanes, materializeCmaskClear, the resident target refresh (CachedStorageSurface, StorageTexture refresh), CachedPipeline/AcquireFramebuffer, prepareDrawInputs (Recorder::SnapshotUse, GuestMemory::FlushGpuWrites), and resolveDrawResources (Revalidate, which mutates the cached template). This step splits them into what only reads (lookups, keys, proofs) and what must stay at record time in guest order (syncs, retires, cache inserts, template mutation), still on the committer.
  3. Prepare ahead on helpers: while the committer records draw N, helpers prepare draws N+1..N+k in guest order from the draw pipeline's queue. At record time the committer checks that nothing the prepared item read was written in between, by a CPU write (write-watch serial or epoch) or by a queued GPU item (the recorder's pending writes over the item's read ranges), and prepares again inline when it fails. The PR brings a test that writes in that window and fails without the check. Locally, 87.5% of draws read nothing the previous 16 draws write, so most prepared items should survive the check.
  4. Only if recording becomes the limit: per-pass secondary command buffers.

@teepean thanks for the offer. Measuring each step on Stray (committer-bound UE4, Linux) would help most, because it covers Linux and a different engine. I'll tag you on each PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312005659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6312005659). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-21T08:52:59Z. --- @oneandonlydean thanks. Here is the draw-side end state, outlined before the bigger steps as you asked, with the same shape as the dispatch side (several prepared items feeding one recorder). Step 1 is up: #8992. **Where the committer's time goes now** (`main` f894ba69d, Astro Bot Crash Site, Windows 11, RTX 5070 Ti, Ryzen 7 7800X3D, warm caches, 10.2 fps, `APS5_PROFILE_DRAW=1`, per 10 s): ~219k draws at 28 µs. lookup 1.90 s, record 1.48 s, vertex 0.93 s, readTarget 0.77 s (315k resident lookups walking 18.4M pages), pipeline 0.24 s, resources 0.22 s, keep 0.20 s, prepare 0.20 s, validate 0.12 s. Record + keep is ~27%; the rest is preparation. The GPU is busy ~65 ms of the ~98 ms frame, so the ceiling for this scene is roughly 15 fps. **Steps** (each behind a switch, off by default, with before/after timings from the same scene): 1. `Graphics::Draw` split into `prepareDraw` and `recordPreparedDraw`, no behaviour change (#8992). 2. Make the prepare step's side effects explicit and movable. Today it calls, under the GPU mutex: `recorder->Sync`/`PendingLabelIn` (indirect records' path), `BoundKeptBytes`, `SharedResourceCache().Insert`, `RetireDepthSurfaces`/`FlushDepthPlanes`, `materializeCmaskClear`, the resident target refresh (`CachedStorageSurface`, `StorageTexture` refresh), `CachedPipeline`/`AcquireFramebuffer`, `prepareDrawInputs` (`Recorder::SnapshotUse`, `GuestMemory::FlushGpuWrites`), and `resolveDrawResources` (`Revalidate`, which mutates the cached template). This step splits them into what only reads (lookups, keys, proofs) and what must stay at record time in guest order (syncs, retires, cache inserts, template mutation), still on the committer. 3. Prepare ahead on helpers: while the committer records draw N, helpers prepare draws N+1..N+k in guest order from the draw pipeline's queue. At record time the committer checks that nothing the prepared item read was written in between, by a CPU write (write-watch serial or epoch) or by a queued GPU item (the recorder's pending writes over the item's read ranges), and prepares again inline when it fails. The PR brings a test that writes in that window and fails without the check. Locally, 87.5% of draws read nothing the previous 16 draws write, so most prepared items should survive the check. 4. Only if recording becomes the limit: per-pass secondary command buffers. @teepean thanks for the offer. Measuring each step on Stray (committer-bound UE4, Linux) would help most, because it covers Linux and a different engine. I'll tag you on each PR.
SleglJan commented 2026-10-21 09:04:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-21T09:04:10Z.


In issuecomment-6309486250, queue 0's worker in 007 First Light (PPSA11386) mostly waits for room in the draw pipeline while the draw
committer waits for the GPU mutex, and that capture did not show who holds the mutex. The driver's [lock] lines from a longer profiled
run do: of the holds that ended while the committer waited, 98.7% by held time were the async compute queues' dispatch and indirect
holds.

Setup

  • main 68323bae7 + #5799 #6868 #5372 #6918 #7643 #6679 (#5799 and #6679 have merged since), Release (GCC 16.2.1).
  • What has changed on main 27c88a8d75:
    • No commit there changes where the dispatch paths take or release the GPU mutex, apart from #7154's FlushDepthPlanes, which takes
      it only when a stale depth plane overlaps.
    • #7870 has since kept released image memory in the buffer pool, which changes the allocations listed below.
    • #8066 moved thread-dimension (USE_THREAD_DIMENSIONS) indirect dispatches to the GPU path; this run never took the CPU path it replaced (its
      [indirect] counter shows 0 thread-dimension dispatches on the CPU side).
    • #7340 adds a GPU-mutex hold on queue 0's packet path: a guest flush packet after a draw takes the mutex to seal the pass's write-only stores. It is not on the dispatch paths, and it was not in the measured build, so it is not measured here.
    • Only the code was compared; the numbers were not measured again on 27c88a8d75.
  • CachyOS, Linux 7.2.10, GNOME on Wayland with SDL_VIDEODRIVER=x11 (XWayland), RTX 3080 (NVIDIA 615.78.08), Ryzen 9 7950X3D.
  • One gameplay run, Bond moving, warm shader cache; scripted input, and the title's two feedback-wait limits widened in its executable as
    described in #6172 (local only).
  • APS5_PROFILE_DRAW=1 APS5_TRACE_SUMMARY_EVERY=60. In a 60 s perf profile in this run's gameplay, their clock reads took about 4% of
    queue 0's CPU.
  • The window is about 49 minutes of gameplay, 2,549 presents (about 1.15 s per frame).
    • Each [lock] line covers its own period, so every figure is a share of that thread's covered time (2,943–2,947 s per thread).
    • The window includes three committer draw holds of 20–25 s and one 25 s hold on queue 0's worker, where presents drop to 1–4 per
      10 s. Without those four lines the committer holds 16.4% (draw 15.8) and waits 12.5%, and the 98.7% is unchanged.
  • How the columns are measured:
    • "GPU waits while holding" is the line's locked GPU waits: waits in Recorder::finish for a recorded batch whose fence was still
      unsignaled, made while the thread held the mutex. Other fence waits are not counted, so it is a lower bound.
    • "Holds that ended during its waits" sums, by holder and site, the holds that ended while the thread waited. A hold counts in full,
      including any part before the wait, so this is hold time, not wait time.

Share of time, per thread

thread holds the GPU mutex of which GPU waits while holding waits for it
queue 0's worker 44.0% (draw 24.7, indirect 10.5, dispatch 8.8) 6.3% 3.9%
draw committer 18.4% (draw 17.7) 3.2% 12.2% (at draw 9.7, label 2.1)
queue 0x20 7.2% (dispatch 7.0) 2.2% 11.3% (at the memory-access hook 8.3)
queue 0x38 4.7% (indirect 4.4) 1.0% 11.9% (at the hook 10.7)
queue 0x30 3.1% (dispatch 3.0) 0.3% 10.4% (at the hook 7.7)
queue 0x28 1.7% (dispatch 1.6) 0.3% 11.3% (at the hook 9.6)

Holds that ended during the committer's waits, by held time

  • 0x20 dispatch 51%, 0x38 indirect 23%, 0x30 dispatch 16%, 0x28 dispatch 7%, 0x38 dispatch 1%.
  • None behind queue 0's draw, dispatch or indirect holds; 0.1% behind the presenter.

The async holds

  • Mean and longest hold:
    • 0x20 dispatch 2.3 ms (max 52.9);
    • 0x38 indirect 2.1 ms (max 95.4);
    • 0x30 dispatch 3.4 ms (max 56.6);
    • 0x28 dispatch 1.1 ms (max 51.4).
  • GPU waits while holding are 30% of 0x20's hold time, 21% of 0x38's, 9% of 0x30's and 17% of 0x28's.
  • The Nsight Systems capture from that comment (same build) shows where the async queues' fence waits and allocations come from:
    • fence waits in StorageTexture::FlushPending (Recorder::Sync / FinishUpTo) under ShaderResources::Complete → buildComplete
      → resolveImageBinding or GuestBufferMemory::UploadFinish, in VulkanDevice::dispatch;
    • fence waits in StorageTexture::FlushPending under StorageTexture::Refresh (its caller is not in the stack);
    • fence waits for CPU reads of GPU-written memory in image-table resolution (Recorder::SyncThrough under
      GuestMemory::EqualsCommitted / ReadCommitted);
    • device-memory allocations (vkAllocateMemory), mostly from StorageTexture::Create; where the stack goes further, it is under
      resolveImageBinding. These stacks end before VulkanDevice::dispatch.
    • The capture has no CPU samples, only the stacks of blocking OS calls, so it does not give how much of the hold time each of these
      takes.

When the dispatch series' step 2 is up, I can measure it on this title the same way: the [lock] lines and the holds the committer waits
behind, same input, gameplay, Linux/NVIDIA.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312207539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6312207539). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-21T09:04:10Z. --- In issuecomment-6309486250, queue 0's worker in 007 First Light (PPSA11386) mostly waits for room in the draw pipeline while the draw committer waits for the GPU mutex, and that capture did not show who holds the mutex. The driver's `[lock]` lines from a longer profiled run do: of the holds that ended while the committer waited, 98.7% by held time were the async compute queues' dispatch and indirect holds. **Setup** - main 68323bae7 + #5799 #6868 #5372 #6918 #7643 #6679 (#5799 and #6679 have merged since), Release (GCC 16.2.1). - What has changed on main 27c88a8d75: - No commit there changes where the dispatch paths take or release the GPU mutex, apart from #7154's `FlushDepthPlanes`, which takes it only when a stale depth plane overlaps. - #7870 has since kept released image memory in the buffer pool, which changes the allocations listed below. - #8066 moved thread-dimension (USE_THREAD_DIMENSIONS) indirect dispatches to the GPU path; this run never took the CPU path it replaced (its `[indirect]` counter shows 0 thread-dimension dispatches on the CPU side). - #7340 adds a GPU-mutex hold on queue 0's packet path: a guest flush packet after a draw takes the mutex to seal the pass's write-only stores. It is not on the dispatch paths, and it was not in the measured build, so it is not measured here. - Only the code was compared; the numbers were not measured again on 27c88a8d75. - CachyOS, Linux 7.2.10, GNOME on Wayland with `SDL_VIDEODRIVER=x11` (XWayland), RTX 3080 (NVIDIA 615.78.08), Ryzen 9 7950X3D. - One gameplay run, Bond moving, warm shader cache; scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only). - `APS5_PROFILE_DRAW=1 APS5_TRACE_SUMMARY_EVERY=60`. In a 60 s perf profile in this run's gameplay, their clock reads took about 4% of queue 0's CPU. - The window is about 49 minutes of gameplay, 2,549 presents (about 1.15 s per frame). - Each `[lock]` line covers its own period, so every figure is a share of that thread's covered time (2,943–2,947 s per thread). - The window includes three committer draw holds of 20–25 s and one 25 s hold on queue 0's worker, where presents drop to 1–4 per 10 s. Without those four lines the committer holds 16.4% (draw 15.8) and waits 12.5%, and the 98.7% is unchanged. - How the columns are measured: - "GPU waits while holding" is the line's `locked GPU waits`: waits in `Recorder::finish` for a recorded batch whose fence was still unsignaled, made while the thread held the mutex. Other fence waits are not counted, so it is a lower bound. - "Holds that ended during its waits" sums, by holder and site, the holds that ended while the thread waited. A hold counts in full, including any part before the wait, so this is hold time, not wait time. **Share of time, per thread** | thread | holds the GPU mutex | of which GPU waits while holding | waits for it | |---|---|---|---| | queue 0's worker | 44.0% (draw 24.7, indirect 10.5, dispatch 8.8) | 6.3% | 3.9% | | draw committer | 18.4% (draw 17.7) | 3.2% | 12.2% (at draw 9.7, label 2.1) | | queue 0x20 | 7.2% (dispatch 7.0) | 2.2% | 11.3% (at the memory-access hook 8.3) | | queue 0x38 | 4.7% (indirect 4.4) | 1.0% | 11.9% (at the hook 10.7) | | queue 0x30 | 3.1% (dispatch 3.0) | 0.3% | 10.4% (at the hook 7.7) | | queue 0x28 | 1.7% (dispatch 1.6) | 0.3% | 11.3% (at the hook 9.6) | **Holds that ended during the committer's waits, by held time** - 0x20 dispatch 51%, 0x38 indirect 23%, 0x30 dispatch 16%, 0x28 dispatch 7%, 0x38 dispatch 1%. - None behind queue 0's draw, dispatch or indirect holds; 0.1% behind the presenter. **The async holds** - Mean and longest hold: - 0x20 dispatch 2.3 ms (max 52.9); - 0x38 indirect 2.1 ms (max 95.4); - 0x30 dispatch 3.4 ms (max 56.6); - 0x28 dispatch 1.1 ms (max 51.4). - GPU waits while holding are 30% of 0x20's hold time, 21% of 0x38's, 9% of 0x30's and 17% of 0x28's. - The Nsight Systems capture from that comment (same build) shows where the async queues' fence waits and allocations come from: - fence waits in `StorageTexture::FlushPending` (`Recorder::Sync` / `FinishUpTo`) under `ShaderResources::Complete` → `buildComplete` → `resolveImageBinding` or `GuestBufferMemory::UploadFinish`, in `VulkanDevice::dispatch`; - fence waits in `StorageTexture::FlushPending` under `StorageTexture::Refresh` (its caller is not in the stack); - fence waits for CPU reads of GPU-written memory in image-table resolution (`Recorder::SyncThrough` under `GuestMemory::EqualsCommitted` / `ReadCommitted`); - device-memory allocations (`vkAllocateMemory`), mostly from `StorageTexture::Create`; where the stack goes further, it is under `resolveImageBinding`. These stacks end before `VulkanDevice::dispatch`. - The capture has no CPU samples, only the stacks of blocking OS calls, so it does not give how much of the hold time each of these takes. When the dispatch series' step 2 is up, I can measure it on this title the same way: the `[lock]` lines and the holds the committer waits behind, same input, gameplay, Linux/NVIDIA. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-21 09:08:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T09:08:19Z.


@SP4C3B4R-8 thanks, this is the shape we described: helpers prepare in guest order, the committer checks each prepared item where it records it, and recording stays on one thread. The profile also shows why: most of the committer's time is preparation, not recording.

On step 3: the check has to cover both write paths you name, CPU writes since the item was prepared and GPU writes still queued over its read ranges. A test that writes in that window, as you plan, is the right proof. The 87.5% figure is one scene. Please give the survival rate per title in each step's description, because the speed-up depends on it.

For #8992 (step 1), the bar is no behaviour change: identical output and timings within noise on the same scene.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312286190 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6312286190). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T09:08:19Z. --- @SP4C3B4R-8 thanks, this is the shape we described: helpers prepare in guest order, the committer checks each prepared item where it records it, and recording stays on one thread. The profile also shows why: most of the committer's time is preparation, not recording. On step 3: the check has to cover both write paths you name, CPU writes since the item was prepared and GPU writes still queued over its read ranges. A test that writes in that window, as you plan, is the right proof. The 87.5% figure is one scene. Please give the survival rate per title in each step's description, because the speed-up depends on it. For #8992 (step 1), the bar is no behaviour change: identical output and timings within noise on the same scene.
teepean commented 2026-10-21 10:27:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by teepean on 2026-10-21T10:27:39Z.


@SP4C3B4R-8 thanks, I'll measure each step on Stray (PPSA02100) and post the numbers on the step's PR.

One thing to know about the setup: Stray is committer-bound on my stack (showcase/stray-stack). On plain main, queue 0's worker bounds this scene instead: in the runs for #8895, the worker was 97-98 % busy and the committer about 48 ms of a ~168 ms frame (main 7e95bde794). So for each step I'll give two things:

  • on main with and without the step: frames 26-39 of the Dead City start compared pixel by pixel, the committer's busy time per frame from tools/trace_digest.py, and FPS from balanced rounds;
  • on my stack, where the committer is the wall, the FPS change and the committer's time.

For #8992 that means main b5d763770a against main + #8992, both on Linux, Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), stock engine.ini. My bench is busy at the moment, so expect it later today or tomorrow.

@oneandonlydean on the survival rate per title: I counted it on Stray with a local diagnostic on my stack (same scene, about 730,000 pipelined draws per 10 s). For each pipelined draw, I checked whether one of the previous 16 committed pipeline items writes a range it reads. The reads were the index buffer, vertex buffers, buffer V#s and image T#s; the writes were each item's declared write ranges plus its attached labels and counter dumps.

  • 42 % of the draws read a range one of the previous 16 items writes, and 96 % of those hits are the item right before. So against every declared write, about 58 % of the prepared draws would survive the check.
  • Most of the hits come from one buffer: 27 % of all draws read a 129,600-byte buffer (240 × 135 × 4, a 16-pixel grid at 3840x2160) that every one of them also declares written. It looks like UE4's virtual-texture feedback buffer, which pixel shaders write in no order. It is bound in place on the GPU, so no CPU-side preparation reads its contents.
  • 15 % sample a texture that was a render target 1 to 4 draws back (post-process chains). Those are GPU images too.
  • 4 % read through the BDA table or image tables, so their read set is unbounded.

So on Stray the rate depends on what the check compares. Against every declared write, it is about 58 %. If it only looks at what preparation read on the CPU (snapshots, uploads, synchronized reads), in-place buffers and GPU images drop out, and most of the 42 % would survive. CPU writes would still be caught, as you asked.

AI-assisted: yes (text with Claude Code; the counts are from my machine).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313742203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6313742203). Originally posted by [teepean](https://github.com/teepean) on 2026-10-21T10:27:39Z. --- @SP4C3B4R-8 thanks, I'll measure each step on Stray (PPSA02100) and post the numbers on the step's PR. One thing to know about the setup: Stray is committer-bound on my stack ([`showcase/stray-stack`](https://github.com/teepean/AnyPS5/tree/showcase/stray-stack)). On plain `main`, queue 0's worker bounds this scene instead: in the runs for #8895, the worker was 97-98 % busy and the committer about 48 ms of a ~168 ms frame (`main` 7e95bde794). So for each step I'll give two things: - on `main` with and without the step: frames 26-39 of the Dead City start compared pixel by pixel, the committer's busy time per frame from `tools/trace_digest.py`, and FPS from balanced rounds; - on my stack, where the committer is the wall, the FPS change and the committer's time. For #8992 that means `main` b5d763770a against `main` + #8992, both on Linux, Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), stock `engine.ini`. My bench is busy at the moment, so expect it later today or tomorrow. @oneandonlydean on the survival rate per title: I counted it on Stray with a local diagnostic on my stack (same scene, about 730,000 pipelined draws per 10 s). For each pipelined draw, I checked whether one of the previous 16 committed pipeline items writes a range it reads. The reads were the index buffer, vertex buffers, buffer V#s and image T#s; the writes were each item's declared write ranges plus its attached labels and counter dumps. - 42 % of the draws read a range one of the previous 16 items writes, and 96 % of those hits are the item right before. So against every declared write, about 58 % of the prepared draws would survive the check. - Most of the hits come from one buffer: 27 % of all draws read a 129,600-byte buffer (240 × 135 × 4, a 16-pixel grid at 3840x2160) that every one of them also declares written. It looks like UE4's virtual-texture feedback buffer, which pixel shaders write in no order. It is bound in place on the GPU, so no CPU-side preparation reads its contents. - 15 % sample a texture that was a render target 1 to 4 draws back (post-process chains). Those are GPU images too. - 4 % read through the BDA table or image tables, so their read set is unbounded. So on Stray the rate depends on what the check compares. Against every declared write, it is about 58 %. If it only looks at what preparation read on the CPU (snapshots, uploads, synchronized reads), in-place buffers and GPU images drop out, and most of the 42 % would survive. CPU writes would still be caught, as you asked. AI-assisted: yes (text with Claude Code; the counts are from my machine).
oneandonlydean commented 2026-10-21 10:39:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T10:39:57Z.


@teepean thanks, those counts answer the question better than any estimate. I agree with your reading. What the check has to protect is what preparation consumed on the CPU (snapshots, uploads, synchronized reads, and the descriptor and table words it decoded), compared against CPU writes since the item was prepared and GPU writes still queued over those ranges. A buffer bound in place and an image sampled on the GPU are ordered by the queue itself, so they don't need the check. That puts PPSA02100 well above 58 %.

One caveat for the 4 % that read through the BDA table or image tables: if preparation resolves those tables on the CPU, the table words themselves are a CPU read, so a queued write over them has to fail the check. If the read set can't be bounded, those draws should fall back to recording in place, not be treated as unchanged.

The per-step plan sounds right. On main the worker is the wall, so the committer's busy time and the pixel comparison are the numbers to watch there.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313958258 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6313958258). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T10:39:57Z. --- @teepean thanks, those counts answer the question better than any estimate. I agree with your reading. What the check has to protect is what preparation consumed on the CPU (snapshots, uploads, synchronized reads, and the descriptor and table words it decoded), compared against CPU writes since the item was prepared and GPU writes still queued over those ranges. A buffer bound in place and an image sampled on the GPU are ordered by the queue itself, so they don't need the check. That puts PPSA02100 well above 58 %. One caveat for the 4 % that read through the BDA table or image tables: if preparation resolves those tables on the CPU, the table words themselves are a CPU read, so a queued write over them has to fail the check. If the read set can't be bounded, those draws should fall back to recording in place, not be treated as unchanged. The per-step plan sounds right. On `main` the worker is the wall, so the committer's busy time and the pixel comparison are the numbers to watch there.
00xDisaster commented 2026-10-21 22:22:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-21T22:22:22Z.


We are not working on the full draw preparation (preparing draws N+1..N+k off the GPU mutex with a validity check at record time, or secondary command buffers per render pass) — the resource cache, the texture and storage registries and the recorder's snapshot arena are the part we have no answer for.

We do have a measurement of the part that the pipeline preparation covers, which may be useful here.

PR #5925 builds the pipelines of a submission ahead on a compile pool. I ported that feature onto current main and measured it on Pumpkin Jack (PPSA03446), a UE4 title, with a fixed camera and warm caches:

lookahead off lookahead on
worst draw 7,467.1 ms 1,075.2 ms
worst pipeline phase 15,763.4 ms 2,473.3 ms
pipelines built by the pool — 477 (0 build failures)
pipeline lookups by the pool — 144,143

So on that title the pipeline build is no longer on the draw's critical path. What the committer still spends is what this issue measures in Astro Bot — the lookups, the recording and the resource work (lookup 2.0 s, record 1.47 s, vertex 0.82 s of the 88 ms the committer is busy). The draw preparation you describe is what is left, and the same shape of problem is in #5485, #5345, #5529, #6257 and #8068.

The measurement and the port of the lookahead are in #5925.

AI-assisted: no

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327846709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7895#issuecomment-6327846709). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-21T22:22:22Z. --- We are not working on the full draw preparation (preparing draws N+1..N+k off the GPU mutex with a validity check at record time, or secondary command buffers per render pass) — the resource cache, the texture and storage registries and the recorder's snapshot arena are the part we have no answer for. We do have a measurement of the part that the pipeline preparation covers, which may be useful here. PR #5925 builds the pipelines of a submission ahead on a compile pool. I ported that feature onto current `main` and measured it on Pumpkin Jack (PPSA03446), a UE4 title, with a fixed camera and warm caches: | | lookahead off | lookahead on | |---|---|---| | worst draw | 7,467.1 ms | 1,075.2 ms | | worst pipeline phase | 15,763.4 ms | 2,473.3 ms | | pipelines built by the pool | — | 477 (0 build failures) | | pipeline lookups by the pool | — | 144,143 | So on that title the pipeline build is no longer on the draw's critical path. What the committer still spends is what this issue measures in Astro Bot — the lookups, the recording and the resource work (lookup 2.0 s, record 1.47 s, vertex 0.82 s of the 88 ms the committer is busy). The draw preparation you describe is what is left, and the same shape of problem is in #5485, #5345, #5529, #6257 and #8068. The measurement and the port of the lookahead are in #5925. AI-assisted: no
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#7895
No description provided.