perf(agc): prebuild registration shader libraries only when APS5_LIBRARY_PREBUILD=1 #23812

Merged
chitters2004 merged 1 commit from upstream-pr/23812 into main 2026-11-20 05:01:57 +00:00
chitters2004 commented 2026-11-19 17:47:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by chitters2004 on 2026-11-19T17:47:46Z.


What

Graphics pipeline library prebuild becomes opt-in. It runs only with APS5_LIBRARY_PREBUILD=1. APS5_NO_LIBRARY_PREBUILD is no longer read; the docs/dev/ENVIRONMENT.md row for the new switch says so.

Why: at shader registration the prebuild compiles every part a registered shader could need, before any draw asks for it. On GTA V that's about 12 times what the game reaches by the time it's standing in the world. It costs about 10 minutes of worker-thread CPU per cold-cache boot, and loading isn't faster with it; the quiet boots below load sooner without it. On a warm cache it does nothing useful either. With it off, draws build only the parts they use.

Tested

GTA V in-game, build against build:

  • on: main 6db6a3e927;
  • off: the same plus this change.

Both builds have #14561 merged for the measurement only, since GTA aborts without it. Both use their defaults, with no profile switch and only APS5_TRACE_SECONDS=140:30 set (stood_still plus about 20 s).

The shader cache was emptied before every boot. Setup:

  • RTX 3080 on PCIe Gen4 x16, NVIDIA 621.24;
  • Ryzen 7 5800X, Windows 11, 3840x2160;
  • content PPSA04263 01.011.001, the city save outside Franklin's house;
  • Defender on.

One untimed warm-up boot ran per build, then the order on, off, off, on. A boot that wasn't quiet ran once more. The second on boot was still not quiet on its rerun (another process on the machine), so it's left out. That leaves one on boot and two off:

on off (2 boots)
first frame 2.7 s 2.6, 2.5 s
story load 53.1 s 49.1, 48.6 s
standing in the world 118.8 s 110.8, 113.4 s
30 s window p50 / p99 frame 134.1 / 207 ms 141.1 / 516, 138.6 / 322 ms
window Driver.Draw.shader_compile_and_link per frame 49.8 ms 52.0, 52.1 ms
Vulkan.GraphicsPipelinePrebuild, summed per boot 625 s 0, 0
Vulkan.GraphicsPipelineLibrary, summed per boot 665 s 46, 43 s

Reading the table:

  • Load: the off boots reached the world 5-8 s sooner. An earlier pair on our development branch (draw pipeline on, prebuild with a stage gate, same machine and scene) went the same way:

    • on: story load 53.6 s, standing 119.9 s;
    • off: 48.1 s and 113.4 s.

    Across both sets, every quiet off boot beat every quiet on boot by more than the spread within an arm:

    • story load: on 53.6, 53.1 s; off 48.1, 49.1, 48.6 s;
    • standing: on 119.9, 118.8 s; off 113.4, 110.8, 113.4 s.

    That's 2 on boots against 3, over two builds, so it's a likely load-time gain rather than a measured one.

  • Boots that weren't quiet are left out of both:

    • here, on 55.5 / 133.7 s;
    • on the branch, off 53.8 / 120.1 s and on 49.3 / 117.4 s.
  • Frames: in the window, draws build what the prebuild would have built earlier, so shader_compile_and_link is about 2 ms per frame higher. p50 is 3-5 % higher, against the 134 ms frames of a cold cache.

  • CPU: the cost the prebuild adds is certain.

The summary lines, traces, nav cues and quiet verdicts of all four boots, and the summary lines and nav cues of the branch pair (branch-cb1-*), are attached at https://github.com/chitters2004/AnyPS5/releases/tag/pr-library-prebuild-opt-in.

Tests: agc_driver_prepared_graphics_prebuild_{unset,0,1} now run against APS5_LIBRARY_PREBUILD:

  • unset and 0 materialize no registration result, so nothing reaches the prebuild;
  • 1 materializes the fragment result.

agc_driver_prepared_graphics opts in for its own prebuild checks.

These ran on Linux (Mesa llvmpipe, LLVM 20.1.2) and on Windows, on main 6db6a3e927 and on this change, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and the Khronos validation layer 1.4.363.1. All 4 pass on both sides on both platforms, with 0 validation messages.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: Mesa llvmpipe (LLVM 20.1.2), Linux; NVIDIA GeForce RTX 3080, driver 621.24, Windows 11 (in-game cold boots)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5400071712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23812). Originally posted by [chitters2004](https://github.com/chitters2004) on 2026-11-19T17:47:46Z. --- ### What Graphics pipeline library prebuild becomes opt-in. It runs only with `APS5_LIBRARY_PREBUILD=1`. `APS5_NO_LIBRARY_PREBUILD` is no longer read; the `docs/dev/ENVIRONMENT.md` row for the new switch says so. Why: at shader registration the prebuild compiles every part a registered shader could need, before any draw asks for it. On GTA V that's about 12 times what the game reaches by the time it's standing in the world. It costs about 10 minutes of worker-thread CPU per cold-cache boot, and loading isn't faster with it; the quiet boots below load sooner without it. On a warm cache it does nothing useful either. With it off, draws build only the parts they use. ### Tested GTA V in-game, build against build: - **on:** `main` 6db6a3e9276; - **off:** the same plus this change. Both builds have #14561 merged for the measurement only, since GTA aborts without it. Both use their defaults, with no profile switch and only `APS5_TRACE_SECONDS=140:30` set (stood_still plus about 20 s). The shader cache was emptied before every boot. Setup: - RTX 3080 on PCIe Gen4 x16, NVIDIA 621.24; - Ryzen 7 5800X, Windows 11, 3840x2160; - content PPSA04263 01.011.001, the city save outside Franklin's house; - Defender on. One untimed warm-up boot ran per build, then the order on, off, off, on. A boot that wasn't quiet ran once more. The second on boot was still not quiet on its rerun (another process on the machine), so it's left out. That leaves one on boot and two off: | | on | off (2 boots) | |---|---|---| | first frame | 2.7 s | 2.6, 2.5 s | | story load | 53.1 s | 49.1, 48.6 s | | standing in the world | 118.8 s | 110.8, 113.4 s | | 30 s window p50 / p99 frame | 134.1 / 207 ms | 141.1 / 516, 138.6 / 322 ms | | window `Driver.Draw.shader_compile_and_link` per frame | 49.8 ms | 52.0, 52.1 ms | | `Vulkan.GraphicsPipelinePrebuild`, summed per boot | 625 s | 0, 0 | | `Vulkan.GraphicsPipelineLibrary`, summed per boot | 665 s | 46, 43 s | Reading the table: - **Load:** the off boots reached the world 5-8 s sooner. An earlier pair on our development branch (draw pipeline on, prebuild with a stage gate, same machine and scene) went the same way: - on: story load 53.6 s, standing 119.9 s; - off: 48.1 s and 113.4 s. Across both sets, every quiet off boot beat every quiet on boot by more than the spread within an arm: - story load: on 53.6, 53.1 s; off 48.1, 49.1, 48.6 s; - standing: on 119.9, 118.8 s; off 113.4, 110.8, 113.4 s. That's 2 on boots against 3, over two builds, so it's a likely load-time gain rather than a measured one. - **Boots that weren't quiet** are left out of both: - here, on 55.5 / 133.7 s; - on the branch, off 53.8 / 120.1 s and on 49.3 / 117.4 s. - **Frames:** in the window, draws build what the prebuild would have built earlier, so `shader_compile_and_link` is about 2 ms per frame higher. p50 is 3-5 % higher, against the 134 ms frames of a cold cache. - **CPU:** the cost the prebuild adds is certain. The summary lines, traces, nav cues and quiet verdicts of all four boots, and the summary lines and nav cues of the branch pair (`branch-cb1-*`), are attached at https://github.com/chitters2004/AnyPS5/releases/tag/pr-library-prebuild-opt-in. Tests: `agc_driver_prepared_graphics_prebuild_{unset,0,1}` now run against `APS5_LIBRARY_PREBUILD`: - unset and `0` materialize no registration result, so nothing reaches the prebuild; - `1` materializes the fragment result. `agc_driver_prepared_graphics` opts in for its own prebuild checks. These ran on Linux (Mesa llvmpipe, LLVM 20.1.2) and on Windows, on `main` 6db6a3e9276 and on this change, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and the Khronos validation layer 1.4.363.1. All 4 pass on both sides on both platforms, with 0 validation messages. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: Mesa llvmpipe (LLVM 20.1.2), Linux; NVIDIA GeForce RTX 3080, driver 621.24, Windows 11 (in-game cold boots) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!23812
No description provided.