Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
chitters2004:perf/agc-library-prebuild-opt-in
Nov 20, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
chitters2004:perf/agc-library-prebuild-opt-in

Conversation

@chitters2004

@chitters2004 chitters2004 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 6db6a3e;
  • 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 6db6a3e 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

…ARY_PREBUILD=1

A cold boot spent minutes of worker CPU prebuilding registration-form
libraries for parts the draws mostly never used, with no measured load or
frame gain, so the prebuild is now opt-in. APS5_LIBRARY_PREBUILD=1 turns
it on; APS5_NO_LIBRARY_PREBUILD is no longer read. The policy tests check
that unset and 0 materialize no registration result and 1 does, and the
prepared graphics test opts in for its prebuild checks.
@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

NVIDIA Linux run with the Khronos validation layer of the current head 36e07636fb; the measurement in Tested is NVIDIA on Windows without the layer.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 36e07636fb merged onto main 40206fe50d with --no-ff (clean, as 4515ffad73). Main baseline is a Release build of 40206fe50d on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_prepared_graphics' -V
main 40206fe50d this PR
Result 4 of 4 passed 4 of 4 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 4 4
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

The pattern is the prepared graphics test and its three prebuild policy cases (unset, 0, 1), which this PR changes from APS5_NO_LIBRARY_PREBUILD to APS5_LIBRARY_PREBUILD; each side ran its own CMake definitions. Every process selected the RTX 4090 and loaded the layer. No speed measurement was taken here.

No new VUID- errors; the four prepared graphics tests pass on Ada on both sides.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line build docs agc libSceAgc* labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown

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.

@Colewiz7

Copy link
Copy Markdown
Contributor

Head 36e07636fb merged onto main 23786c4e4f as e8d06ef2ca, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
tests run (6299 on the 7900 XT, the 2028 GPU ones on the iGPU), new failures vs main none none
-R '^agc' (1960 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the set of distinct validation messages matches main.

AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs perf numbers missing perf pull request without a before and after summary line perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants