perf(agc): leave a lazily registered shader's resolved ABI to its first use #7644

Merged
EagleBearerYS merged 9 commits from upstream-pr/7644 into main 2026-10-23 14:14:39 +00:00
EagleBearerYS commented 2026-10-18 19:20:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T19:20:36Z.


What

Under APS5_LAZY_SHADER_PREPARE=1, registration prepares nothing. But ResolveShaderAbi still planned and prepared every compute or pixel stage whose ABI the title resolved. A title that resolves every shader's ABI therefore prepared them all at boot, whether they ever drew.

Resident Evil Village (PPSA01556) is such a title. Its prepared shaders take a large part of its private memory at the menu: this PR saves ~3 to 4.5 GB there (see Tested), more than the ~2–3 GB we had estimated from per-program holders of ~0.5 MiB across ~6,000 programs.

With lazy preparation, ResolveShaderAbi now:

  • plans the stage with the ABI's state: its register and entry-point checks, as lazy registration keeps them;
  • records the ABI key;
  • queues the ABI's context and primitive registers on the shader.

Then the shader's first draw or dispatch plans and prepares the queued ABIs with that state, before it looks for its artifact.

  • A shader that never draws or dispatches stays unprepared.
  • One that does gets the entries eager resolution would have made.
  • A stage whose plan fails is deferred, as before.
  • Without the switch, nothing changes. Graphics-stage ABIs are still prepared when they are resolved.

Concurrent first uses. The first use of a shader with deferred ABIs marks the shader while it prepares them, then publishes all their entries together under the shader's lock. A use from another queue that arrives meanwhile waits on the shader's existing condition until they're published, then matches the published entry, so each ABI is prepared once. If no entry matches (its preparation failed, or the use's state differs), each use prepares its own entry, as without deferral. After the first use, the lookup reads one more flag under the lock it already holds.

Which workloads it helps. The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with.

  • Resident Evil Village (PPSA01556) resolves every shader's ABI at boot: ~2.9 to 4.6 GB less private memory at the menu, over three pairs (Tested).
  • On Astro's Playroom (PPSA01325), fma-rc measured no saving (comment): 16,430 MiB with this PR and 16,111 MiB on main at 600 s.
  • Nothing changes without APS5_LAZY_SHADER_PREPARE=1.

Cost at first use. The preparation moves from resolution to a shader's first draw or dispatch, on the queue worker. The Village pairs below are at the static menu, so they can't show it. A Resident Evil Village pair across the transition from the menu into first gameplay, on a warm shader cache, with and without this PR (comment, and Tested): 24:11 from Yes to the first lit gameplay frame with it, against 24:00 without, and the worst frames within the same range (85.5 s against 133.0 s at the top). On that memory-bound machine, a first-use cost smaller than its paging stalls wouldn't show.

The commits:

  1. Driver::PreparedEntries counts a registered shader's prepared entries, for the test.

  2. The change.

  3. test(agc): the lazy resolved ABI test's eager reference runs without the switch.

  4. test(agc): a lazily resolved ABI's entries, libraries and cache files are compared with eager preparation's.

  5. test(agc): stale-state cases of a deferred ABI are compared with eager preparation.

  6. test(agc): a deferred compute ABI is checked under lazy preparation.

    Commits 3 to 6 came from an adversarial review. They're described under Tested.

  7. A counter for whether a deferred ABI's first use finds its artifact among the queued entries. It tells whether the queued preparation is the use's own work or extra, through Driver::DeferredAbiUses and a [shaders] deferred ABIs: ... line.

  8. fix(agc): a deferred ABI is prepared once when queues make its first use at once (above).

  9. fix(agc): the [shaders] deferred ABIs line prints only under APS5_PROFILE_DRAW, through the profile output the [rescache] lines use.

Where the end state can differ from eager preparation, with no wrong state:

  • if the device is gone by the first use, the queued ABI is skipped, and the draw prepares its own entry;
  • if a deferred ABI's preparation fails, it is logged, and each use, the waiting ones too, prepares its own entry.

Tested

  • agc_driver_lazy_resolved_abi runs one scenario with eager and with lazy preparation, and compares the lazy run's end state with the eager run's.

    • Five pixel shaders: four resolved with empty ABI registers and one with its draw's own registers. Three of them draw.
    • Each drawn shader's prepared entries (SPIR-V content hash and source key) equal eager preparation's. The shaders that never drew hold none, and nothing is prepared or prebuilt at resolution.
    • The pipeline libraries built, once the prebuild pool has drained, equal eager preparation's, and the lazy run writes no shader-cache file the eager run didn't.
    • Stale state: the ABI's register arrays overwritten before any draw; one shader resolved with two ABIs; a second header registered and drawn, then the first registered again and drawn.
    • Each check fails when its part of the first-use preparation is removed. For example, without the prebuild device the library counts differ.
    • The first-use counter, from the counts before and after the scenario's draws:
      • the two draws whose state differs from the resolved ABI count as own, with every queued entry unmatched;
      • the shader resolved with its draw's registers counts as found and matches one entry.
    • agc_driver_lazy_resolved_abi_switch_set runs it with APS5_LAZY_SHADER_PREPARE=1 exported.
  • agc_driver_prepared_shaders_abi_deferred_compute_lazy resolves a compute ABI under the switch. Neither resolution builds a front end, and the first dispatch links both callees and writes the expected value in every lane.

  • agc_driver_prepared_shaders_abi_deferred_concurrent_lazy (commit 8):

    • Setup: a compute shader registered under the switch with its ABI resolved, so the ABI is deferred. Four threads behind a barrier submit its first dispatch on queues 0x20 to 0x23 at once, each into its own output.
    • Every output must be right, with:
      • one first use, which found its artifact;
      • no own preparation;
      • every front-end build and entry from the deferred ABI;
      • all four dispatches on the same entry.
    • Red, with ShaderRegistry.hpp and ShaderRegistry.cpp as before commit 8, in 20 of 20 runs: "four queues making the first use of one deferred ABI at once did not prepare it once (2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used)". Green in 20 of 20.
  • The profile line (commit 9): without APS5_PROFILE_DRAW, no [shaders] deferred ABIs line. With it: [shaders] deferred ABIs: 1 prepared at first use, 1 found their artifact there, 0 prepared their own; 1 of the 2 entries prepared from them never matched a use.

  • Linux, CI's configuration (a cloud worker), at the head:

    • agc_driver_lazy_resolved_abi, agc_driver_lazy_resolved_abi_switch_set, agc_driver_prepared_shaders, agc_driver_prepared_shaders_abi_deferred_compute_lazy and agc_driver_prepared_shaders_abi_deferred_concurrent_lazy pass 20 runs in a row.
    • ^agc passes 795 of 797 (57 skipped). The two failures also fail on main: agc_driver_sgpr_pattern_fill_keys fails under the sweep's parallel load, and agc_driver_storage_read_during_idle_store fails in about 1% of runs on that machine (alone: 4 of 360 runs at the head, 3 of 360 at the base).
    • Each commit builds and passes its own tests.
  • Resident Evil Village (PPSA01556), Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU, one run each. Both runs use our test tree (main with #6366 and other open PRs of ours) plus #6178, with APS5_LAZY_SHADER_PREPARE=1, heap counters on (APS5_PROFILE_HEAP=1) and GPL on. Private memory at the menu:

    menu + 1 min menu + 10 min
    without this PR 25,932 MB 26,529 MB
    with it 21,443 MB 21,915 MB
    change −4,489 MB −4,614 MB
    • Commit free at menu + 1 rises from 1,519 to 5,550 MB.
    • This is a memory change, and the pair's menu frame times don't compare: the run without it started on a cold shader cache, the run with it on a warm one. So there are no summary lines here. The cache state isn't what moved memory: a cold-cache run with this change (and APS5_RELEASE_SPIRV=1) was at 21,485 MB at menu + 1.
  • Resident Evil Village (PPSA01556), a second pair with traces, on the same two trees: without the change (964a4ea473) and with it (174358bd0d). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), APS5_LAZY_SHADER_PREPARE=1, GPL on, no heap counters, a warm shader cache in both (an untraced boot filled it first), one run each, menu only. The GPU was at P0 for 100% of the samples in both runs (mean 1,293 and 1,294 MHz); clocks weren't locked.

    • Private memory at the menu: 25,629 / 26,236 MB without the change and 21,510 / 22,072 MB with it at + 1 / + 10 min, −4,119 / −4,164 MB. That's the same saving as the first pair.

    • Frame times at the static menu, minutes 5 to 15: 13 presents in 530 s without the change (0.0245 fps, median frame 38.9 s) and 12 in 531 s with it (0.0226 fps, 42.6 s). One frame either way at ~40 s a frame, so this pair can't resolve a frame-time difference; the change is to memory.

    • The summary line from the middle of each arm's menu window, without and then with the change:

      {"commit":"964a4ea47335","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":5769,"ms":38512.704},"interval_start_s":1958.049,"interval_end_s":1996.562,"presents":1,"frame_ms":{"p50":38512.704,"p90":38512.704,"p99":38512.704,"max":38512.704},"gpu_busy_ms_per_present":360.658,"worker_busy_pct":{"queue worker 0x0":99.955,"queue worker 0x38":0.013,"queue worker 0x28":99.489,"queue worker 0x20":98.163},"top_phases_ms_per_frame":{"Driver.Packet":114619.989,"Driver.Packet.memory_wait":75600.232,"Driver.Packet.draw":37624.408,"Driver.Draw":37621.748,"Driver.Draw.draw_and_resource_release":23173.020,"Graphics.Draw":22491.874,"Graphics.Draw.draw_and_resource_release":22366.853,"Resources.Complete":15706.836},"top_phases_calls_per_s":{"Driver.Packet":198.895,"Driver.Packet.memory_wait":2.571,"Driver.Packet.draw":21.707,"Driver.Draw":21.707,"Driver.Draw.draw_and_resource_release":21.655,"Graphics.Draw":24.408,"Graphics.Draw.draw_and_resource_release":24.408,"Resources.Complete":16.981},"trace_dropped":false,"trace":""}
      {"commit":"174358bd0df9","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":3728,"ms":49551.654},"interval_start_s":1962.416,"interval_end_s":2011.967,"presents":1,"frame_ms":{"p50":49551.654,"p90":49551.654,"p99":49551.654,"max":49551.654},"gpu_busy_ms_per_present":366.125,"worker_busy_pct":{"queue worker 0x0":99.981,"queue worker 0x38":0.023,"queue worker 0x28":99.621,"queue worker 0x20":98.978},"top_phases_ms_per_frame":{"Driver.Packet":147961.349,"Driver.Packet.memory_wait":98183.273,"Driver.Packet.draw":49127.480,"Driver.Draw":49124.666,"Driver.Draw.draw_and_resource_release":25133.673,"Graphics.Draw":23956.698,"Graphics.Draw.draw_and_resource_release":23835.429,"Shader.DrawStage":20213.190},"top_phases_calls_per_s":{"Driver.Packet":154.707,"Driver.Packet.memory_wait":1.998,"Driver.Packet.draw":16.871,"Driver.Draw":16.871,"Driver.Draw.draw_and_resource_release":16.831,"Graphics.Draw":18.970,"Graphics.Draw.draw_and_resource_release":18.970,"Shader.DrawStage":52.713},"trace_dropped":false,"trace":""}
      
    • tools/trace_digest.py on those two lines:

      2 intervals, 1958.0 to 2012.0 s, 2 presents
      NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 964a4ea47335
      commit, environment, GPU, driver or OS changed at interval 2

      # seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
      1 1958-1997 1 38512.7 38512.7 38512.7 38512.7 360.7 100 % Driver.Packet 114620.0
      2 1962-2012 1 49551.7 49551.7 49551.7 49551.7 366.1 100 % Driver.Packet 147961.3
      p99 ms  #@  0-49551.7
      gpu ms  @@  0-366.1
      
    • The two traces are on this fork release. Their 60 s windows (APS5_TRACE_SECONDS=900:60) fell in the intro, about 6 to 7 minutes before the main menu, since these trees take ~23 minutes to reach it.

  • Resident Evil Village (PPSA01556), a third pair on this head (1ba22061e3), menu only, one run each. Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held, and no GPU timing is claimed.

    • Both arms run main 1ff5c8ac5c with #8926's fix (63d5414338), which Resident Evil Village needs on that main to get through its intro. One has this PR on top, and one doesn't.
    • Settings, the same in both: APS5_LAZY_SHADER_PREPARE=1, GPL on, APS5_HOST_IMPORT_MIB=6400, a warm shader cache, no profiling, no input.
    • Private memory at the static menu, without and with this PR: 22,079 and 18,297 MB on arrival (−3,782), 22,715 and 18,976 MB at + 1 min (−3,739), 24,586 and 21,654 MB at + 5 min (−2,932). The lowest commit free was 2,625 MB without it and 6,241 MB with it.
    • Unlike the first two pairs, the gap narrowed over the window: private memory grew about 670 MB a minute with this PR against about 500 without it.
    • Neither run has a fault, FATAL or refusal line.
  • Resident Evil Village (PPSA01556), the menu → first gameplay transition on this head (1ba22061e3), one matched pair (comment, with the summary lines and digests). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held (P0 at 1,290 MHz in the slow intervals).

    • The trees are the third pair's: main 1ff5c8ac5c with #8926's fix (63d5414338), with and without this PR.
    • Settings, the same in both: APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1 (with GPL on, this PC doesn't load past the menu), APS5_HOST_IMPORT_MIB=6400 and APS5_TRACE_SUMMARY_EVERY=1. Warm shader cache, the same route and the same host-import mode.
    • Yes → first lit gameplay frame: 24:00 without, 24:11 with. Worst frames after Yes: 133.0 s without, 85.5 s with.
    • The shader disk cache served 18,902 entries without and 9,452 with, with no misses.
    • Both runs page hard, and the first minute of gameplay runs at 7.6 to 11.7 s a frame. So this pair shows no measurable difference, and a first-use cost smaller than the paging stalls wouldn't show.
    • Private memory at menu + 1 min is 415 MB higher with the change in this NO_GPL pair. The pair doesn't show whether the GPL-on saving above carries over.
  • A harness on a cloud worker (Linux, lavapipe):

    • memory after registration falls from 2,531 to 139 MiB;
    • registration time falls from 670 to 4 s.
  • The adversarial review (a cloud worker). Its question: can a deferred preparation run with different state from what eager resolution would have used? The answer is no.

    • The first use builds its state from inputs fixed at resolution: the snapshot's registered state and code, the ABI's registers (copied by value), and the device (held weakly).
    • It found no product bug. Its one should-fix, the eager reference inheriting an exported switch, has its fix in the merged commits (agc_driver_lazy_resolved_abi_switch_set).
  • GitHub's runners at 1ba22061e3 (run): the five tests above pass 5 runs in a row on Linux. On Windows they need Vulkan and skip. The libc and libkernel suites pass on both.

Checklist

  • Based on main f47c856634, rebased, and it merges cleanly with 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none (#6366 is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: lavapipe (Linux, a cloud worker); NVIDIA GeForce RTX 3070 Laptop GPU (Windows 11, Resident Evil Village)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4912075330 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-18T19:20:36Z. --- ### What Under `APS5_LAZY_SHADER_PREPARE=1`, registration prepares nothing. But `ResolveShaderAbi` still planned and prepared every compute or pixel stage whose ABI the title resolved. A title that resolves every shader's ABI therefore prepared them all at boot, whether they ever drew. **Resident Evil Village (PPSA01556)** is such a title. Its prepared shaders take a large part of its private memory at the menu: this PR saves ~3 to 4.5 GB there (see Tested), more than the ~2–3 GB we had estimated from per-program holders of ~0.5 MiB across ~6,000 programs. **With lazy preparation, `ResolveShaderAbi` now:** - plans the stage with the ABI's state: its register and entry-point checks, as lazy registration keeps them; - records the ABI key; - queues the ABI's context and primitive registers on the shader. **Then the shader's first draw or dispatch** plans and prepares the queued ABIs with that state, before it looks for its artifact. - A shader that never draws or dispatches stays unprepared. - One that does gets the entries eager resolution would have made. - A stage whose plan fails is deferred, as before. - Without the switch, nothing changes. Graphics-stage ABIs are still prepared when they are resolved. **Concurrent first uses.** The first use of a shader with deferred ABIs marks the shader while it prepares them, then publishes all their entries together under the shader's lock. A use from another queue that arrives meanwhile waits on the shader's existing condition until they're published, then matches the published entry, so each ABI is prepared once. If no entry matches (its preparation failed, or the use's state differs), each use prepares its own entry, as without deferral. After the first use, the lookup reads one more flag under the lock it already holds. **Which workloads it helps.** The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with. - Resident Evil Village (PPSA01556) resolves every shader's ABI at boot: ~2.9 to 4.6 GB less private memory at the menu, over three pairs (Tested). - On Astro's Playroom (PPSA01325), fma-rc measured no saving ([comment](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6270125623)): 16,430 MiB with this PR and 16,111 MiB on `main` at 600 s. - Nothing changes without `APS5_LAZY_SHADER_PREPARE=1`. **Cost at first use.** The preparation moves from resolution to a shader's first draw or dispatch, on the queue worker. The Village pairs below are at the static menu, so they can't show it. A Resident Evil Village pair across the transition from the menu into first gameplay, on a warm shader cache, with and without this PR ([comment](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6331064475), and Tested): 24:11 from Yes to the first lit gameplay frame with it, against 24:00 without, and the worst frames within the same range (85.5 s against 133.0 s at the top). On that memory-bound machine, a first-use cost smaller than its paging stalls wouldn't show. **The commits:** 1. `Driver::PreparedEntries` counts a registered shader's prepared entries, for the test. 2. The change. 3. `test(agc)`: the lazy resolved ABI test's eager reference runs without the switch. 4. `test(agc)`: a lazily resolved ABI's entries, libraries and cache files are compared with eager preparation's. 5. `test(agc)`: stale-state cases of a deferred ABI are compared with eager preparation. 6. `test(agc)`: a deferred compute ABI is checked under lazy preparation. Commits 3 to 6 came from an adversarial review. They're described under Tested. 7. A counter for whether a deferred ABI's first use finds its artifact among the queued entries. It tells whether the queued preparation is the use's own work or extra, through `Driver::DeferredAbiUses` and a `[shaders] deferred ABIs: ...` line. 8. `fix(agc)`: a deferred ABI is prepared once when queues make its first use at once (above). 9. `fix(agc)`: the `[shaders] deferred ABIs` line prints only under `APS5_PROFILE_DRAW`, through the profile output the `[rescache]` lines use. **Where the end state can differ from eager preparation,** with no wrong state: - if the device is gone by the first use, the queued ABI is skipped, and the draw prepares its own entry; - if a deferred ABI's preparation fails, it is logged, and each use, the waiting ones too, prepares its own entry. ### Tested - **`agc_driver_lazy_resolved_abi`** runs one scenario with eager and with lazy preparation, and compares the lazy run's end state with the eager run's. - Five pixel shaders: four resolved with empty ABI registers and one with its draw's own registers. Three of them draw. - Each drawn shader's prepared entries (SPIR-V content hash and source key) equal eager preparation's. The shaders that never drew hold none, and nothing is prepared or prebuilt at resolution. - The pipeline libraries built, once the prebuild pool has drained, equal eager preparation's, and the lazy run writes no shader-cache file the eager run didn't. - Stale state: the ABI's register arrays overwritten before any draw; one shader resolved with two ABIs; a second header registered and drawn, then the first registered again and drawn. - Each check fails when its part of the first-use preparation is removed. For example, without the prebuild device the library counts differ. - **The first-use counter,** from the counts before and after the scenario's draws: - the two draws whose state differs from the resolved ABI count as own, with every queued entry unmatched; - the shader resolved with its draw's registers counts as found and matches one entry. - `agc_driver_lazy_resolved_abi_switch_set` runs it with `APS5_LAZY_SHADER_PREPARE=1` exported. - **`agc_driver_prepared_shaders_abi_deferred_compute_lazy`** resolves a compute ABI under the switch. Neither resolution builds a front end, and the first dispatch links both callees and writes the expected value in every lane. - **`agc_driver_prepared_shaders_abi_deferred_concurrent_lazy`** (commit 8): - Setup: a compute shader registered under the switch with its ABI resolved, so the ABI is deferred. Four threads behind a barrier submit its first dispatch on queues 0x20 to 0x23 at once, each into its own output. - Every output must be right, with: - one first use, which found its artifact; - no own preparation; - every front-end build and entry from the deferred ABI; - all four dispatches on the same entry. - Red, with `ShaderRegistry.hpp` and `ShaderRegistry.cpp` as before commit 8, in 20 of 20 runs: "four queues making the first use of one deferred ABI at once did not prepare it once (2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used)". Green in 20 of 20. - **The profile line** (commit 9): without `APS5_PROFILE_DRAW`, no `[shaders] deferred ABIs` line. With it: `[shaders] deferred ABIs: 1 prepared at first use, 1 found their artifact there, 0 prepared their own; 1 of the 2 entries prepared from them never matched a use`. - **Linux, CI's configuration (a cloud worker), at the head:** - `agc_driver_lazy_resolved_abi`, `agc_driver_lazy_resolved_abi_switch_set`, `agc_driver_prepared_shaders`, `agc_driver_prepared_shaders_abi_deferred_compute_lazy` and `agc_driver_prepared_shaders_abi_deferred_concurrent_lazy` pass 20 runs in a row. - `^agc` passes 795 of 797 (57 skipped). The two failures also fail on `main`: `agc_driver_sgpr_pattern_fill_keys` fails under the sweep's parallel load, and `agc_driver_storage_read_during_idle_store` fails in about 1% of runs on that machine (alone: 4 of 360 runs at the head, 3 of 360 at the base). - Each commit builds and passes its own tests. - **Resident Evil Village (PPSA01556),** Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU, one run each. Both runs use our test tree (`main` with #6366 and other open PRs of ours) plus #6178, with `APS5_LAZY_SHADER_PREPARE=1`, heap counters on (`APS5_PROFILE_HEAP=1`) and GPL on. Private memory at the menu: | | menu + 1 min | menu + 10 min | |---|---|---| | without this PR | 25,932 MB | 26,529 MB | | with it | 21,443 MB | 21,915 MB | | change | −4,489 MB | −4,614 MB | - Commit free at menu + 1 rises from 1,519 to 5,550 MB. - This is a memory change, and the pair's menu frame times don't compare: the run without it started on a cold shader cache, the run with it on a warm one. So there are no summary lines here. The cache state isn't what moved memory: a cold-cache run with this change (and `APS5_RELEASE_SPIRV=1`) was at 21,485 MB at menu + 1. - **Resident Evil Village (PPSA01556), a second pair with traces,** on the same two trees: without the change (964a4ea473) and with it (174358bd0d). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), `APS5_LAZY_SHADER_PREPARE=1`, GPL on, no heap counters, a warm shader cache in both (an untraced boot filled it first), one run each, menu only. The GPU was at P0 for 100% of the samples in both runs (mean 1,293 and 1,294 MHz); clocks weren't locked. - Private memory at the menu: 25,629 / 26,236 MB without the change and 21,510 / 22,072 MB with it at + 1 / + 10 min, −4,119 / −4,164 MB. That's the same saving as the first pair. - Frame times at the static menu, minutes 5 to 15: 13 presents in 530 s without the change (0.0245 fps, median frame 38.9 s) and 12 in 531 s with it (0.0226 fps, 42.6 s). One frame either way at ~40 s a frame, so this pair can't resolve a frame-time difference; the change is to memory. - The summary line from the middle of each arm's menu window, without and then with the change: ```jsonl {"commit":"964a4ea47335","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":5769,"ms":38512.704},"interval_start_s":1958.049,"interval_end_s":1996.562,"presents":1,"frame_ms":{"p50":38512.704,"p90":38512.704,"p99":38512.704,"max":38512.704},"gpu_busy_ms_per_present":360.658,"worker_busy_pct":{"queue worker 0x0":99.955,"queue worker 0x38":0.013,"queue worker 0x28":99.489,"queue worker 0x20":98.163},"top_phases_ms_per_frame":{"Driver.Packet":114619.989,"Driver.Packet.memory_wait":75600.232,"Driver.Packet.draw":37624.408,"Driver.Draw":37621.748,"Driver.Draw.draw_and_resource_release":23173.020,"Graphics.Draw":22491.874,"Graphics.Draw.draw_and_resource_release":22366.853,"Resources.Complete":15706.836},"top_phases_calls_per_s":{"Driver.Packet":198.895,"Driver.Packet.memory_wait":2.571,"Driver.Packet.draw":21.707,"Driver.Draw":21.707,"Driver.Draw.draw_and_resource_release":21.655,"Graphics.Draw":24.408,"Graphics.Draw.draw_and_resource_release":24.408,"Resources.Complete":16.981},"trace_dropped":false,"trace":""} {"commit":"174358bd0df9","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":3728,"ms":49551.654},"interval_start_s":1962.416,"interval_end_s":2011.967,"presents":1,"frame_ms":{"p50":49551.654,"p90":49551.654,"p99":49551.654,"max":49551.654},"gpu_busy_ms_per_present":366.125,"worker_busy_pct":{"queue worker 0x0":99.981,"queue worker 0x38":0.023,"queue worker 0x28":99.621,"queue worker 0x20":98.978},"top_phases_ms_per_frame":{"Driver.Packet":147961.349,"Driver.Packet.memory_wait":98183.273,"Driver.Packet.draw":49127.480,"Driver.Draw":49124.666,"Driver.Draw.draw_and_resource_release":25133.673,"Graphics.Draw":23956.698,"Graphics.Draw.draw_and_resource_release":23835.429,"Shader.DrawStage":20213.190},"top_phases_calls_per_s":{"Driver.Packet":154.707,"Driver.Packet.memory_wait":1.998,"Driver.Packet.draw":16.871,"Driver.Draw":16.871,"Driver.Draw.draw_and_resource_release":16.831,"Graphics.Draw":18.970,"Graphics.Draw.draw_and_resource_release":18.970,"Shader.DrawStage":52.713},"trace_dropped":false,"trace":""} ``` - `tools/trace_digest.py` on those two lines: **2 intervals**, 1958.0 to 2012.0 s, 2 presents NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 964a4ea47335 commit, environment, GPU, driver or OS changed at interval 2 | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 1958-1997 | 1 | 38512.7 | 38512.7 | 38512.7 | 38512.7 | 360.7 | 100 % | Driver.Packet 114620.0 | | 2 | 1962-2012 | 1 | 49551.7 | 49551.7 | 49551.7 | 49551.7 | 366.1 | 100 % | Driver.Packet 147961.3 | ``` p99 ms #@ 0-49551.7 gpu ms @@ 0-366.1 ``` - The two traces are on [this fork release](https://github.com/EagleBearerYS/AnyPS5/releases/tag/perf-7644-village-traces). Their 60 s windows (`APS5_TRACE_SECONDS=900:60`) fell in the intro, about 6 to 7 minutes before the main menu, since these trees take ~23 minutes to reach it. - **Resident Evil Village (PPSA01556), a third pair on this head** (1ba22061e3), menu only, one run each. Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held, and no GPU timing is claimed. - Both arms run `main` 1ff5c8ac5c with #8926's fix (63d5414338), which Resident Evil Village needs on that `main` to get through its intro. One has this PR on top, and one doesn't. - Settings, the same in both: `APS5_LAZY_SHADER_PREPARE=1`, GPL on, `APS5_HOST_IMPORT_MIB=6400`, a warm shader cache, no profiling, no input. - Private memory at the static menu, without and with this PR: 22,079 and 18,297 MB on arrival (−3,782), 22,715 and 18,976 MB at + 1 min (−3,739), 24,586 and 21,654 MB at + 5 min (−2,932). The lowest commit free was 2,625 MB without it and 6,241 MB with it. - Unlike the first two pairs, the gap narrowed over the window: private memory grew about 670 MB a minute with this PR against about 500 without it. - Neither run has a fault, FATAL or refusal line. - **Resident Evil Village (PPSA01556), the menu → first gameplay transition** on this head (1ba22061e3), one matched pair ([comment](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6331064475), with the summary lines and digests). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held (P0 at 1,290 MHz in the slow intervals). - The trees are the third pair's: `main` 1ff5c8ac5c with #8926's fix (63d5414338), with and without this PR. - Settings, the same in both: `APS5_LAZY_SHADER_PREPARE=1`, `APS5_NO_GPL=1` (with GPL on, this PC doesn't load past the menu), `APS5_HOST_IMPORT_MIB=6400` and `APS5_TRACE_SUMMARY_EVERY=1`. Warm shader cache, the same route and the same host-import mode. - Yes → first lit gameplay frame: 24:00 without, 24:11 with. Worst frames after Yes: 133.0 s without, 85.5 s with. - The shader disk cache served 18,902 entries without and 9,452 with, with no misses. - Both runs page hard, and the first minute of gameplay runs at 7.6 to 11.7 s a frame. So this pair shows no measurable difference, and a first-use cost smaller than the paging stalls wouldn't show. - Private memory at menu + 1 min is 415 MB higher with the change in this NO_GPL pair. The pair doesn't show whether the GPL-on saving above carries over. - **A harness on a cloud worker** (Linux, lavapipe): - memory after registration falls from 2,531 to 139 MiB; - registration time falls from 670 to 4 s. - **The adversarial review (a cloud worker).** Its question: can a deferred preparation run with different state from what eager resolution would have used? The answer is no. - The first use builds its state from inputs fixed at resolution: the snapshot's registered state and code, the ABI's registers (copied by value), and the device (held weakly). - It found no product bug. Its one should-fix, the eager reference inheriting an exported switch, has its fix in the merged commits (`agc_driver_lazy_resolved_abi_switch_set`). - **GitHub's runners** at 1ba22061e3 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39549307807)): the five tests above pass 5 runs in a row on Linux. On Windows they need Vulkan and skip. The libc and libkernel suites pass on both. ### Checklist - [x] Based on `main` f47c856634, rebased, and it merges cleanly with 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#6366 is merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: lavapipe (Linux, a cloud worker); NVIDIA GeForce RTX 3070 Laptop GPU (Windows 11, Resident Evil Village) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 19:20:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T19:20:52Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254084526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6254084526). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T19:20:52Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
fma-rc commented 2026-10-19 14:51:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-19T14:51:24Z.


@EagleBearerYS here's Astro's Playroom (PPSA01325) with APS5_LAZY_SHADER_PREPARE=1 on this head (40e0d968c3) and on the main commit it merges (324e0e48e0). Linux, RTX 5080, one run each, 600 s with Cross pressed every 4 s. Private memory is Private_Clean + Private_Dirty from smaps_rollup:

MiB 30 s 60 s 600 s
this PR 13188 15009 16430
main 13500 16063 16111

Playroom shows no saving here. I don't have Resident Evil Village, so this doesn't test the ~4.5 GB in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6270125623 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6270125623). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-19T14:51:24Z. --- @EagleBearerYS here's Astro's Playroom (PPSA01325) with `APS5_LAZY_SHADER_PREPARE=1` on this head (40e0d968c3) and on the `main` commit it merges (324e0e48e0). Linux, RTX 5080, one run each, 600 s with Cross pressed every 4 s. Private memory is `Private_Clean + Private_Dirty` from `smaps_rollup`: | MiB | 30 s | 60 s | 600 s | |---|---|---|---| | this PR | 13188 | 15009 | 16430 | | `main` | 13500 | 16063 | 16111 | Playroom shows no saving here. I don't have Resident Evil Village, so this doesn't test the ~4.5 GB in the description.
CnRJay commented 2026-10-19 17:51:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-19T17:51:02Z.

Review: COMMENTED


The memory result is clear and repeats (menu private memory down 4,489 and 4,119 MB across two pairs, 21.4-21.9 GB against 25.6-26.5 GB), the cold-cache control shows it isn't the shader cache, and the test compares the lazy end state with eager preparation entry by entry.

What the PR does not show is the price. The preparation does not go away; it moves from boot to a shader's first draw or dispatch, on the queue worker.

  • Both Village pairs are at the static menu, at about 40 s per frame (one present in 530 s per arm). The description says they can't resolve a frame-time difference, and that is true, but it also means nothing here measures the case this change affects: the frames in which many shaders are drawn for the first time (entering the first area). Please capture the transition from menu into gameplay, warm shader cache, with and without the change, and post the worst frame times and the time to the first stable gameplay frame. If entering an area now hitches by the preparation of hundreds of ABIs, the memory is paid for with stutter.
  • "Two threads making the first use at once may each prepare an entry." That's two compiles of the same ABI on the hot path. Use a once-per-ABI flag so the second thread waits for the first, and say what the test shows about it.
  • The [shaders] deferred ABIs counter is diagnostics that prints to stderr every minute for everyone. Put it behind a profile switch, or keep it out of the PR.
  • It carries #6366's three commits first. Rebase once that merges so only this PR's commits show, as the title says.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5575522271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#pullrequestreview-5575522271). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-19T17:51:02Z. **Review:** COMMENTED --- The memory result is clear and repeats (menu private memory down 4,489 and 4,119 MB across two pairs, 21.4-21.9 GB against 25.6-26.5 GB), the cold-cache control shows it isn't the shader cache, and the test compares the lazy end state with eager preparation entry by entry. What the PR does not show is the price. The preparation does not go away; it moves from boot to a shader's first draw or dispatch, on the queue worker. - Both Village pairs are at the static menu, at about 40 s per frame (one present in 530 s per arm). The description says they can't resolve a frame-time difference, and that is true, but it also means nothing here measures the case this change affects: the frames in which many shaders are drawn for the first time (entering the first area). Please capture the transition from menu into gameplay, warm shader cache, with and without the change, and post the worst frame times and the time to the first stable gameplay frame. If entering an area now hitches by the preparation of hundreds of ABIs, the memory is paid for with stutter. - "Two threads making the first use at once may each prepare an entry." That's two compiles of the same ABI on the hot path. Use a once-per-ABI flag so the second thread waits for the first, and say what the test shows about it. - The `[shaders] deferred ABIs` counter is diagnostics that prints to stderr every minute for everyone. Put it behind a profile switch, or keep it out of the PR. - It carries #6366's three commits first. Rebase once that merges so only this PR's commits show, as the title says.
adriadam10 commented 2026-10-20 11:46:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T11:46:49Z.

Review: CHANGES_REQUESTED


Thanks, the lazy-vs-eager end-state test is a good check. Before this can merge:

  • Conflicts with main, and the history. #6366 is merged, so please rebase onto main so only this PR's commits remain (no merge commits, per CONTRIBUTING).
  • The cost isn't measured. The memory saving is clear on Resident Evil Village, but the preparation moves to a shader's first draw/dispatch on the queue worker. Both pairs are at the static menu (~40 s per frame), so nothing covers the frames where many shaders are drawn for the first time. Please capture the menu → first gameplay transition on a warm shader cache with and without the change, and post the worst frame times and the time to the first stable gameplay frame (same ask as @CnRJay's review).
  • Duplicate preparation on the hot path. "Two threads making the first use at once may each prepare an entry" means two compiles of the same ABI. Make the first use once-per-ABI (the second thread waits) and add a test that exercises it.
  • Counter output. The [shaders] deferred ABIs: ... line goes to stderr every minute for every user (ShaderRegistry.cpp, the new fprintf(stderr, ...)). Put it behind a profile switch or drop it from this PR.
  • Evidence beyond one title. @fma-rc's Astro's Playroom run shows no saving with this head (16.4 GB vs 16.1 GB at 600 s). Please state which workloads this helps, so the switch's benefit isn't read as general.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5584549045 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#pullrequestreview-5584549045). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T11:46:49Z. **Review:** CHANGES_REQUESTED --- Thanks, the lazy-vs-eager end-state test is a good check. Before this can merge: - **Conflicts with `main`, and the history.** #6366 is merged, so please rebase onto `main` so only this PR's commits remain (no merge commits, per CONTRIBUTING). - **The cost isn't measured.** The memory saving is clear on Resident Evil Village, but the preparation moves to a shader's first draw/dispatch on the queue worker. Both pairs are at the static menu (~40 s per frame), so nothing covers the frames where many shaders are drawn for the first time. Please capture the menu → first gameplay transition on a warm shader cache with and without the change, and post the worst frame times and the time to the first stable gameplay frame (same ask as @CnRJay's review). - **Duplicate preparation on the hot path.** "Two threads making the first use at once may each prepare an entry" means two compiles of the same ABI. Make the first use once-per-ABI (the second thread waits) and add a test that exercises it. - **Counter output.** The `[shaders] deferred ABIs: ...` line goes to stderr every minute for every user (`ShaderRegistry.cpp`, the new `fprintf(stderr, ...)`). Put it behind a profile switch or drop it from this PR. - **Evidence beyond one title.** @fma-rc's Astro's Playroom run shows no saving with this head (16.4 GB vs 16.1 GB at 600 s). Please state which workloads this helps, so the switch's benefit isn't read as general.
EagleBearerYS commented 2026-10-21 05:58:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T05:58:15Z.


@adriadam10 @CnRJay, thanks for the reviews. 1ba22061e3 is a rebase onto main with two new fixes. Point by point:

History. The branch is rebased onto main f47c856634, and it merges cleanly with current main.

  • It holds this PR's seven commits and the two new ones, with no merge commits and none of #6366's (merged).
  • The four review test commits come right after the change, as they were written. The first-use counter comes after them, with the resolution the old merge made: at that commit the tree equals the old head merged with main.

Once per ABI (4eeeeb6438).

  • The first use marks the shader while it prepares its deferred ABIs, and publishes their entries together. A use from another queue waits on the shader's existing condition and takes the published entry.
  • If no entry matches, each use prepares its own, so a failed preparation leaves no one waiting.
  • After the first use, the lookup reads one more flag under the lock it already holds.
  • The new agc_driver_prepared_shaders_abi_deferred_concurrent_lazy submits the first dispatch of one deferred ABI from four queues at once, and requires one preparation that all four use. It failed in 20 of 20 runs before the fix ("2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used"), and passes in 20 of 20 with it. On GitHub's runners (run) it and the four other lazy and prepared-shader tests pass 5 runs in a row on Linux; on Windows they need Vulkan and skip.

The counter line (1ba22061e3) prints only under APS5_PROFILE_DRAW, through the profile output the [rescache] lines use. The counters still count, for the tests.

Which workloads. The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with. Resident Evil Village (PPSA01556) resolves every shader's ABI at boot, and saves ~4.1 to 4.6 GB at the menu. @fma-rc's Astro's Playroom (PPSA01325) run shows no saving. Without APS5_LAZY_SHADER_PREPARE=1 nothing changes. The description now says this.

The cost at first use. A Resident Evil Village pair across the transition from the menu into first gameplay is queued, on a warm shader cache, with and without this head, both under APS5_LAZY_SHADER_PREPARE=1. It will give the worst frame times, the time from starting the game at the menu to the first stable gameplay frame, both summary lines and the digest. I'll post it when it's in.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309189032 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6309189032). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T05:58:15Z. --- @adriadam10 @CnRJay, thanks for the reviews. 1ba22061e3 is a rebase onto `main` with two new fixes. Point by point: **History.** The branch is rebased onto `main` f47c856634, and it merges cleanly with current `main`. - It holds this PR's seven commits and the two new ones, with no merge commits and none of #6366's (merged). - The four review test commits come right after the change, as they were written. The first-use counter comes after them, with the resolution the old merge made: at that commit the tree equals the old head merged with `main`. **Once per ABI** (4eeeeb6438). - The first use marks the shader while it prepares its deferred ABIs, and publishes their entries together. A use from another queue waits on the shader's existing condition and takes the published entry. - If no entry matches, each use prepares its own, so a failed preparation leaves no one waiting. - After the first use, the lookup reads one more flag under the lock it already holds. - The new `agc_driver_prepared_shaders_abi_deferred_concurrent_lazy` submits the first dispatch of one deferred ABI from four queues at once, and requires one preparation that all four use. It failed in 20 of 20 runs before the fix ("2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used"), and passes in 20 of 20 with it. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39549307807)) it and the four other lazy and prepared-shader tests pass 5 runs in a row on Linux; on Windows they need Vulkan and skip. **The counter line** (1ba22061e3) prints only under `APS5_PROFILE_DRAW`, through the profile output the `[rescache]` lines use. The counters still count, for the tests. **Which workloads.** The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with. Resident Evil Village (PPSA01556) resolves every shader's ABI at boot, and saves ~4.1 to 4.6 GB at the menu. @fma-rc's Astro's Playroom (PPSA01325) run shows no saving. Without `APS5_LAZY_SHADER_PREPARE=1` nothing changes. The description now says this. **The cost at first use.** A Resident Evil Village pair across the transition from the menu into first gameplay is queued, on a warm shader cache, with and without this head, both under `APS5_LAZY_SHADER_PREPARE=1`. It will give the worst frame times, the time from starting the game at the menu to the first stable gameplay frame, both summary lines and the digest. I'll post it when it's in.
EagleBearerYS commented 2026-10-22 02:15:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T02:15:49Z.


@adriadam10 @CnRJay, here's the Resident Evil Village (PPSA01556) transition pair from the menu into first gameplay, as promised: one matched pair, without and with this PR.

Setup

  • Trees: main 1ff5c8ac5c with #8926 (63d5414338), and the same with this PR's head 1ba22061e3 (074e31acbe).
  • Both arms: APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1, APS5_HOST_IMPORT_MIB=6400, and APS5_TRACE_SUMMARY_EVERY=1 (summary lines only, no trace window).
  • Warm shader cache: no new cache key, and no disk-cache misses in either run.
  • The same route: about a minute at the menu, Continue, Yes, then about 3 minutes at control.
  • Both runs used the same low host-import mode (26,107 imports, 13,696 MiB without; 26,337, 14,233 MiB with).
  • RTX 3070 Laptop GPU, Ryzen 9 5900HS, 16 GB of RAM, Windows. GPU clocks weren't held; nvidia-smi showed P0 at 1,290 MHz in the slow intervals.
  • The earlier memory pairs in the description were with GPL on. With GPL on, this PC can't load past the menu, so this pair is with APS5_NO_GPL=1, and its memory compares only within the pair. In this pair, private memory at the menu is 415 MB higher with the change; it doesn't show whether the description's GPL-on saving carries over to APS5_NO_GPL=1.

Results

without with this PR
Yes → first lit gameplay frame 24:00 24:11
Five worst frames after Yes 133.0, 25.5, 23.3, 22.9, 22.0 s 85.5, 27.9, 24.9, 19.0, 18.6 s
First ~60 s of gameplay 6 frames, 7.6-9.5 s, plus one of 22.9 s 5 frames, 10.5-11.7 s
Frames over 2 s: count, mean 244, 7.3 s 274, 6.5 s
Shader disk-cache hits (misses) 18,902 (0) 9,452 (0)
Private memory at menu + 1 min 19,170 MB 19,585 MB

Per frame over the frames above 2 s, counted where a phase is among the frame's eight largest:

phase without with
Driver.Packet.memory_wait 11.5 s 10.1 s
Driver.Packet.dispatch 2.59 s 2.52 s
Resources.Complete 2.62 s 2.86 s
Graphics.Draw.draw_and_resource_release 1.75 s 1.74 s
Shader.DrawStage 0.56 s 0.12 s
Shader.ResolveGraphicsStagesAbi 0.07 s 0.05 s

"First lit gameplay frame" is the end of the opening scene's fade-in. Gameplay then runs at about 0.1 fps on this machine, so there's no stable frame rate to time.

Reading: there's no measurable difference in the time into gameplay or in the worst frames. With the change, the shader disk cache was asked for half as many entries, which fits the entries it leaves unprepared. But both runs are memory-bound: page-ins run at about 5,000 to 45,000 a second, and Driver.Packet.memory_wait is the largest phase of the slow frames. So a first-use cost smaller than the paging stalls wouldn't show here. The first minute of gameplay is slower with the change (10.5-11.7 s against 7.6-9.5 s per frame), while the run without it has a 22.9 s frame with 8.7 s in Shader.DrawStage and 8.6 s in Driver.Draw.shader_compile_and_link. One pair on this machine can't separate those from paging. I can run a second pair if you'd like one.

An earlier warm-up run with the change used the other host-import mode, which turns up on any tree, so it isn't compared here.

The first gameplay summary line of each run, and the digest of the first minute

Without (trace_digest.py):

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 2081-2089 1 7753.1 7753.1 7753.1 7753.1 227.7 100 % Driver.Packet 21628.0
2 2089-2098 1 9475.8 9475.8 9475.8 9475.8 225.5 100 % Driver.Packet 26341.5
3 2098-2107 1 8839.8 8839.8 8839.8 8839.8 226.2 100 % Driver.Packet 24897.7
4 2107-2115 1 7559.7 7559.7 7559.7 7559.7 225.6 100 % Driver.Packet 21034.4
5 2115-2123 1 7868.9 7868.9 7868.9 7868.9 452.8 100 % Driver.Packet 21841.3
6 2123-2145 1 22854.9 22854.9 22854.9 22854.9 0.0 100 % Driver.Packet 66970.4

With this PR:

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 2078-2090 1 11413.6 11413.6 11413.6 11413.6 449.7 100 % Driver.Packet 30869.4
2 2090-2101 1 11653.2 11653.2 11653.2 11653.2 224.5 100 % Driver.Packet 31631.9
3 2101-2112 1 10450.8 10450.8 10450.8 10450.8 227.4 100 % Driver.Packet 28852.0
4 2112-2123 1 10750.1 10750.1 10750.1 10750.1 225.9 100 % Driver.Packet 28348.4
5 2123-2134 1 11612.9 11612.9 11612.9 11612.9 0.0 100 % Driver.Packet 32336.9
{"commit": "63d541433884", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 3492, "ms": 7753.104}, "interval_start_s": 2081.053, "interval_end_s": 2088.806, "presents": 1, "frame_ms": {"p50": 7753.104, "p90": 7753.104, "p99": 7753.104, "max": 7753.104}, "gpu_busy_ms_per_present": 227.673, "worker_busy_pct": {"queue worker 0x0": 99.82, "queue worker 0x38": 0.279, "queue worker 0x28": 99.29, "queue worker 0x20": 79.593}, "top_phases_ms_per_frame": {"Driver.Packet": 21628.011, "Driver.Packet.memory_wait": 11854.178, "Driver.Packet.dispatch": 4528.933, "Driver.Dispatch": 4505.071, "Resources.Complete": 4217.389, "Driver.Packet.draw": 3613.669, "Driver.Draw": 3611.741, "Graphics.Draw": 3085.413}, "trace_dropped": false, "trace": ""}
{"commit": "074e31acbeb2", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 4767, "ms": 11413.624}, "interval_start_s": 2078.238, "interval_end_s": 2089.651, "presents": 1, "frame_ms": {"p50": 11413.624, "p90": 11413.624, "p99": 11413.624, "max": 11413.624}, "gpu_busy_ms_per_present": 449.682, "worker_busy_pct": {"queue worker 0x0": 99.83, "queue worker 0x38": 0.256, "queue worker 0x20": 76.712, "queue worker 0x28": 93.779}, "top_phases_ms_per_frame": {"Driver.Packet": 30869.398, "Driver.Packet.memory_wait": 17299.51, "Resources.Complete": 6567.612, "Driver.Packet.draw": 6277.76, "Driver.Draw": 6274.592, "Graphics.Draw": 5530.823, "Graphics.Draw.draw_and_resource_release": 5488.717, "Driver.Packet.dispatch": 5138.133}, "trace_dropped": false, "trace": ""}
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331064475 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6331064475). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T02:15:49Z. --- @adriadam10 @CnRJay, here's the Resident Evil Village (PPSA01556) transition pair from the menu into first gameplay, as promised: one matched pair, without and with this PR. **Setup** - Trees: `main` 1ff5c8ac5c with #8926 (63d5414338), and the same with this PR's head 1ba22061e3 (074e31acbe). - Both arms: `APS5_LAZY_SHADER_PREPARE=1`, `APS5_NO_GPL=1`, `APS5_HOST_IMPORT_MIB=6400`, and `APS5_TRACE_SUMMARY_EVERY=1` (summary lines only, no trace window). - Warm shader cache: no new cache key, and no disk-cache misses in either run. - The same route: about a minute at the menu, Continue, Yes, then about 3 minutes at control. - Both runs used the same low host-import mode (26,107 imports, 13,696 MiB without; 26,337, 14,233 MiB with). - RTX 3070 Laptop GPU, Ryzen 9 5900HS, 16 GB of RAM, Windows. GPU clocks weren't held; `nvidia-smi` showed P0 at 1,290 MHz in the slow intervals. - The earlier memory pairs in the description were with GPL on. With GPL on, this PC can't load past the menu, so this pair is with `APS5_NO_GPL=1`, and its memory compares only within the pair. In this pair, private memory at the menu is 415 MB higher with the change; it doesn't show whether the description's GPL-on saving carries over to `APS5_NO_GPL=1`. **Results** | | without | with this PR | |---|---|---| | Yes → first lit gameplay frame | 24:00 | 24:11 | | Five worst frames after Yes | 133.0, 25.5, 23.3, 22.9, 22.0 s | 85.5, 27.9, 24.9, 19.0, 18.6 s | | First ~60 s of gameplay | 6 frames, 7.6-9.5 s, plus one of 22.9 s | 5 frames, 10.5-11.7 s | | Frames over 2 s: count, mean | 244, 7.3 s | 274, 6.5 s | | Shader disk-cache hits (misses) | 18,902 (0) | 9,452 (0) | | Private memory at menu + 1 min | 19,170 MB | 19,585 MB | Per frame over the frames above 2 s, counted where a phase is among the frame's eight largest: | phase | without | with | |---|---|---| | `Driver.Packet.memory_wait` | 11.5 s | 10.1 s | | `Driver.Packet.dispatch` | 2.59 s | 2.52 s | | `Resources.Complete` | 2.62 s | 2.86 s | | `Graphics.Draw.draw_and_resource_release` | 1.75 s | 1.74 s | | `Shader.DrawStage` | 0.56 s | 0.12 s | | `Shader.ResolveGraphicsStagesAbi` | 0.07 s | 0.05 s | "First lit gameplay frame" is the end of the opening scene's fade-in. Gameplay then runs at about 0.1 fps on this machine, so there's no stable frame rate to time. **Reading:** there's no measurable difference in the time into gameplay or in the worst frames. With the change, the shader disk cache was asked for half as many entries, which fits the entries it leaves unprepared. But both runs are memory-bound: page-ins run at about 5,000 to 45,000 a second, and `Driver.Packet.memory_wait` is the largest phase of the slow frames. So a first-use cost smaller than the paging stalls wouldn't show here. The first minute of gameplay is slower with the change (10.5-11.7 s against 7.6-9.5 s per frame), while the run without it has a 22.9 s frame with 8.7 s in `Shader.DrawStage` and 8.6 s in `Driver.Draw.shader_compile_and_link`. One pair on this machine can't separate those from paging. I can run a second pair if you'd like one. An earlier warm-up run with the change used the other host-import mode, which turns up on any tree, so it isn't compared here. <details><summary>The first gameplay summary line of each run, and the digest of the first minute</summary> Without (`trace_digest.py`): | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 2081-2089 | 1 | 7753.1 | 7753.1 | 7753.1 | 7753.1 | 227.7 | 100 % | Driver.Packet 21628.0 | | 2 | 2089-2098 | 1 | 9475.8 | 9475.8 | 9475.8 | 9475.8 | 225.5 | 100 % | Driver.Packet 26341.5 | | 3 | 2098-2107 | 1 | 8839.8 | 8839.8 | 8839.8 | 8839.8 | 226.2 | 100 % | Driver.Packet 24897.7 | | 4 | 2107-2115 | 1 | 7559.7 | 7559.7 | 7559.7 | 7559.7 | 225.6 | 100 % | Driver.Packet 21034.4 | | 5 | 2115-2123 | 1 | 7868.9 | 7868.9 | 7868.9 | 7868.9 | 452.8 | 100 % | Driver.Packet 21841.3 | | 6 | 2123-2145 | 1 | 22854.9 | 22854.9 | 22854.9 | 22854.9 | 0.0 | 100 % | Driver.Packet 66970.4 | With this PR: | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 2078-2090 | 1 | 11413.6 | 11413.6 | 11413.6 | 11413.6 | 449.7 | 100 % | Driver.Packet 30869.4 | | 2 | 2090-2101 | 1 | 11653.2 | 11653.2 | 11653.2 | 11653.2 | 224.5 | 100 % | Driver.Packet 31631.9 | | 3 | 2101-2112 | 1 | 10450.8 | 10450.8 | 10450.8 | 10450.8 | 227.4 | 100 % | Driver.Packet 28852.0 | | 4 | 2112-2123 | 1 | 10750.1 | 10750.1 | 10750.1 | 10750.1 | 225.9 | 100 % | Driver.Packet 28348.4 | | 5 | 2123-2134 | 1 | 11612.9 | 11612.9 | 11612.9 | 11612.9 | 0.0 | 100 % | Driver.Packet 32336.9 | ```json {"commit": "63d541433884", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 3492, "ms": 7753.104}, "interval_start_s": 2081.053, "interval_end_s": 2088.806, "presents": 1, "frame_ms": {"p50": 7753.104, "p90": 7753.104, "p99": 7753.104, "max": 7753.104}, "gpu_busy_ms_per_present": 227.673, "worker_busy_pct": {"queue worker 0x0": 99.82, "queue worker 0x38": 0.279, "queue worker 0x28": 99.29, "queue worker 0x20": 79.593}, "top_phases_ms_per_frame": {"Driver.Packet": 21628.011, "Driver.Packet.memory_wait": 11854.178, "Driver.Packet.dispatch": 4528.933, "Driver.Dispatch": 4505.071, "Resources.Complete": 4217.389, "Driver.Packet.draw": 3613.669, "Driver.Draw": 3611.741, "Graphics.Draw": 3085.413}, "trace_dropped": false, "trace": ""} {"commit": "074e31acbeb2", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 4767, "ms": 11413.624}, "interval_start_s": 2078.238, "interval_end_s": 2089.651, "presents": 1, "frame_ms": {"p50": 11413.624, "p90": 11413.624, "p99": 11413.624, "max": 11413.624}, "gpu_busy_ms_per_present": 449.682, "worker_busy_pct": {"queue worker 0x0": 99.83, "queue worker 0x38": 0.256, "queue worker 0x20": 76.712, "queue worker 0x28": 93.779}, "top_phases_ms_per_frame": {"Driver.Packet": 30869.398, "Driver.Packet.memory_wait": 17299.51, "Resources.Complete": 6567.612, "Driver.Packet.draw": 6277.76, "Driver.Draw": 6274.592, "Graphics.Draw": 5530.823, "Graphics.Draw.draw_and_resource_release": 5488.717, "Driver.Packet.dispatch": 5138.133}, "trace_dropped": false, "trace": ""} ``` </details>
MarcZX10 commented 2026-10-22 05:07:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T05:07:41Z.


Overlap note from PR #9626: I added a process-private-memory admission check to the non-lazy registration path, so it touches the RegisterShader branch changed here. To avoid conflicting sequencing, I marked #9626 as depending on #7644 and will adapt the guard after this PR’s disposition. If you prefer a different order or think these changes should be integrated together, please let me know. I have not changed your branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333212902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6333212902). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T05:07:41Z. --- Overlap note from PR #9626: I added a process-private-memory admission check to the non-lazy registration path, so it touches the RegisterShader branch changed here. To avoid conflicting sequencing, I marked #9626 as depending on #7644 and will adapt the guard after this PR’s disposition. If you prefer a different order or think these changes should be integrated together, please let me know. I have not changed your branch.
MarcZX10 commented 2026-10-22 05:11:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T05:11:30Z.


Update on my earlier overlap note: I moved the memory admission check into PlanRegistered, outside the RegisterShader hunk changed here. The current overlap check no longer reports a direct conflict with #7644, so #9626 no longer depends on it. Please disregard the previous sequencing note; I have not changed your branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333262149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7644#issuecomment-6333262149). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T05:11:30Z. --- Update on my earlier overlap note: I moved the memory admission check into `PlanRegistered`, outside the `RegisterShader` hunk changed here. The current overlap check no longer reports a direct conflict with #7644, so #9626 no longer depends on it. Please disregard the previous sequencing note; I have not changed your branch.
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!7644
No description provided.