Repository navigation
perf(shader): digest the device's SPIR-V features once instead of on every cache key - #14266
Conversation
…every cache key The recompile cache key mixed every supported capability and every byte of every supported extension name each time it was built, which is once per draw stage. The shader device profile fixes its capability and extension lists in its constructor and never changes them, so it now seals their digest into its target there. A key uses the sealed digest while the target's feature spans are the ones it was computed from, and digests them as before otherwise. Key values are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015W3M6NbYpmwWkzkL8YNLaF
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (5 IDs in 484 tests)Skipped (45)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
…URE_REPLAY A capture walks the SRT tape and evaluates every descriptor even when a draw only moved descriptors. With APS5_CAPTURE_REPLAY=1 (off by default) a prepared invocation's capture is rebuilt from the last capture of the same source and plan: the tape records, for every SRT slot, the address it read, the word and whether the slot was active, and the replay rereads exactly those addresses through the same SrtRuntime reader, so ShaderMemory records the same regions and applies the same pending-write handling a full capture does. Nothing read earlier is reused unread, so the draw cache's gates (pending GPU writes, labels, generations) need no second copy. The words feed the same snapshot finish as a full capture (finishSnapshot, split out of materializeSnapshot), then degamma, tables and SRT guards as before. Slot roles are flags, computed beside the pure flat slots and again when a plan is read from the disk cache (the format is unchanged): Descriptor (a descriptor dword is exactly the slot), Address (reaches an address argument of any raw read, including a V# whose records bound a constant-buffer read), Selector (a control-flow condition), Fill, Computed (feeds a descriptor dword through arithmetic) and Fixed (a plan the roles cannot classify). A changed word is accepted only when its slot has no flag but Descriptor; changed user data, any changed word with another flag, an unreadable or unmapped slot, an active descriptor slot the walk did not read, a descriptor the finish rejects, or a moved invalidation serial fall back to a full capture. Plans with image tables, a uniform fill, poisoned or null-root reads are not recorded. APS5_CAPTURE_REPLAY=shadow also runs the full capture and throws on any difference in descriptors, flattened SRT, user data, fill, poison, tables, user-data use or read trace. CaptureReplays(outcome) counts replays and each fallback reason; APS5_PROFILE_DRAW prints them every ten seconds as "[recompile] capture replay". Report for draft/stage-overhead-v3 (C4 follow-up), CPU only, no GPU or game in this session. Numbers rank changes on this machine; none is a speed claim. Commits on draft/stage-overhead-v3 (base 0ff0124, which is draft/stage-overhead-v2): - 9fd594d test(agc): stage fixture loading 8 V# and 1 T# through a table (real buffers, image, 40-word flattened SRT); --bench per phase (invocation, capture, materialize) for hit, moved buffer (memo churn at capacity) and moved image (true miss: 8000 distinct bases); --bench-churn for profiling. - 793383f perf(shader): image masking in the masked result memo. - this commit: replay prototype and fallback counters. Recompile gap (GTA: 7.1 us/packet, patch+Populate explain ~400 of ~1,240 ms per 10 s). perf (DWARF call graphs) of the moved-buffer churn case, samples under materializePreparedMemoized: vector<bool> copies of the donor's bindings 21%, operator new 15.5%, free 13.3%, releasing the evicted result 5.4% (together ~55%: the donor copy plus destroying the evicted result), snapshotHash 16%, the rest inlined (patch, insert, resultBytes). Cherry-picking boykopovar#10757 (reuse an evicted result's storage for the next patched result) locally, conflict resolved by hand, not pushed: churn materialize 1535 -> ~880 ns (-43%, three runs 868-887). boykopovar#10757 is the largest lever found for the gap; land it rather than a copy of it. Eviction itself: ~1 per result is the 4-way, 64-set table of each source refilling with snapshots that never recur (8.6% full hits against 82% patched); the 256 MiB global trim cuts to 3/4 per pass, so it runs rarely. Sizing and ways were not changed: no evidence here that more ways would raise the hit rate when descriptors move every draw. Remaining after boykopovar#10757: the snapshot hash (serial FNV over every descriptor and flattened word) and copy-assigning the donor's per-binding vector<bool> metadata. Image masking (793383f). Safety proof: the compiled result depends on an image descriptor's base only through "base is zero". The binding plan cache key (preparedBindingPlan) already omits word 0 and word 1's low byte except for that test; every base read in plan building (ConstantImageComponents, null-image checks, metadata flags) is that test; Populate copies the 8 words as they are (identity swizzle touches only word 3; inactive elements are zero); ShaderDataDwordsFor copies them into the registration-module metadata; color-target merge images come from the request. So the masked hash keeps dword count, available mask, base-is-zero, word 1 above the base byte and words 2-7, and the patch rewrites words 0-1 of each active element in the image binding and, for registration modules, in the shader data (push data or the ShaderData binding). Fixture: miss 2797 ns vs patched 1373 ns of materialize (4 runs each). GTA's 9.5% misses are an upper bound on what this reaches; which of them are image-only is unmeasured. Replay. Capture of the descriptor fixture: 3.6 us -> 1.70-1.76 us with APS5_CAPTURE_REPLAY=1 (hit, moved buffer and moved image alike). Cost when ineligible: the one-word pixel fixture whose user word changes every draw goes 1277 -> 1515 ns per stage (recording each capture plus a refused attempt), so eligibility decides whether it pays. Benchmark method: build/tests/agc_driver_stage_recapture_tests --bench, Release, GCC 13.3, Xeon @ 2.10 GHz VM, taskset -c 2, ANYPS5_NO_SHADER_CACHE=1, each binary with its own copy of build/core/libs/libs/unpatched via LD_LIBRARY_PATH (the test loads libSceAgcDriver.prx at run time). Fixture phases: 21 batches x 2000 draws after a warm-up batch, a fresh ShaderMemory per draw; median of four interleaved runs, range of run medians: measure (ns) before (9fd594d) after, replay off after, replay on descriptors hit capture 3639 [3560-4069] 3585 [3526-3657] 1698 [1651-1714] descriptors hit materialize 341 [331-347] 308 [302-314] 303 [299-307] moved buffer capture 3644 [3615-3688] 3771 [3654-3945] 1759 [1726-2505] moved buffer materialize 1402 [1372-1422] 1417 [1385-1466] 1353 [1343-1870] moved image (miss) capture 3658 [3589-3848] 3672 [3655-3718] 1756 [1736-2507] moved image (miss) materialize 2797 [2758-2953] 1373 [1370-1389] 1355 [1340-1857] pixel stage, new user data 1243 [1225-1261] 1277 [1236-1316] 1515 [1506-1538] InvocationFor 557 [548-651] 542 [525-560] 544 [540-603] Tests and mutations (StageRecapture.cpp; CTest modes default, verified, unmasked, replay_shadow, replay; 72 CPU tests pass, 29 need Vulkan and skip; the agc_shader suites also pass with APS5_CAPTURE_REPLAY=shadow exported; check_conventions passes). Every mutation below was run under the stated modes: image (default, verified, unmasked modes): I1 masked hash drops word 1 above the base byte KILLED I2 masked hash drops words 2-7 KILLED (height-only change) I3 masked hash drops base-is-zero KILLED I4 patch skips word 1 KILLED (base bit 40) I5 patch skips registration metadata KILLED I6 full hash drops images SURVIVED: the T# words are also in the flattened SRT, which the full hash covers I7 patch skips word 0 KILLED I8 metadata patch one word early KILLED replay (shadow and replay modes): R1 replay accepts a changed address word KILLED (two-tables swap) R2 roles skip address cones KILLED (two-tables swap) R3 replay keeps old descriptor dwords KILLED R4 replay ignores changed user data KILLED R5 tape records no slot words KILLED R6 replay writes flattened words of inactive slots SURVIVED: no fixture with control flow that reads an inactive slot for a descriptor R7 roles treat computed dwords as identities KILLED (s_and_b32 fixture) The riskiest failure, old addresses after a pointer moves while variant and bindings match, is the two-tables test: the root word is an Address slot, so the swap is refused ("address word") and the stage binds the second table's V#; R1 and R2 make it bind the first table's and fail, and shadow mode reports the buffer difference. Not run or unverified: - No GPU: no ANYPS5_REQUIRE_VULKAN or validation-layer runs, no VUID comparison; prepared shader/graphics tests and fusion skip. - No game: GTA eligibility, fallback mix and frame effect unmeasured. A boot with APS5_CAPTURE_REPLAY=1 (or shadow) and APS5_PROFILE_DRAW=1 prints replays and every fallback reason per 10 s; shadow throws on the first mismatch. - Replay hooks only PreparedShaderInvocation::Capture (draws and dispatches through CaptureInvocation); CaptureResources and the dispatch-ahead paths still walk. - One recipe per source: a shader drawn alternately with two SRT layouts refuses every other draw. - Replay reads each word without the descriptor scope the walk opens around multi-word descriptor reads; the invalidation serial is checked before and after, and shadow mode is the guard until measured. - Selector, fill and inactive-slot paths have no CPU fixture (R6). - boykopovar#10757 measured only as a local cherry-pick; boykopovar#14266 (sealed feature digest) not applied; InvocationFor still spends ~200 ns on the digest with test targets. - ShaderDiskCache's IrResourcePlan layout guards now expect 776 bytes and 26 fields (two derived fields recomputed at decode); checked on Linux GCC only, not on MinGW. - No Windows build, no ASan/TSan, no full test suite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011mLh2bAPqp631cncf3kCbJ
Each replay fixture's plan is encoded and decoded with the disk cache's EncodePlan and DecodePlan, and the roles, source dword slots and replay eligibility derived after the load must equal those of the built plan, so a warm start replays exactly what a cold one would. Report for draft/stage-overhead-v4 (C4 v4 brief), CPU only. Numbers rank changes on this machine; none is a speed claim. Per-frame figures use the brief's GTA rates: 4,100 stages, 3,362 patched, 388 misses, 352 hits; 1 us per capture = 4.1 ms, per patched result = 3.36 ms. Checked against main first: upstream main moved 87 commits since v3's base; none touches the replay, memo or capture code except boykopovar#13517 (disk cache key pair hash). boykopovar#10757, boykopovar#14266 and boykopovar#9899 are still open. Commits (base bbed4ea = v3): - 03abbc4 fix(shader): replay proves its reads, keeps span sync, rolls back refusals; static eligibility; no SourceEntry cycle; oracle tests. - this commit: disk cache round-trip of derived roles. Items, ranked by ms per frame: 1. Capture (brief items 1, 2, 3, 4, 6). Replay on the descriptor fixture: capture 3.6 us off -> 2.46 us on (3 interleaved runs each, medians 3547/3607/3589 vs 2336/2460/2473 ns for hit, moved buffer, moved image). Upper bound if every stage were eligible: 1.1 us x 4,100 = 4.6 ms per frame; the eligible fraction is unmeasured. v3 reached 1.7 us; the 0.75 us difference is the price of the fixes below (span scoped descriptor reads, read journal). A statically ineligible stage now costs one branch and a relaxed counter: the one-word pixel stage 1267 ns off vs 1280 ns on (v3: +19%). - P1 unrecorded reads: fixed. A plan is ineligible when any memory read reachable from a descriptor, condition or address cone is not a recorded slot (dynamicReads included), decided once per plan (IrResourcePlan::replayEligible, recomputed after a disk cache load). Shown by: the static+runtime-offset fixture reports "ineligible plan" and matches the oracle; mutation V1 (drop the check) fails it. - P1 span sync: fixed. Descriptor words are reread first, in source order, under the span the tape opens. Shown by: with pages read word by word, the set of (address, bytes) pending-write queries of a replayed draw equals an independent full capture's; mutation V2 (span 0) fails it. - Found by the new oracle, not in the brief: a refused replay left its reads in ShaderMemory, so after a pointer swap the draw recorded the old table's words as regions the draw cache would validate. Fixed with an SrtRuntime read journal over ShaderMemory's read/recent masks, rolled back unless replay commits. Mutation V3 (always commit) fails the pointer-swap region check. - P2 cycle: fixed; SourceEntry keeps plan, recipe, user-data use and read trace only. Recipe bytes are still outside the memo budget (one recipe per source, a few hundred bytes). - Item 4, a compiled capture plan replacing the tape: not done. I disagree that it should replace guarded replay as the next step: the tape's own evaluation is ~25% of capture in the fixture profile (compute + Run + evaluate), reads through ShaderMemory and the walk's bookkeeping are the rest, so a faster evaluator that still re-derives every address and branch bounds out near 1 us of 3.6. Guarded replay keeps addresses and branches only behind equality of every word that produced them (now proven complete statically) and still reads every word. If eligibility in GTA turns out low, the compiled plan is the next lever; it shares the role analysis built here. - Item 6 oracle: done. Oracle() captures through CaptureResources (never replayed) on its own ShaderMemory, materializes without the memo, and the test compares results, descriptor words, every region read (address and bytes) and the pending-write spans queried. 2. Patched path (item 5), 3,362 per frame. Churn materialize 1.41 us (descriptor fixture, every insert evicting). perf: ~55% donor deep copy (vector<bool> metadata, new) and freeing the evicted result, 16% hashing. boykopovar#10757 cherry-picked locally earlier: 1535 -> ~880 ns (-43%), ~2.2 ms per frame at GTA's rate; it remains someone else's open PR, not pushed here. Experiment (not committed): not inserting patched results into the exact memo at all leaves churn materialize unchanged (1408 vs 1424 ns medians of 3): the copy is destroyed later by its consumer instead, so admission alone saves no CPU; only avoiding the deep copy does. The payload split (shared module and layout, a structural binding template, a per-invocation payload of descriptors, user data and flattened SRT) is the right design but touches ~200 uses of DescriptorBinding's per-element metadata across the driver, which this CPU-only session cannot exercise; not started. Expected effect if the template holds the ~20 metadata vectors: the copy shrinks to the payload words, i.e. most of the 55%. 3. Exact key compare (item 8), predates us. Memo lookup trusts a 64-bit FNV hash. An exact compare needs the key words kept per entry: one copy per insert (~3,750 per frame) and one compare per hash hit (~3,714 per frame). At memcmp speed (~0.1-0.2 ns per word vs ~2.4 ns per word for the serial hash, from the profile) and an estimated 100 to 500 key words per GTA snapshot: ~0.04-0.4 ms per frame CPU, plus 65-73k entries x 0.4-2 KB = 26-140 MiB of memory. Collision risk of a good 64-bit hash is negligible, but FNV over 32-bit words mixes differences only upward. Not changed; a cheaper hardening is a stronger 64-bit mixer at equal cost. 4. Image masking (kept from v3): miss 2.8 us vs patched 1.37 us of materialize in the fixture, at most 388 x 1.4 us = 0.54 ms per frame. Tests and mutations (StageRecapture.cpp, CTest modes default, verified, unmasked, replay_shadow, replay; 72 CPU tests pass, 29 Vulkan-only skip; agc_shader suites also pass with APS5_CAPTURE_REPLAY=shadow; check conventions passes): V1 roles miss unrecorded reads KILLED (static+runtime offset) V2 descriptor reads without span KILLED (span query sets) V3 refused replay keeps its reads KILLED (pointer swap regions) V4 every plan eligible KILLED V5 (R6) inactive slot takes reread word SURVIVED: no fixture evaluates a slot whose flat output is inactive V6 changed selector accepted KILLED (branch fixture) R1, R2, R3, R4, R5, R7 KILLED (rerun on v4) D1 disk decode skips slot roles KILLED (round trip) New fixtures: runtime offset beside a static descriptor, branch on a table word (selector on and off, buffer moved while off), pointee moved behind an unchanged pointer, one buffer both bound and the address and bounds of another descriptor read (Descriptor and Address roles on one word). Not done or unverified: - Item 7 partly: pending descriptor writes across page crossings and forced-sync retries, image masking breadth (storage and atomic aliases, repeated storage mips, inactive registration heaps, MSAA/FMASK, tiling, constant swizzles, target merges), lifetime tests. - R6 fixture; selector-dependent flat activity. - Item 4 compiled plan and item 5 payload split (reasons above). - No GPU: no Vulkan or validation-layer runs. No game: eligibility, fallback mix and frame effect unmeasured; a boot with APS5_CAPTURE_REPLAY=shadow APS5_PROFILE_DRAW=1 prints replays and each fallback reason per 10 s and throws on the first mismatch. - Disk cache layout guards (776 bytes, 27 fields) checked on Linux GCC only; no Windows, ASan, TSan or full suite. My own best idea: measure eligibility first. If most GTA stages refuse on user data (per-draw SRT pointers from a ring), extend recipes to treat a user-data pointer word as an Address root that may change when the pointee layout is identical, by keying recipes on (plan, pointee offsets) and rereading through the new base; that turns the common "same table layout at a new ring address" case from a refusal into a replay without freezing any address, and it uses the same journal and oracle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011mLh2bAPqp631cncf3kCbJ
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings; one question on the cache key
The device's SPIR-V feature digest is now computed once when the target is sealed, and the cache key reuses it while the feature vectors' data pointers and sizes stay the same. Otherwise the digest is computed again, as before. The design is sound as far as the code read here shows. One question needs an answer: the check compares addresses and sizes, not contents, so an in-place edit of a sealed vector would keep the old digest. No hosted run of the new tests has happened on this head.
What I ran
- Head
3e50578d9381146fa3a8de0be066cc2fc1ef3f65; base5e936063e3a74b7f03ff06905be04c5a00be60a7. 5 files, +81/-4:core/shader/recompiler/CacheKey.hpp(the seal, the spans, the cached digest and the fallback),core/shader/recompiler/Recompiler.hpp(the cached digest fields onSpirvTarget),libSceAgcDriver/Execution/src/ShaderDeviceProfile.cpp(seals the target),libSceAgcDriver/tests/ShaderDeviceProfile.cpp(new tests), andcore/shader/recompiler/CMakeLists.txt. - Read the production diff in full (the lines shown above, covering the four production files).
- Not read: the test file in full, the CMake registration in full, and the callers of
SealFeatureDigestbeyond the one inShaderDeviceProfile.cpp. - Hosted: the Windows CTest run for this head executed one case (
conventions_blob_reads,100% tests passed, 0 tests failed out of 1), so the new shader tests did not run there. The relinker jobs' test lists were not checked for these tests, and Linux is skipped on this head. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed (no declared dependencies, no errors). The ABI audit is not applicable.
- No MarcZX10 review at this head.
Results
| Check | Result | Note |
|---|---|---|
| Diff check | passed | |
| Conventions and PR template | passed | conventions check from the main checkout |
| Mergeability and dependencies | passed | stack check passed; no declared dependencies; no errors |
| Fallback when the spans differ (read) | passed by reading | appendFeatureDigest recomputes the digest unless the target is sealed and the spans still match |
| Sealed digest equals a recomputed digest (read) | passed by reading | SealFeatureDigest stores what digestFeatures returns |
| In-place edit of a sealed vector keeps the old digest | not verified | the spans compare pointers and sizes, not contents; the callers that edit the vectors were not read |
The new shader device tests (tests/ShaderDeviceProfile.cpp) |
not run | the Windows run executed one unrelated case |
| ABI audit | not applicable | no export changed |
| Build and runtime tests (Linux) | not run | Linux is skipped on pull requests; the relinker test lists were not checked for these tests |
| Negative controls | not run | no local build |
| Hosted CI | passed (partial) | windows (one case), both macOS and Windows and Ubuntu relinkers, conventions and PR checks succeeded; linux skipped |
Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed, no errors. Hosted: gh api repos/boykopovar/AnyPS5/commits/3e50578d9381146fa3a8de0be066cc2fc1ef3f65/check-runs, and the Windows job log.
Negative control
Not run here. A negative control needs a local build and run of the device test, and code from this head is not run here.
Findings
Blocking
None from the code read.
Non-blocking
- Question on the cache key. The sealed digest is reused when the feature vectors' data pointers and sizes match. If a sealed vector's values change in place (same address and size), the old digest is used, and two different feature sets could map to one key. Please confirm that the supported-capability and supported-extension vectors are not edited after
SealFeatureDigest, or compare contents (or re-seal on edit). - The new tests have not run on this head. A run of
tests/ShaderDeviceProfile.cppon a host that builds the shader recompiler would settle the equality claims.
Sources
- Cache key: https://github.com/boykopovar/AnyPS5/blob/3e50578d9381146fa3a8de0be066cc2fc1ef3f65/core/shader/recompiler/CacheKey.hpp
- Target fields: https://github.com/boykopovar/AnyPS5/blob/3e50578d9381146fa3a8de0be066cc2fc1ef3f65/core/shader/recompiler/Recompiler.hpp
- Device profile: https://github.com/boykopovar/AnyPS5/blob/3e50578d9381146fa3a8de0be066cc2fc1ef3f65/core/libs/prx/libSceAgcDriver/Execution/src/ShaderDeviceProfile.cpp
- Windows job log: check-run
windowson 3e50578
Not verified
- Whether any caller edits the feature vectors in place after sealing.
- The new device tests (not run).
- Linux behaviour.
To get this to a good state
- Answer the in-place-edit question (or make the seal check contents). Run the new device tests on a host that builds the recompiler.
|
Independent Linux check of head Both arms use main Ryzen 9 7950X, RX 6650 XT, RADV Mesa 26.2.6, Linux 7.2.11, GCC 16.2.1 Release. Each side warmed its own compatible shader/Mesa caches; measured runs restart with fresh private writable state, identical input schedule, stationary underwater “L to move” scene (230/310-second captures reviewed), PTY stdout/stderr and only All attempts, in execution order:
Do not pool the two resolutions. Both frozen SDKs pass the same 4 focused checks ( Full summaries, traces/digests, reviewed captures, native reports, protocol, focused test logs, exact patches and preparation failure receipts, SHA-256 |
|
The lists are never edited in place. The profile copies, sorts and deduplicates them into its own private vectors in its constructor and seals the digest last. The profile is created The new tests pass at this head on Linux / RX 9070 XT (RADV): |
What
Every recompile cache key carries a 128-bit digest of the device's supported SPIR-V capabilities and extensions (#10438).
RecompileCacheKeycomputes it again for each key it builds: it mixes every capability and every eight bytes of every extension name, for each stage of each draw and for each dispatch. Local timers on an older base (not part of this PR) counted 41 capabilities and 13 extension names on an RX 9070 XT with RADV, and in Astro Bot about 10,000 such keys per present on the draw finisher (about 5,900 draws), at about 0.6 us of digest per key: 6.5 ms per present.The lists come from the shader device profile, which copies, sorts and deduplicates them into its own storage in its constructor. The profile is created
const, cannot be copied or moved, and never changes its lists afterwards. It now computes the digest once, at the end of its constructor (RecompileCacheKey::SealFeatureDigest), and stores it in its target together with the address and length of the capability and extension spans it was computed from (SpirvTarget::featureDigest,featureDigestSpans,featureDigestSealed).A key uses the stored digest only while the target's capability and extension spans are the profile's own: the same address and the same length for both. Any other target digests its lists as before, for example a request read back by
RequestSerializer, a hand-built target, or a copy whose spans point at other or shorter lists. The copies the driver passes on (VulkanDevice::Target(),ComputeTarget()) keep the profile's spans and change only fields that enter the key separately. Each device has its own profile and digest; two profiles with the same features give the same keys.Keys are byte-identical to
main's; only the work to build them changes, and the digest function is unchanged.agc_shader_device_profilechecks that a profile seals its digest, that the sealed key equals the key digested per key from the same lists and from equal lists in other storage, that a sealed target pointed at a shorter capability or extension list digests the new list, that profiles with the same features in another order give the same key, and that an added capability or extension changes it. A key-dump program built once againstmain's headers and once against this branch gives the same 20 keys (five feature sets including a 41-capability, 13-extension list, extension names of 0 to 25 bytes and 40 names; compute and fragment requests;BuildandBuildInterface) in all three modes: digested per key, sealed, and sealed and then pointed at other lists. In the scene below, this branch's shader cache, written from empty, has 3,587 entries, and with the source version field masked all 3,587 stored keys are byte-identical to the keys inmain's cache (3,587 entries); the same comparison betweenmain's cache and the cache of an older base with another key layout (7,272 entries) matches none. As after any edit undercore/shader/recompiler, the shader cache source version changes, so the disk cache is written again once.RecompileCacheKey::SealFeatureDigestis added toshaderCacheReviewedNames: it only stores the target's own digest and changes no compiled output.Tested
CachyOS (Linux 7.3), Ryzen 7 5700X3D, RX 9070 XT (RADV, Mesa 26.2.5, GPU clock level forced to
high), 3840x2160. PPSA21564 (ASTRO BOT 01.007.000), started intounderwater_aerial_gardenwith-lvl, standing at the spawn with no input, warm caches (each side ran the scene before; this branch built its own shader cache in two warm-up boots), 0 shader cache misses in every measured run on both sides.Base:
main029463ceb6; change: this branch at8ef71d4cea, measured before it was rebased ontomain3ab5a11d66without conflicts (the same diff; rebuilt and its focused tests rerun after the rebase). Plainmainneeds a larger host-import budget than its default to run this scene at a usable rate, so both sides setAPS5_HOST_IMPORT_MIB=11815. Switches on both:APS5_DEPTH_PLANE_COPY_MIB=512 APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1 APS5_NO_PAD_INPUT=1 APS5_HOST_IMPORT_MIB=11815.Clean runs, each measured from 40 s to 130 s after the level started, in the order A B B A B A A B, four per side, no run excluded; FPS from every frame of that window, intervals by Welch's t-test over the four runs per side:
mainDriver.DrawFinishms per frameDriver.Draw.preparems per frameEvery B run is faster than every A run.
Driver.DrawFinishis the draw finisher's work per draw, which builds the recompile keys of the draw's stages; it drops by 3.4 ms per frame, and the GPU time does not change. Every run has one long frame about 86 s after the level started, when the title starts a video, and the frame after it is the second frame over 500 ms; both were shorter on B (longest frame mean 991 against 1,456 ms, the frame after it 721 against 1,061 ms). Nothing in this PR obviously explains that, and four runs do not attribute it.Summary lines of the attached traces, captured as the Performance report form describes (no other
APS5_TRACE_*orAPS5_PROFILE_*switch; the runner reads the log through a pipe on both sides). The window is 4 s, 40 s after the level started, because in a 10 s window the default event buffer would drop queue worker0x0's events; 13 presents are too few to compare frame times, which the clean runs above do:{"commit":"029463ceb62c","dirty":false,"env":{"APS5_DEPTH_PLANE_COPY_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"11815","APS5_NO_PAD_INPUT":"1","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"55:4"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.5-arch3.1","os":"Linux 7.3.0-4-cachyos","cpu":"AMD Ryzen 7 5700X3D 8-Core Processor","cpu_threads":16,"memory_mib":31992,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"seconds 55:4","first_present":391,"ms":4261.760},"presents":13,"frame_ms":{"p50":326.603,"p90":333.713,"p99":334.457,"max":334.457},"gpu_busy_ms_per_present":167.423,"worker_busy_pct":{"queue worker 0x0":97.906,"queue worker 0x40":93.526,"queue worker 0x48":92.502,"queue worker 0x46":0.821},"top_phases_ms_per_frame":{"Driver.Packet":931.394,"Driver.Packet.memory_wait":580.810,"Driver.Packet.draw":221.732,"Driver.Draw":220.863,"Graphics.Draw":194.136,"Driver.DrawFinish":188.645,"Driver.Draw.prepare":185.721,"Graphics.Draw.draw_and_resource_release":159.595},"trace_dropped":false,"trace":"aps5-trace-029463ceb62c-629854.json.gz"} {"commit":"8ef71d4cead1","dirty":false,"env":{"APS5_DEPTH_PLANE_COPY_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"11815","APS5_NO_PAD_INPUT":"1","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"53:4"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.5-arch3.1","os":"Linux 7.3.0-4-cachyos","cpu":"AMD Ryzen 7 5700X3D 8-Core Processor","cpu_threads":16,"memory_mib":31992,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"seconds 53:4","first_present":403,"ms":4147.067},"presents":13,"frame_ms":{"p50":320.163,"p90":328.026,"p99":330.152,"max":330.152},"gpu_busy_ms_per_present":167.006,"worker_busy_pct":{"queue worker 0x0":97.782,"queue worker 0x40":93.932,"queue worker 0x48":92.402,"queue worker 0x46":0.881},"top_phases_ms_per_frame":{"Driver.Packet":906.912,"Driver.Packet.memory_wait":559.819,"Driver.Packet.draw":218.613,"Driver.Draw":217.707,"Graphics.Draw":190.146,"Driver.DrawFinish":184.921,"Driver.Draw.prepare":181.646,"Graphics.Draw.draw_and_resource_release":156.008},"trace_dropped":false,"trace":"aps5-trace-8ef71d4cead1-630424.json.gz"}tools/trace_digest.py:main13 presents, frame p50 326.6 / p99 334.5 ms, GPU busy 167.4 ms per present, draw finisher busy 165.8 ms per present; this PR 13 presents, frame p50 320.2 / p99 330.2 ms, GPU busy 167.0 ms per present, draw finisher busy 159.2 ms per present;dropped: noon both.Validation: the 68 tests of
-R '^(agc_shader_device_profile|agc_shader_disk_cache.*|agc_shader_memory|agc_driver_graphics.*|agc_driver_prepared.*|agc_driver_registration.*|agc_driver_draw_data_hit.*|agc_driver_draw_cache.*|agc_pipeline_library.*|agc_driver_frame_replay_shader.*|request_serializer|shader_cache_file_read)$'(key building, the shader disk cache, prepared and registered shaders matched at use, draw caches, pipeline libraries, and draws compiled through a device's profile) withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandctest -V, onmain(029463ceb6) and on this branch: 68 of 68 pass on both, neither log reports the layer missing, and the validation messages are identical per test: the same 20VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605errors inagc_driver_prepared_exportsand the same 16 warnings on both sides; this PR adds none. The full suite (ctest, 3,100 tests,ANYPS5_REQUIRE_VULKAN=1) passes apart fromagc_driver_tessellation(a crash inside RADV) andagc_idle_publish_wait, which fail onmainas well. The new checks fail when the sealed digest is used without the span check, when the check compares addresses only, when a wrong digest is sealed, and when the profile does not seal.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)aps5-trace-029463ceb62c-629854.json.gz
aps5-trace-8ef71d4cead1-630424.json.gz
🤖 Generated with Claude Code