perf(agc): destroy deferred MoltenVK objects when the queue is already idle #11587

Open
imellag wants to merge 5 commits from upstream-pr/11587 into main
imellag commented 2026-10-26 21:48:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-26T21:48:17Z.


What

On MoltenVK, #10062 destroys released buffers and device memory only while the graphics queue is idle (KhronosGroup/MoltenVK#2876). Before every recorder or command batch submission it drains the queue once 512 objects wait or the oldest has waited 100 ms. A title that releases buffers all the time reaches the 100 ms bound about ten times a second, and each vkQueueWaitIdle stops the queue worker until the GPU has finished everything queued. That cost was not measured in #10062.

With this change the recorder also passes whether every batch it has submitted has completed: its timeline semaphore against its submission count, read with vkGetSemaphoreCounterValueKHR, without waiting. When they have, and the oldest deferred object has waited 30 ms, the drain runs at once. It still calls vkQueueWaitIdle, so the guarantee #2876 needs is unchanged, but the queue is already idle. A title whose GPU finishes a frame before the next one starts now drains about once a frame, between frames.

  • The 512-object and 100 ms bounds stay as they were, for a queue that never goes idle and for CommandBatch submissions.
  • Only MoltenVK defers destruction. On other drivers the deferred list is empty, so the recorder only adds one DeferredObjects lookup per submission.
  • Why 30 ms: with 8 ms the idle drains also ran mid-frame, whenever the GPU caught up between small batches. Each one is a GPU round trip in MoltenVK's waitIdle (an empty command buffer committed and waited for), and Planet of Lana lost about 2% against no deferral. With 30 ms it is about 1%.
  • agc_deferred_destruction covers three new cases:
    • an idle queue with objects younger than 30 ms: no drain;
    • a busy queue at 31 ms: no drain;
    • an idle queue at 31 ms: the queue wait, then the buffer.
  • The debt entry describes the new rule.

Tested

Current main (2026-10-27), clean commits. Base 9f6232f229eb is main 3fea2a937b plus the 8 macOS PRs listed on #1 (fork branch bench/main-boot-1027); the change 87853364575c is the base plus this commit (bench/dd-pr). main now has #11142, which removed most buffer creations, so the drains this PR avoids are rare there: the base committer spends 0.1 ms per frame in Recorder.Submit, not 3.5 ms.

  • Lana, alternating 120 s runs with mimalloc, fps from 85 s: base 30.31, 30.63; this PR 30.48, 30.69.
  • trace_digest, 95:10: base 302 presents, p50 32.9 / p90 34.9 / p99 44.5 / max 53.0 ms; this PR 306 presents, p50 32.6 / p90 34.6 / p99 37.7 / max 42.5 ms.
  • agc_deferred_destruction and agc_buffer_pool pass 3 of 3.

The runs below are from the earlier base (main 035ac96edd with the macOS PRs), before #11142.

macOS 27.0.1, Apple M4 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), x86-64 Release under Rosetta 2. main does not build and run on macOS, so this ran on main 035ac96edd + #10366 #10552 #7631 #7804 #11249 #10669 #10540 #11447 #11047 #11048 #10876 #9263 and a local patch that loads libvulkan.1.dylib, without and with this commit. Every run had mimalloc injected with DYLD_INSERT_LIBRARIES (as #11130 does on request), and the same shader cache.

Planet of Lana (PPSA19450), New Game into the village, 120 s runs, alternated, fps from 85 s:

runs (fps) Driver.Packet frame p90 / p99
main (#10062 as merged) 28.33, 28.49, 28.36, 24.52 24.0-25.4 ms 45 / 50 ms
this PR 29.38, 29.12 21.0-21.3 ms 35.5 / 39-41 ms
APS5_NO_DEFERRED_DESTRUCTION=1 29.64, 29.78, 29.82, 29.55, 29.58, 29.59 21.3-21.7 ms

tools/trace_digest.py on the APS5_TRACE_SUMMARY_EVERY=10 summaries, gameplay intervals (attached):

  • main: 70-110 s, 277-284 presents per 10 s, p50 33.7-34.7, p90 44.8-45.9, p99 49.2-54.5 ms, largest phase Driver.Packet 23.9-24.4 ms per frame
  • this PR: 60-100 s, 291-294 presents per 10 s, p50 33.8-34.1, p90 35.4-35.8, p99 39.0-48.5 ms, largest phase Driver.Packet 20.9-21.1 ms per frame

Summary lines of the attached traces (APS5_TRACE_SECONDS=95:10 APS5_TRACE_EVENTS=1048576, window 95-105 s; the change build is marked dirty because the 30 ms constant was edited before the commit, its code equals this head apart from the debt text and the test):

main:

{"commit":"c930034b60a8","dirty":false,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"95:10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"Apple M4 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":12,"memory_mib":24576,"title_id":"PPSA19450","title":"Planet of Lana","content_version":"01.010.000","resolution":"3840x2160","window":{"spec":"seconds 95:10","first_present":3968,"ms":10041.083},"presents":287,"frame_ms":{"p50":33.333,"p90":44.751,"p99":48.517,"max":51.355},"gpu_busy_ms_per_present":21.749,"worker_busy_pct":{"queue worker 0x0":69.718},"top_phases_ms_per_frame":{"Driver.Packet":23.883,"Driver.Packet.draw":18.592,"Driver.Draw":18.431,"Graphics.Draw":15.645,"Graphics.Draw.draw_and_resource_release":12.029,"VideoOut.Flip":10.065,"Driver.Present":9.268,"VideoOut.Flip.present":9.258},"trace_dropped":false,"trace":"aps5-trace-c930034b60a8-41812.json.gz"}

This PR:

{"commit":"33dbe48a8e0d","dirty":true,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"95:10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"Apple M4 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":12,"memory_mib":24576,"title_id":"PPSA19450","title":"Planet of Lana","content_version":"01.010.000","resolution":"3840x2160","window":{"spec":"seconds 95:10","first_present":4015,"ms":10013.230},"presents":294,"frame_ms":{"p50":33.789,"p90":35.790,"p99":39.741,"max":41.878},"gpu_busy_ms_per_present":24.335,"worker_busy_pct":{"queue worker 0x0":62.869},"top_phases_ms_per_frame":{"Driver.Packet":20.976,"Driver.Packet.draw":16.603,"Driver.Draw":16.448,"Graphics.Draw":15.388,"VideoOut.Flip":12.220,"Graphics.Draw.draw_and_resource_release":11.782,"Driver.Present":11.413,"VideoOut.Flip.present":11.383},"trace_dropped":false,"trace":"aps5-trace-33dbe48a8e0d-45115.json.gz"}

Stray (PPSA02100), the title #10062 was written for, 180 s runs pressing cross into the game, MTL_DEBUG_LAYER=1, a MoltenVK without residency sets (where #2876 still crashes without the deferral):

  • APS5_NO_DEFERRED_DESTRUCTION=1: segmentation fault after about 30 s (status 139), so #2876 still reproduces on this setup.
  • main: 3 of 3 runs reach 180 s, no device loss, no Metal assertion.
  • This PR: 5 runs, no device loss and no Metal assertion in any. 4 reach 180 s. In the fifth the game stopped presenting after about 71 s, waiting on a WAIT_REG_MEM (the AGC wait diagnostic printed). The same diagnostic appears in 5 of 12 Stray runs on 2026-10-24 without this change, so I don't attribute it to this PR.
  • Stray's frame rate is the same in both: 2.8-3.2 fps with the Metal debug layer.

Tests:

  • agc_deferred_destruction and agc_buffer_pool pass with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: no VUID- line, no "was not found but was requested by env var VK_INSTANCE_LAYERS". agc_deferred_destruction uses a mock device.
  • tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py finds no conflicting lines. It could not compare the open pull requests that conflict with main; of those, #5609 also edits Recorder.cpp.

Not tested: Linux and Windows (the path only runs on MoltenVK), GCC.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M4 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), macOS 27.0.1
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5025159144 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11587). Originally posted by [imellag](https://github.com/imellag) on 2026-10-26T21:48:17Z. --- ### What On MoltenVK, #10062 destroys released buffers and device memory only while the graphics queue is idle (KhronosGroup/MoltenVK#2876). Before every recorder or command batch submission it drains the queue once 512 objects wait or the oldest has waited 100 ms. A title that releases buffers all the time reaches the 100 ms bound about ten times a second, and each `vkQueueWaitIdle` stops the queue worker until the GPU has finished everything queued. That cost was not measured in #10062. With this change the recorder also passes whether every batch it has submitted has completed: its timeline semaphore against its submission count, read with `vkGetSemaphoreCounterValueKHR`, without waiting. When they have, and the oldest deferred object has waited 30 ms, the drain runs at once. It still calls `vkQueueWaitIdle`, so the guarantee #2876 needs is unchanged, but the queue is already idle. A title whose GPU finishes a frame before the next one starts now drains about once a frame, between frames. - The 512-object and 100 ms bounds stay as they were, for a queue that never goes idle and for `CommandBatch` submissions. - Only MoltenVK defers destruction. On other drivers the deferred list is empty, so the recorder only adds one `DeferredObjects` lookup per submission. - Why 30 ms: with 8 ms the idle drains also ran mid-frame, whenever the GPU caught up between small batches. Each one is a GPU round trip in MoltenVK's `waitIdle` (an empty command buffer committed and waited for), and Planet of Lana lost about 2% against no deferral. With 30 ms it is about 1%. - `agc_deferred_destruction` covers three new cases: - an idle queue with objects younger than 30 ms: no drain; - a busy queue at 31 ms: no drain; - an idle queue at 31 ms: the queue wait, then the buffer. - The debt entry describes the new rule. ### Tested **Current `main` (2026-10-27), clean commits.** Base `9f6232f229eb` is `main` `3fea2a937b` plus the 8 macOS PRs listed on #1 (fork branch `bench/main-boot-1027`); the change `87853364575c` is the base plus this commit (`bench/dd-pr`). `main` now has #11142, which removed most buffer creations, so the drains this PR avoids are rare there: the base committer spends 0.1 ms per frame in `Recorder.Submit`, not 3.5 ms. - Lana, alternating 120 s runs with mimalloc, fps from 85 s: base 30.31, 30.63; this PR 30.48, 30.69. - `trace_digest`, 95:10: base 302 presents, p50 32.9 / p90 34.9 / p99 44.5 / max 53.0 ms; this PR 306 presents, p50 32.6 / p90 34.6 / p99 37.7 / max 42.5 ms. - `agc_deferred_destruction` and `agc_buffer_pool` pass 3 of 3. The runs below are from the earlier base (`main` `035ac96edd` with the macOS PRs), before #11142. macOS 27.0.1, Apple M4 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), x86-64 Release under Rosetta 2. `main` does not build and run on macOS, so this ran on `main` `035ac96edd` + #10366 #10552 #7631 #7804 #11249 #10669 #10540 #11447 #11047 #11048 #10876 #9263 and a local patch that loads `libvulkan.1.dylib`, without and with this commit. Every run had mimalloc injected with `DYLD_INSERT_LIBRARIES` (as #11130 does on request), and the same shader cache. **Planet of Lana (PPSA19450)**, New Game into the village, 120 s runs, alternated, fps from 85 s: | | runs (fps) | Driver.Packet | frame p90 / p99 | |---|---|---|---| | `main` (#10062 as merged) | 28.33, 28.49, 28.36, 24.52 | 24.0-25.4 ms | 45 / 50 ms | | this PR | 29.38, 29.12 | 21.0-21.3 ms | 35.5 / 39-41 ms | | `APS5_NO_DEFERRED_DESTRUCTION=1` | 29.64, 29.78, 29.82, 29.55, 29.58, 29.59 | 21.3-21.7 ms | | `tools/trace_digest.py` on the `APS5_TRACE_SUMMARY_EVERY=10` summaries, gameplay intervals (attached): - `main`: 70-110 s, 277-284 presents per 10 s, p50 33.7-34.7, p90 44.8-45.9, p99 49.2-54.5 ms, largest phase Driver.Packet 23.9-24.4 ms per frame - this PR: 60-100 s, 291-294 presents per 10 s, p50 33.8-34.1, p90 35.4-35.8, p99 39.0-48.5 ms, largest phase Driver.Packet 20.9-21.1 ms per frame Summary lines of the attached traces (`APS5_TRACE_SECONDS=95:10 APS5_TRACE_EVENTS=1048576`, window 95-105 s; the change build is marked dirty because the 30 ms constant was edited before the commit, its code equals this head apart from the debt text and the test): `main`: ```json {"commit":"c930034b60a8","dirty":false,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"95:10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"Apple M4 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":12,"memory_mib":24576,"title_id":"PPSA19450","title":"Planet of Lana","content_version":"01.010.000","resolution":"3840x2160","window":{"spec":"seconds 95:10","first_present":3968,"ms":10041.083},"presents":287,"frame_ms":{"p50":33.333,"p90":44.751,"p99":48.517,"max":51.355},"gpu_busy_ms_per_present":21.749,"worker_busy_pct":{"queue worker 0x0":69.718},"top_phases_ms_per_frame":{"Driver.Packet":23.883,"Driver.Packet.draw":18.592,"Driver.Draw":18.431,"Graphics.Draw":15.645,"Graphics.Draw.draw_and_resource_release":12.029,"VideoOut.Flip":10.065,"Driver.Present":9.268,"VideoOut.Flip.present":9.258},"trace_dropped":false,"trace":"aps5-trace-c930034b60a8-41812.json.gz"} ``` This PR: ```json {"commit":"33dbe48a8e0d","dirty":true,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"95:10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"Apple M4 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.0.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":12,"memory_mib":24576,"title_id":"PPSA19450","title":"Planet of Lana","content_version":"01.010.000","resolution":"3840x2160","window":{"spec":"seconds 95:10","first_present":4015,"ms":10013.230},"presents":294,"frame_ms":{"p50":33.789,"p90":35.790,"p99":39.741,"max":41.878},"gpu_busy_ms_per_present":24.335,"worker_busy_pct":{"queue worker 0x0":62.869},"top_phases_ms_per_frame":{"Driver.Packet":20.976,"Driver.Packet.draw":16.603,"Driver.Draw":16.448,"Graphics.Draw":15.388,"VideoOut.Flip":12.220,"Graphics.Draw.draw_and_resource_release":11.782,"Driver.Present":11.413,"VideoOut.Flip.present":11.383},"trace_dropped":false,"trace":"aps5-trace-33dbe48a8e0d-45115.json.gz"} ``` **Stray (PPSA02100)**, the title #10062 was written for, 180 s runs pressing cross into the game, `MTL_DEBUG_LAYER=1`, a MoltenVK without residency sets (where #2876 still crashes without the deferral): - `APS5_NO_DEFERRED_DESTRUCTION=1`: segmentation fault after about 30 s (status 139), so #2876 still reproduces on this setup. - `main`: 3 of 3 runs reach 180 s, no device loss, no Metal assertion. - This PR: 5 runs, no device loss and no Metal assertion in any. 4 reach 180 s. In the fifth the game stopped presenting after about 71 s, waiting on a `WAIT_REG_MEM` (the AGC wait diagnostic printed). The same diagnostic appears in 5 of 12 Stray runs on 2026-10-24 without this change, so I don't attribute it to this PR. - Stray's frame rate is the same in both: 2.8-3.2 fps with the Metal debug layer. **Tests:** - `agc_deferred_destruction` and `agc_buffer_pool` pass with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: no `VUID-` line, no "was not found but was requested by env var VK_INSTANCE_LAYERS". `agc_deferred_destruction` uses a mock device. - `tools/check_conventions.py --base upstream/main` passes. - `tools/pr_overlap.py` finds no conflicting lines. It could not compare the open pull requests that conflict with `main`; of those, #5609 also edits `Recorder.cpp`. Not tested: Linux and Windows (the path only runs on MoltenVK), GCC. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Apple M4 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), macOS 27.0.1 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 22:08:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T22:08:11Z.

Review: APPROVED


Reviewed head 8738e58545556d451c19edf05d62167d93dcb081. The 30 ms path is gated on the recorder timeline having completed all submitted batches; the existing 512-object and 100 ms drains remain the fallback when that condition is false. The added mock cases cover young idle, older busy, and older idle queues.

I downloaded both attached event traces and reran tools/trace_digest.py against the corresponding pasted summary lines. It matched the reported windows and no-drop flags: 287 presents on the baseline and 294 on the change, with p90/p99 of 44.751/48.517 ms and 35.790/39.741 ms respectively. The baseline’s macOS compatibility stack is disclosed in the PR description; both captures use the same title, scene, machine and MoltenVK setup. The report gives useful frame-tail improvement, while the no-deferral comparison indicates some remaining overhead.

Conventions, labels, eligibility, intake and report checks pass. Product, relinker and write-watch jobs are path-skipped. The author reports focused Vulkan validation tests and native title runs on the stated machine. No issue found in the reviewed code or evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5659766195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11587#pullrequestreview-5659766195). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T22:08:11Z. **Review:** APPROVED --- Reviewed head `8738e58545556d451c19edf05d62167d93dcb081`. The 30 ms path is gated on the recorder timeline having completed all submitted batches; the existing 512-object and 100 ms drains remain the fallback when that condition is false. The added mock cases cover young idle, older busy, and older idle queues. I downloaded both attached event traces and reran `tools/trace_digest.py` against the corresponding pasted summary lines. It matched the reported windows and no-drop flags: 287 presents on the baseline and 294 on the change, with p90/p99 of 44.751/48.517 ms and 35.790/39.741 ms respectively. The baseline’s macOS compatibility stack is disclosed in the PR description; both captures use the same title, scene, machine and MoltenVK setup. The report gives useful frame-tail improvement, while the no-deferral comparison indicates some remaining overhead. Conventions, labels, eligibility, intake and report checks pass. Product, relinker and write-watch jobs are path-skipped. The author reports focused Vulkan validation tests and native title runs on the stated machine. No issue found in the reviewed code or evidence.
CnRJay commented 2026-11-01 19:49:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:23Z.

Review: COMMENTED


Two things I would want settled before this goes in.

1. The numbers on current main do not show a gain. On main after #11142 the PR's own figures are fps 30.31 / 30.63 (base) against 30.48 / 30.69 (change), which is inside the run-to-run spread of the base itself (0.3 fps). The p99 improvement (44.5 to 37.7 ms) is one trace_digest capture per arm, so there is no repeat to tell it from noise. The description also says the base committer now spends 0.1 ms per frame in Recorder.Submit. The larger wins come from the earlier base, which predates #11142 and no longer exists. Please repeat the trace_digest pair at least twice per arm on the current base, or say plainly that this is a no-op there.

2. Cost and tuning.

  • Recorder.cpp: every submission with a non-empty deferred list now calls vkGetSemaphoreCounterValueKHR. That is cheap on MoltenVK, but it is new work on a path that runs per batch.
  • IdleDrainAge = 30 ms was picked from one title ("with 8 ms Planet of Lana lost about 2%, with 30 ms about 1%"). That is a threshold tuned to one title, and the change still loses about 1% against no deferral there. Why is that acceptable, and what is the reasoning for 30 rather than a value derived from the frame time?
  • The idle check is a snapshot: the timeline value equals the submission count at the moment of the read, and then vkQueueWaitIdle runs. If another thread can submit in between, the "already idle" drain can still block on new work. Is submission to this queue serialised against Submit's drain? If so, a comment in the PR description would help; if not, the guarantee in the description is weaker than stated.

The new test cases cover the age/idle matrix well, but none of them can fail on a wrong queueIdle computation in Recorder.cpp, since the test passes the flag in by hand.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11587#pullrequestreview-5729922125). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:23Z. **Review:** COMMENTED --- Two things I would want settled before this goes in. **1. The numbers on current main do not show a gain.** On main after #11142 the PR's own figures are fps 30.31 / 30.63 (base) against 30.48 / 30.69 (change), which is inside the run-to-run spread of the base itself (0.3 fps). The p99 improvement (44.5 to 37.7 ms) is one `trace_digest` capture per arm, so there is no repeat to tell it from noise. The description also says the base committer now spends 0.1 ms per frame in `Recorder.Submit`. The larger wins come from the earlier base, which predates #11142 and no longer exists. Please repeat the `trace_digest` pair at least twice per arm on the current base, or say plainly that this is a no-op there. **2. Cost and tuning.** - `Recorder.cpp`: every submission with a non-empty deferred list now calls `vkGetSemaphoreCounterValueKHR`. That is cheap on MoltenVK, but it is new work on a path that runs per batch. - `IdleDrainAge = 30 ms` was picked from one title ("with 8 ms Planet of Lana lost about 2%, with 30 ms about 1%"). That is a threshold tuned to one title, and the change still loses about 1% against no deferral there. Why is that acceptable, and what is the reasoning for 30 rather than a value derived from the frame time? - The idle check is a snapshot: the timeline value equals the submission count at the moment of the read, and then `vkQueueWaitIdle` runs. If another thread can submit in between, the "already idle" drain can still block on new work. Is submission to this queue serialised against `Submit`'s drain? If so, a comment in the PR description would help; if not, the guarantee in the description is weaker than stated. The new test cases cover the age/idle matrix well, but none of them can fail on a wrong `queueIdle` computation in `Recorder.cpp`, since the test passes the flag in by hand.
MarcZX10 commented 2026-11-20 09:53:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:53:23Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review supports merging, with the optional note below.

What I ran

Reviewed head e0aecc7bb67dcdf5b027e04e750c0d242103aea0 using repo_read.py to inspect the prepared description, commit list, manifest, diff, and targeted source context. No commands or tests were run.

Results

Check Result Note
Code review passed Changed logic and call sites inspected
Tests not run Author-reported test runs only

Findings

Blocking

None.

Non-blocking

  • The new timeline-counter query is only used to decide whether the recorder queue is idle when a submission is considered. The safety condition is conservative: a failed query leaves queueIdle false, and a successful query must reach the prior submission count before the idle-age path can drain. Consider a focused test for this decision path, including a failed query and a counter below the submitted serial.

Not verified

  • No build or tests were run; the test results in the PR description are author-reported.
  • Read all five changed files listed in manifest.json; no changed files were excluded there. files.json was unavailable through the reader, so any exclusions beyond the manifest are not verified.
  • Hardware performance measurements and behavior on Linux or Windows were not independently verified.

To get this to a good state

Nothing is required. The optional test coverage point is listed above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990753332 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11587#pullrequestreview-5990753332). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T09:53:23Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review supports merging, with the optional note below. ## What I ran Reviewed head `e0aecc7bb67dcdf5b027e04e750c0d242103aea0` using `repo_read.py` to inspect the prepared description, commit list, manifest, diff, and targeted source context. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Changed logic and call sites inspected | | Tests | not run | Author-reported test runs only | ## Findings ### Blocking None. ### Non-blocking - The new timeline-counter query is only used to decide whether the recorder queue is idle when a submission is considered. The safety condition is conservative: a failed query leaves `queueIdle` false, and a successful query must reach the prior submission count before the idle-age path can drain. Consider a focused test for this decision path, including a failed query and a counter below the submitted serial. ## Not verified - No build or tests were run; the test results in the PR description are author-reported. - Read all five changed files listed in `manifest.json`; no changed files were excluded there. `files.json` was unavailable through the reader, so any exclusions beyond the manifest are not verified. - Hardware performance measurements and behavior on Linux or Windows were not independently verified. ## To get this to a good state Nothing is required. The optional test coverage point is listed above.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/11587:upstream-pr/11587'
git switch 'upstream-pr/11587'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/11587'
git switch 'upstream-pr/11587'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/11587'
git switch 'upstream-pr/11587'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/11587'
git switch 'main'
git merge --squash 'upstream-pr/11587'
git switch 'main'
git merge --ff-only 'upstream-pr/11587'
git switch 'main'
git merge 'upstream-pr/11587'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11587
No description provided.