AGC: on a cold shader cache, the first submission waits for every queued registration preparation; Ghost of Yōtei reaches its loading spinner 2.6x later than with APS5_LAZY_SHADER_PREPARE=1 #6846

Open
opened 2026-10-16 14:10:43 +00:00 by Pipodi · 2 comments
Pipodi commented 2026-10-16 14:10:43 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T14:10:43Z.


What happens

On a cold shader cache, Ghost of Yōtei (PPSA26344) shows a black screen for 80–180 s before its first frame. With a warm cache, the first frame comes at about 40 s. While the screen is black, about 1.3 CPU cores are busy.

Thread dumps at 45 s and 70 s (main 82ddae75b, cold) show:

  • the render thread and one job worker in Driver::Submit → AwaitRegistrationPreparation;
  • one registration prepare thread in the recompiler front end (Structurizer::computeDominatorTree / tarjanVisit);
  • the other 16 prepare threads idle.

In the first 10 s the title registers about 1,600 shaders, and almost all of them are prepared within that window. A few giant registrations, about 21 MiB of SPIR-V each, stay in the pool for tens of seconds. Since #5007, Driver::Submit waits for every preparation queued before it, not only the ones its commands use. So the first submission waits for those giants. The debt entry "Registration preparation at submit" in docs/dev/debt/libSceAgcDriver.md already describes this case.

Measured

Windows 11 Pro 26200, RTX 4090, driver 617.42. main 82ddae75b plus #6227, which this title needs to start on current main, plus a local crash-report thread-dump hook. Each run has its own empty shader cache directory.

Run APS5_LAZY_SHADER_PREPARE First frame Frame 619 (heavy load starts) Frame 768 (spinner) Recompiler cache misses by 360 s
run180 unset 181 s 281 s not reached by 360 s 11,721
run182 unset 80 s 201 s 623 s n/a
run181 1 40 s 100 s not reached by 360 s 219
run183 1 40 s 100 s 241 s n/a
run165 (warm cache, older tree) unset 40 s 101 s 241 s 0
  • The eager boot varies from run to run. run182 came after run180 with NVIDIA's own driver cache warmer, so its 80 s is the better case.
  • With lazy preparation, the first frame and frame 619 match the warm run in both lazy runs. Past frame 619 the lazy runs differ: run183 matched the warm run to the spinner, while run181 was still at frame 692 at 360 s. Two runs per arm are not enough to say how much of the loading phase lazy preparation saves. Neither lazy run showed new errors, and both had the same 120 "could not be prepared at registration" lines as the eager runs.
  • Both arms later hit a separate NVIDIA driver crash during graphics pipeline creation at frames 795–812. That crash is still being narrowed down and is not covered here.

Possible fixes

  1. Make lazy preparation the default for titles that register thousands of shaders at boot, or the default overall. #5872 added the opt-in, and #6743 extends it to pipeline ABI resolution.
  2. Keep eager preparation, but let Driver::Submit wait only for the preparations of the shaders its commands bind. The Goat Simulator 3 case from #5007 only needs those.
  3. Bound the wait, then let the queue worker prepare the rest on first use, with #4404's prioritization.

I can turn option 2 or 3 into a PR with this A/B if one of them is the preferred direction.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5885615168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6846). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-16T14:10:43Z. --- ### What happens On a cold shader cache, Ghost of Yōtei (PPSA26344) shows a black screen for 80–180 s before its first frame. With a warm cache, the first frame comes at about 40 s. While the screen is black, about 1.3 CPU cores are busy. Thread dumps at 45 s and 70 s (main 82ddae75b, cold) show: - the render thread and one job worker in `Driver::Submit` → `AwaitRegistrationPreparation`; - one registration prepare thread in the recompiler front end (`Structurizer::computeDominatorTree` / `tarjanVisit`); - the other 16 prepare threads idle. In the first 10 s the title registers about 1,600 shaders, and almost all of them are prepared within that window. A few giant registrations, about 21 MiB of SPIR-V each, stay in the pool for tens of seconds. Since #5007, `Driver::Submit` waits for every preparation queued before it, not only the ones its commands use. So the first submission waits for those giants. The debt entry "Registration preparation at submit" in `docs/dev/debt/libSceAgcDriver.md` already describes this case. ### Measured Windows 11 Pro 26200, RTX 4090, driver 617.42. `main` 82ddae75b plus #6227, which this title needs to start on current main, plus a local crash-report thread-dump hook. Each run has its own empty shader cache directory. | Run | `APS5_LAZY_SHADER_PREPARE` | First frame | Frame 619 (heavy load starts) | Frame 768 (spinner) | Recompiler cache misses by 360 s | |---|---|---|---|---|---| | run180 | unset | 181 s | 281 s | not reached by 360 s | 11,721 | | run182 | unset | 80 s | 201 s | 623 s | n/a | | run181 | 1 | 40 s | 100 s | not reached by 360 s | 219 | | run183 | 1 | 40 s | 100 s | 241 s | n/a | | run165 (warm cache, older tree) | unset | 40 s | 101 s | 241 s | 0 | - The eager boot varies from run to run. run182 came after run180 with NVIDIA's own driver cache warmer, so its 80 s is the better case. - With lazy preparation, the first frame and frame 619 match the warm run in both lazy runs. Past frame 619 the lazy runs differ: run183 matched the warm run to the spinner, while run181 was still at frame 692 at 360 s. Two runs per arm are not enough to say how much of the loading phase lazy preparation saves. Neither lazy run showed new errors, and both had the same 120 "could not be prepared at registration" lines as the eager runs. - Both arms later hit a separate NVIDIA driver crash during graphics pipeline creation at frames 795–812. That crash is still being narrowed down and is not covered here. ### Possible fixes 1. Make lazy preparation the default for titles that register thousands of shaders at boot, or the default overall. #5872 added the opt-in, and #6743 extends it to pipeline ABI resolution. 2. Keep eager preparation, but let `Driver::Submit` wait only for the preparations of the shaders its commands bind. The Goat Simulator 3 case from #5007 only needs those. 3. Bound the wait, then let the queue worker prepare the rest on first use, with #4404's prioritization. I can turn option 2 or 3 into a PR with this A/B if one of them is the preferred direction. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-16 14:15:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T14:15:46Z.


I would favor option 2 as the next investigation: it targets the measured wait on unrelated registrations while preserving the existing eager-preparation behavior by default. Before removing the submission-wide barrier, I would want a regression that queues a slow unrelated registration ahead of a submission, verifies the submission waits for the shaders its commands actually reference, and verifies unrelated preparations do not hold that submission back. The existing per-shader first-use wait and prioritization need to remain safe with the queue worker. Since you offered to implement option 2 or 3, please take that direction if it still fits your plan; I will avoid starting an overlapping change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217438816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6846#issuecomment-6217438816). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T14:15:46Z. --- I would favor option 2 as the next investigation: it targets the measured wait on unrelated registrations while preserving the existing eager-preparation behavior by default. Before removing the submission-wide barrier, I would want a regression that queues a slow unrelated registration ahead of a submission, verifies the submission waits for the shaders its commands actually reference, and verifies unrelated preparations do not hold that submission back. The existing per-shader first-use wait and prioritization need to remain safe with the queue worker. Since you offered to implement option 2 or 3, please take that direction if it still fits your plan; I will avoid starting an overlapping change.
Pipodi commented 2026-10-16 14:59:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T14:59:10Z.


Implemented option 2 in #6867, as you suggested. Driver::Submit now reads the program address registers its commands write (SET_SH_REG and indirect SH register lists) and waits only for those programs' pending preparations, moving them to the front of the queue. The global wait is gone. A program it can't see still waits in the queue worker at first use.

It includes the regression you asked for:

  • a slow unrelated preparation is queued ahead;
  • the wait returns once the bound program's preparation settles, before the unrelated one runs;
  • a submission with only unrelated work queued returns in under 1 s.

On a cold Yōtei boot (two runs), submission waits drop from 117 s to about 6 s, and frame 619 comes at 101 s instead of 181 s. That's the same as APS5_LAZY_SHADER_PREPARE=1, with preparation still eager.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218272432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6846#issuecomment-6218272432). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-16T14:59:10Z. --- Implemented option 2 in #6867, as you suggested. `Driver::Submit` now reads the program address registers its commands write (`SET_SH_REG` and indirect SH register lists) and waits only for those programs' pending preparations, moving them to the front of the queue. The global wait is gone. A program it can't see still waits in the queue worker at first use. It includes the regression you asked for: - a slow unrelated preparation is queued ahead; - the wait returns once the bound program's preparation settles, before the unrelated one runs; - a submission with only unrelated work queued returns in under 1 s. On a cold Yōtei boot (two runs), submission waits drop from 117 s to about 6 s, and frame 619 comes at 101 s instead of 181 s. That's the same as `APS5_LAZY_SHADER_PREPARE=1`, with preparation still eager. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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#6846
No description provided.