perf(agc): relocate cached draws across user words that only reach the shader as values #6539

Closed
TheAggie wants to merge 11 commits from upstream-pr/6539 into main
TheAggie commented 2026-10-15 19:24:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-15T19:24:24Z.


What

Third step for #4054, stacked on #5609. A user-data word that the resource walk never reads, and that the compiled stage only receives as a pushed value, still took part in the draw key and in the relocation alias. RADV's base-vertex SGPR is one: it changes on every draw, so a title whose draws would otherwise relocate across its moved pointers missed on every draw anyway. On Ratchet & Clank under RetroArch's PCSX2 core, 0.1% of draws hit the cache.

  • A stage's capture now also records which of its pushed user words (shaderDataUserWords) the resource walk did not read at all: DispatchVariant::forwardedWords.
  • When a shader set's relocation is learned and it has at least one read-through pointer word, those forwarded words are learned beside the pointers, marked forwarded. They stay out of the alias key, a relocation accepts any change to them, and the new value is patched into the pushed data the same way a moved pointer's value is.
  • A shader set whose user words are all plain values is left to main's data-only path (#5216's shape reuse), which already owns that case. A relocation that finds the draw's decode but not every stage also gives way to that path when it applies, instead of claiming the draw with an incomplete entry.
  • The variants and entries a relocation clones come from a small pool that keeps their vectors' capacity (returned when the last reference drops), and the per-stage move and patch lists are thread-local scratch: a draw whose pointers move every draw no longer pays nine heap allocations a stage for its clones.
  • APS5_NO_FORWARDED_RELOCATION=1 turns the forwarded words off; APS5_NO_DRAW_RELOCATION=1 still turns the whole thing off.

Related: #5656 (on #494) lets a data-only hit reuse a stage whose changed user words it never reads; it counts the words a layout forwards into shader data as read, so a changed forwarded word still recompiles the stage there. This PR patches such a word on the relocation path instead. The two touch different paths and no shared code.

Only the commits after #5609's head are this PR.

Tested

Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2.0, on main 940eba9a2 with #4943 and #5609.

  • ctest: 1271 of 1292 pass, 14 skipped. guest_call_trace_abort, windows_backtrace_report and agc_driver_store_over_untracked fail, and fail the same way on plain main here; agc_driver_prepared_graphics_prebuild_0/_1 and undeliverable_host_exception fail under my test runner because it skips their environment changes and pass pattern, and pass run with those; agc_driver_multisample_fill_host_only failed once in the parallel run and passes alone.
  • New case in agc_driver_draw_cache_relocation: a pixel shader reads its red channel through a user-data pointer and its green channel from a user word it gets as a value. Eight draws with the same contents at moving addresses and a changing green value hit the cached draw from the fifth on (0 hits with APS5_NO_FORWARDED_RELOCATION=1), and a hit given green 1.0 writes 255 to the target (64 if the value is not patched: checked by removing the patch).
  • main's agc_driver_draw_cache_reuse cases pass unchanged: their user words are plain values, which still go through the data-only path.
  • RetroArch (PPSA99169) with its PCSX2 core running Ratchet & Clank's intro, pipelined draws, immediate present, audio muted, same build with and without: draw-cache hits from 0.1% to 99.8% of lookups, captures per 10 s from about 460,000 to 950, queue worker from 24.8 to 13.0 µs per draw packet, audio produced in the heavy intro scenes from about 17% of real time to 24-25%. The rest of the gap is the draw pipeline draining on RADV's per-draw cache prefetches, which #6538 addresses; with both, the same scenes reach 37-43% and the lighter ones real time.
  • The pool, same title, same build with and without it, two alternating runs each: heap allocations per draw (counted with a hook on the driver's operator new imports) 167 to 136, audio produced in the heavy intro scenes 41-43% of real time to 45-47%.
  • Same title with APS5_VERIFY_DRAW_ENTRIES=1, which captures every hit again and compares: 0 stages differed; the last four 10 s windows of the run captured 868,744 hits again.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • 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: #4943, #5609
  • AI-assisted: yes. Written with Claude Code under my direction.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4878677951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-15T19:24:24Z. --- ### What Third step for #4054, stacked on #5609. A user-data word that the resource walk never reads, and that the compiled stage only receives as a pushed value, still took part in the draw key and in the relocation alias. RADV's base-vertex SGPR is one: it changes on every draw, so a title whose draws would otherwise relocate across its moved pointers missed on every draw anyway. On Ratchet & Clank under RetroArch's PCSX2 core, 0.1% of draws hit the cache. - A stage's capture now also records which of its pushed user words (`shaderDataUserWords`) the resource walk did not read at all: `DispatchVariant::forwardedWords`. - When a shader set's relocation is learned and it has at least one read-through pointer word, those forwarded words are learned beside the pointers, marked `forwarded`. They stay out of the alias key, a relocation accepts any change to them, and the new value is patched into the pushed data the same way a moved pointer's value is. - A shader set whose user words are all plain values is left to `main`'s data-only path (#5216's shape reuse), which already owns that case. A relocation that finds the draw's decode but not every stage also gives way to that path when it applies, instead of claiming the draw with an incomplete entry. - The variants and entries a relocation clones come from a small pool that keeps their vectors' capacity (returned when the last reference drops), and the per-stage move and patch lists are thread-local scratch: a draw whose pointers move every draw no longer pays nine heap allocations a stage for its clones. - `APS5_NO_FORWARDED_RELOCATION=1` turns the forwarded words off; `APS5_NO_DRAW_RELOCATION=1` still turns the whole thing off. Related: #5656 (on #494) lets a data-only hit reuse a stage whose changed user words it never reads; it counts the words a layout forwards into shader data as read, so a changed forwarded word still recompiles the stage there. This PR patches such a word on the relocation path instead. The two touch different paths and no shared code. Only the commits after #5609's head are this PR. ### Tested Windows 11, NVIDIA GeForce RTX 5070 Ti, MinGW-w64 GCC 15.2.0, on main `940eba9a2` with #4943 and #5609. - `ctest`: 1271 of 1292 pass, 14 skipped. `guest_call_trace_abort`, `windows_backtrace_report` and `agc_driver_store_over_untracked` fail, and fail the same way on plain main here; `agc_driver_prepared_graphics_prebuild_0`/`_1` and `undeliverable_host_exception` fail under my test runner because it skips their environment changes and pass pattern, and pass run with those; `agc_driver_multisample_fill_host_only` failed once in the parallel run and passes alone. - New case in `agc_driver_draw_cache_relocation`: a pixel shader reads its red channel through a user-data pointer and its green channel from a user word it gets as a value. Eight draws with the same contents at moving addresses and a changing green value hit the cached draw from the fifth on (0 hits with `APS5_NO_FORWARDED_RELOCATION=1`), and a hit given green 1.0 writes 255 to the target (64 if the value is not patched: checked by removing the patch). - `main`'s `agc_driver_draw_cache_reuse` cases pass unchanged: their user words are plain values, which still go through the data-only path. - RetroArch (PPSA99169) with its PCSX2 core running Ratchet & Clank's intro, pipelined draws, immediate present, audio muted, same build with and without: draw-cache hits from 0.1% to 99.8% of lookups, captures per 10 s from about 460,000 to 950, queue worker from 24.8 to 13.0 µs per draw packet, audio produced in the heavy intro scenes from about 17% of real time to 24-25%. The rest of the gap is the draw pipeline draining on RADV's per-draw cache prefetches, which #6538 addresses; with both, the same scenes reach 37-43% and the lighter ones real time. - The pool, same title, same build with and without it, two alternating runs each: heap allocations per draw (counted with a hook on the driver's `operator new` imports) 167 to 136, audio produced in the heavy intro scenes 41-43% of real time to 45-47%. - Same title with `APS5_VERIFY_DRAW_ENTRIES=1`, which captures every hit again and compares: 0 stages differed; the last four 10 s windows of the run captured 868,744 hits again. ### Checklist - [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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: #4943, #5609 - [x] AI-assisted: yes. Written with Claude Code under my direction. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nicolasfalesy commented 2026-10-16 08:53:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T08:53:04Z.


Tested on Linux (Arch), c++ (GCC) 16.2.1 20260810, Release, BUILD_TESTING=ON, main at 5d9dcc42d2ec5401aebd089028b8d4d7410a77b4. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8).

With the dependencies from the description (#4943 and #5609) merged first, agc_driver_draw_cache_relocation aborts (2 of 2):

corrupted double-linked list
agc_driver_draw_cache_relocation ...Subprocess aborted

main plus #4943 plus #5609 without this PR passes the same test (2 of 2). main alone does not have the test. glibc detects a heap corruption, so a write past a buffer or a double free happens somewhere in the code this PR changes or runs. I did not find the exact line.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6211829246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6211829246). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-16T08:53:04Z. --- Tested on Linux (Arch), `c++ (GCC) 16.2.1 20260810`, Release, `BUILD_TESTING=ON`, `main` at `5d9dcc42d2ec5401aebd089028b8d4d7410a77b4`. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8). With the dependencies from the description (#4943 and #5609) merged first, `agc_driver_draw_cache_relocation` aborts (2 of 2): ``` corrupted double-linked list agc_driver_draw_cache_relocation ...Subprocess aborted ``` `main` plus #4943 plus #5609 without this PR passes the same test (2 of 2). `main` alone does not have the test. glibc detects a heap corruption, so a write past a buffer or a double free happens somewhere in the code this PR changes or runs. I did not find the exact line. AI-assisted: yes
alfalfa-star commented 2026-10-16 09:32:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-16T09:32:03Z.


Root cause of the corrupted double-linked list abort that @nicolasfalesy reported in agc_driver_draw_cache_relocation.

Reproduced on Linux (Arch), RX 9070 XT (RADV, Mesa 26.2.4), Release, PR head 12a5f02d1: 14 of 15 runs abort. The abort is in static destruction at process exit:

#9  RelocationPool<DrawEntry>::~RelocationPool()
#10 ?? () from libc.so.6
#11 exit ()

entryPool() and variantPool() in DrawRelocate.cpp are function-local statics. relocateDrawEntry calls entryPool().Take() before cloneVariant first calls variantPool(), so the entry pool is constructed first and destroyed last. Its spare DrawEntry objects still hold stages (cleared only when an entry is taken again). Those stages hold shared_ptr<DispatchVariant> objects whose deleter calls Return on variantPool(), which is already destroyed by then. ~RelocationPool<DrawEntry> deletes the spare entries, the variant deleters push into the destroyed pool's vector, and glibc catches the heap corruption.

Fix tested on the same head: make both pools immortal, the same pattern as other process-lifetime singletons in the driver:

RelocationPool<DispatchVariant>& variantPool() {
    static auto* pool = new RelocationPool<DispatchVariant>();
    return *pool;
}

RelocationPool<DrawEntry>& entryPool() {
    static auto* pool = new RelocationPool<DrawEntry>();
    return *pool;
}

With this change agc_driver_draw_cache_relocation passes 10 of 10 runs. Clearing an entry's stages in Return would also work, but the immortal pools also cover any other object that keeps a pooled variant until exit.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6212524520 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6212524520). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-16T09:32:03Z. --- Root cause of the `corrupted double-linked list` abort that @nicolasfalesy reported in `agc_driver_draw_cache_relocation`. Reproduced on Linux (Arch), RX 9070 XT (RADV, Mesa 26.2.4), Release, PR head `12a5f02d1`: 14 of 15 runs abort. The abort is in static destruction at process exit: ``` #9 RelocationPool<DrawEntry>::~RelocationPool() #10 ?? () from libc.so.6 #11 exit () ``` `entryPool()` and `variantPool()` in `DrawRelocate.cpp` are function-local statics. `relocateDrawEntry` calls `entryPool().Take()` before `cloneVariant` first calls `variantPool()`, so the entry pool is constructed first and destroyed last. Its spare `DrawEntry` objects still hold `stages` (cleared only when an entry is taken again). Those stages hold `shared_ptr<DispatchVariant>` objects whose deleter calls `Return` on `variantPool()`, which is already destroyed by then. `~RelocationPool<DrawEntry>` deletes the spare entries, the variant deleters push into the destroyed pool's vector, and glibc catches the heap corruption. Fix tested on the same head: make both pools immortal, the same pattern as other process-lifetime singletons in the driver: ```cpp RelocationPool<DispatchVariant>& variantPool() { static auto* pool = new RelocationPool<DispatchVariant>(); return *pool; } RelocationPool<DrawEntry>& entryPool() { static auto* pool = new RelocationPool<DrawEntry>(); return *pool; } ``` With this change `agc_driver_draw_cache_relocation` passes 10 of 10 runs. Clearing an entry's `stages` in `Return` would also work, but the immortal pools also cover any other object that keeps a pooled variant until exit. AI-assisted: yes (Claude Code)
blawesom commented 2026-10-16 17:58:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T17:58:23Z.


Rebase handoff + independent confirmation of the abort — rebased onto current main (both commits, authorship unchanged). The conflicts: Pipeline::Continue keeps main's optimized->Schedule() atop this PR's apply restructure, and the disk-cache static_assert is pinned to the merged tree's actual RecompileResult size (488 — main restructured it since your base).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • agc_driver_draw_cache_relocation aborts with corrupted double-linked list — 1/1 on my runs, matching your root-cause analysis from this morning (the entryPool/variantPool static-destruction order). Same device class as your repro (RX 9070 XT / RADV), so this is a second confirmation on the same head 12a5f02d1 (pre-rebase) rather than new information — the rebase does not change it.
  • one more observation: agc_driver_same_queue_label_wait failed once in parallel runs and passed solo — the second draw-state-filtering PR where I have seen that test flake (also on #6523); if your destruction-order fix lands, that pair may be worth a look too.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/6539
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 51c11a856 (amended to fold in the Continue/Schedule repair).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221570944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6221570944). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-16T17:58:23Z. --- **Rebase handoff + independent confirmation of the abort** — rebased onto current `main` (both commits, authorship unchanged). The conflicts: `Pipeline::Continue` keeps `main`'s `optimized->Schedule()` atop this PR's `apply` restructure, and the disk-cache `static_assert` is pinned to the merged tree's actual `RecompileResult` size (**488** — `main` restructured it since your base). Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **`agc_driver_draw_cache_relocation` aborts with `corrupted double-linked list` — 1/1 on my runs**, matching your root-cause analysis from this morning (the `entryPool`/`variantPool` static-destruction order). Same device class as your repro (RX 9070 XT / RADV), so this is a second confirmation on the same head `12a5f02d1` (pre-rebase) rather than new information — the rebase does not change it. - one more observation: `agc_driver_same_queue_label_wait` failed once in parallel runs and passed solo — the second draw-state-filtering PR where I have seen that test flake (also on #6523); if your destruction-order fix lands, that pair may be worth a look too. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/6539 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `51c11a856` (amended to fold in the Continue/Schedule repair).
blawesom commented 2026-10-16 18:07:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T18:07:01Z.


Correction on the agc_driver_same_queue_label_wait remark above: root-caused to my machine, not this PR — the card heat-soaked after a long verification day (junction ~95°C) and that timing-sensitive test's measurement flips when hot; it passes again after four minutes idle on the same build. Not a signal about this PR or your destruction-order fix. Please disregard.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221737216 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6221737216). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-16T18:07:01Z. --- **Correction on the `agc_driver_same_queue_label_wait` remark above:** root-caused to my machine, not this PR — the card heat-soaked after a long verification day (junction ~95°C) and that timing-sensitive test's measurement flips when hot; it passes again after four minutes idle on the same build. Not a signal about this PR or your destruction-order fix. Please disregard.
Scramblrrrr commented 2026-10-19 03:35:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-19T03:35:03Z.


Reviewing this for a possible 007 Windows cross-test after our current loading probe. Public baseline63ec3b290 is mainca13a56a5 plus the title's carried fixes and #6616; 150 selected native checks pass, one Linux-only import case skips. Menu remains1.911FPS, GPU180.25ms/present, so there is still substantial CPU preparation cost. Recent menu report: 9.4k draw packets/10s, 14.9k captures, per-packet capture150us, recompile/materialization246us, key/lookup/validation95us, graphics-lock wait192us. These are inclusive phase labels, not proof your optimization applies. Draw-cache hits remain low; no benefit claimed from this PR yet.

GitHub reports current heads #6539=12a5f02d and #5609=09238da8 conflict with main. Do you have a newer current-main rebase/WIP to use before I duplicate that integration work? I can review/adapt meanwhile; no title data needed.

Overlap to preserve: our #7508 at858c36315 replaces the per-word tagging scan in tagVariantRuns with ForEachRelocationRun; it retains #6454's AppendSharedWords first inside each emitted partition callback. SleglJan already cross-tested that combination on Linux and noted your adjacent edit. Public integration has that same partitioning. Any combination needs both provenance/shared-word handling and the forwarded-value patches, with the existing changed-green readback control kept. I will report exact heads and native/title evidence for an actual test. AI-assisted: Codex; raw title data remains local.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6259080626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6259080626). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-19T03:35:03Z. --- Reviewing this for a possible 007 Windows cross-test after our current loading probe. Public baseline63ec3b290 is mainca13a56a5 plus the title's carried fixes and #6616; 150 selected native checks pass, one Linux-only import case skips. Menu remains1.911FPS, GPU180.25ms/present, so there is still substantial CPU preparation cost. Recent menu report: ~9.4k draw packets/10s, ~14.9k captures, per-packet capture~150us, recompile/materialization~246us, key/lookup/validation~95us, graphics-lock wait~192us. These are inclusive phase labels, not proof your optimization applies. Draw-cache hits remain low; no benefit claimed from this PR yet. GitHub reports current heads #6539=12a5f02d and #5609=09238da8 conflict with main. Do you have a newer current-main rebase/WIP to use before I duplicate that integration work? I can review/adapt meanwhile; no title data needed. Overlap to preserve: our #7508 at858c36315 replaces the per-word tagging scan in tagVariantRuns with ForEachRelocationRun; it retains #6454's AppendSharedWords first inside each emitted partition callback. SleglJan already cross-tested that combination on Linux and noted your adjacent edit. Public integration has that same partitioning. Any combination needs both provenance/shared-word handling and the forwarded-value patches, with the existing changed-green readback control kept. I will report exact heads and native/title evidence for an actual test. AI-assisted: Codex; raw title data remains local.
oneandonlydean commented 2026-10-20 12:51:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T12:51:10Z.


Thanks for this. Two things before it can be reviewed:

  1. agc_driver_draw_cache_relocation aborts with corrupted double-linked list on this head, the static-destruction order of entryPool/variantPool described in the thread. Could you push that fix?
  2. The branch is far behind main and conflicts in DrawRelocate.cpp, Pipeline.cpp, DrawCacheRelocation.cpp, SrtDescriptorEvaluation.cpp, SrtEvaluator.cpp and ShaderDiskCache.cpp. Relocation has changed on main since your base (stage-data patches for relocated hits, the mesh index descriptor on relocated stages, shared words recorded by run). Please rebase onto current main and say whether the value-only user-word rule still holds on top of those changes.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6291256121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6291256121). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T12:51:10Z. --- Thanks for this. Two things before it can be reviewed: 1. `agc_driver_draw_cache_relocation` aborts with `corrupted double-linked list` on this head, the static-destruction order of `entryPool`/`variantPool` described in the thread. Could you push that fix? 2. The branch is far behind `main` and conflicts in `DrawRelocate.cpp`, `Pipeline.cpp`, `DrawCacheRelocation.cpp`, `SrtDescriptorEvaluation.cpp`, `SrtEvaluator.cpp` and `ShaderDiskCache.cpp`. Relocation has changed on `main` since your base (stage-data patches for relocated hits, the mesh index descriptor on relocated stages, shared words recorded by run). Please rebase onto current `main` and say whether the value-only user-word rule still holds on top of those changes.
JJenkx commented 2026-10-20 16:27:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T16:27:23Z.


Additional local integration evidence for the pool-lifetime and current SRT metadata concerns above (AI-assisted: yes).

I combined PR head 12a5f02d10fd8bfeedf101df27cb079a3b01f5b1 with main 7526640c3c1c5ea236c33b43b854681e8d169745 and the carried HTILE integration; local integration commit 1a1f519ebfe9dce77b3f3aaf1be96f205d46d162. This is not a current-main-only comparison or a performance result.

  • An alternative to immortal pools is to give RelocationPool<T> shared ownership and capture that owning pointer in each returned object's deleter: [pool = this->shared_from_this()](T* released) { pool->Return(released); }, with each pool accessor holding a static std::shared_ptr<RelocationPool<T>>. This keeps a pool alive until its outstanding objects are returned during shutdown.
  • Address-relocated variants need their copied shared validation metadata cleared before rebuilding address-bound runs in this integration.
  • The SRT tape needs the same provenance accounting as the basic evaluator: preserve forwarded/nested operand reads, record readInstructions and descriptor sourceLeads, and roll back those additions when a tape walk refuses. Before that adaptation, agc_driver_draw_cache_moved_buffer failed on the tape path while the APS5_NO_SRT_TAPE control passed.

After these adaptations, seven focused tests passed five repetitions each (35 executions): shader disk cache, moved buffer, relocation, and draw-cache reuse/default-off/verify/inline. Linux/RADV, MALLOC_PERTURB_=165, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; no VUID errors, skips, or missing-layer warnings in that log.

Hades II native controls also completed, but do not establish a forwarding performance benefit or regression. An initial cold-cache run had black timed captures during a long frame stall; a later ordinary-settings repeat rendered the hub. The cache conditions differed, so the initial black captures should not be attributed to forwarding from these runs. This does not settle the general value-only rule or replace the requested current-main rebase/review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6295787502 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6295787502). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-20T16:27:23Z. --- Additional local integration evidence for the pool-lifetime and current SRT metadata concerns above (AI-assisted: yes). I combined PR head `12a5f02d10fd8bfeedf101df27cb079a3b01f5b1` with main `7526640c3c1c5ea236c33b43b854681e8d169745` and the carried HTILE integration; local integration commit `1a1f519ebfe9dce77b3f3aaf1be96f205d46d162`. This is not a current-main-only comparison or a performance result. - An alternative to immortal pools is to give `RelocationPool<T>` shared ownership and capture that owning pointer in each returned object's deleter: `[pool = this->shared_from_this()](T* released) { pool->Return(released); }`, with each pool accessor holding a static `std::shared_ptr<RelocationPool<T>>`. This keeps a pool alive until its outstanding objects are returned during shutdown. - Address-relocated variants need their copied `shared` validation metadata cleared before rebuilding address-bound runs in this integration. - The SRT tape needs the same provenance accounting as the basic evaluator: preserve forwarded/nested operand reads, record `readInstructions` and descriptor `sourceLeads`, and roll back those additions when a tape walk refuses. Before that adaptation, `agc_driver_draw_cache_moved_buffer` failed on the tape path while the `APS5_NO_SRT_TAPE` control passed. After these adaptations, seven focused tests passed five repetitions each (35 executions): shader disk cache, moved buffer, relocation, and draw-cache reuse/default-off/verify/inline. Linux/RADV, `MALLOC_PERTURB_=165`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`; no VUID errors, skips, or missing-layer warnings in that log. Hades II native controls also completed, but do not establish a forwarding performance benefit or regression. An initial cold-cache run had black timed captures during a long frame stall; a later ordinary-settings repeat rendered the hub. The cache conditions differed, so the initial black captures should not be attributed to forwarding from these runs. This does not settle the general value-only rule or replace the requested current-main rebase/review.
JJenkx commented 2026-10-20 19:51:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T19:51:24Z.


The repair source is now available on JJenkx/AnyPS5, fix/descriptor-relocation-integration, rebased onto main 2185dbf92e8d9013a1620d2dfc95de50494e19f8. Prerequisite commits from #5609 and #6539 retain their original authorship. This is a tested integration branch for review/cherry-picking, not a replacement PR or a performance claim.

The relevant repairs are:

  • 586c05cf71: retain the relocation pools in outstanding objects' deleters so cached-object cleanup cannot return an object to an already destroyed pool. Before the repair, the relocation test aborted during shutdown; after it, the test exits normally.
  • 572fe318ce: record tape readInstructions, operandReads and descriptor sourceLeads, preserve operand nesting, and roll the metadata back on tape refusal. The differential tape/interpreter regression fails without this repair (read provenance has a different size from the reads) and passes with it.
  • 4184001cff: patch moved descriptor bases when a data-only hit validates as EqualData, with moved-buffer and changed-length regression coverage. This builds on the preceding data-only integration commits in the branch; it is not a standalone patch against main.

Matched focused validation on Arch Linux / AMD Radeon RX 6650 XT / RADV 26.2.4:

  • Main 2185dbf92e: 5/5 matching tests pass.
  • Integration 572fe318ce: those five plus the dependency's new moved-buffer test pass (6/6).
  • Both logs have zero VUID- messages, missing validation-layer warnings, or skipped tests.

Both runs used:

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 \
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
ctest --test-dir build-full -R '^(agc_shader_memory|agc_driver_draw_(data_hit_user_words(_verify)?|cache_relocation|cache_moved_buffer)|agc_shader_disk_cache)$' -V

The moved-buffer test is absent on main; the other five test names match. Conventions checks pass. These results establish focused correctness coverage, not a title FPS improvement. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300033897 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6300033897). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-20T19:51:24Z. --- The repair source is now available on [JJenkx/AnyPS5, `fix/descriptor-relocation-integration`](https://github.com/JJenkx/AnyPS5/tree/fix/descriptor-relocation-integration), rebased onto main `2185dbf92e8d9013a1620d2dfc95de50494e19f8`. Prerequisite commits from #5609 and #6539 retain their original authorship. This is a tested integration branch for review/cherry-picking, not a replacement PR or a performance claim. The relevant repairs are: - [586c05cf71](https://github.com/JJenkx/AnyPS5/commit/586c05cf71): retain the relocation pools in outstanding objects' deleters so cached-object cleanup cannot return an object to an already destroyed pool. Before the repair, the relocation test aborted during shutdown; after it, the test exits normally. - [572fe318ce](https://github.com/JJenkx/AnyPS5/commit/572fe318ce): record tape `readInstructions`, `operandReads` and descriptor `sourceLeads`, preserve operand nesting, and roll the metadata back on tape refusal. The differential tape/interpreter regression fails without this repair (`read provenance has a different size from the reads`) and passes with it. - [4184001cff](https://github.com/JJenkx/AnyPS5/commit/4184001cff): patch moved descriptor bases when a data-only hit validates as `EqualData`, with moved-buffer and changed-length regression coverage. This builds on the preceding data-only integration commits in the branch; it is not a standalone patch against main. Matched focused validation on Arch Linux / AMD Radeon RX 6650 XT / RADV 26.2.4: - Main `2185dbf92e`: 5/5 matching tests pass. - Integration `572fe318ce`: those five plus the dependency's new moved-buffer test pass (6/6). - Both logs have zero `VUID-` messages, missing validation-layer warnings, or skipped tests. Both runs used: ```sh ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 \ VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \ ctest --test-dir build-full -R '^(agc_shader_memory|agc_driver_draw_(data_hit_user_words(_verify)?|cache_relocation|cache_moved_buffer)|agc_shader_disk_cache)$' -V ``` The moved-buffer test is absent on main; the other five test names match. Conventions checks pass. These results establish focused correctness coverage, not a title FPS improvement. AI-assisted: yes.
JJenkx commented 2026-10-20 20:34:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T20:34:05Z.


A matched Hades II measurement is now available for the integration branch above (AI-assisted: yes). This pair does not show a speedup.

Baseline 17558c1cd1bb8b8cb6c0e44c4a7ea7af774016f5 is main 9a97ac784da5d40cc7b7d968898ffbf5b8b5377a plus the refreshed #6300 depth dependency. Candidate 64ba4ebacf38fead38f699555b2418e1c24463a6 adds the combined descriptor relocation stack and its integration repairs. This is a dependency-baseline comparison, not a main-only result or an isolated measurement of #6539.

Both legs used identical starting save hashes, the same inputs and rendered Underworld room, separate initially empty shader/Mesa caches, the same hardware and trace settings (APS5_TRACE_SECONDS=160:15, APS5_TRACE_EVENTS=1048576). Both compiled 199 shaders from cold caches, exited normally, restored the kernel setting, and produced complete traces (trace_dropped=false). Both traces were processed with tools/trace_digest.py.

Metric Baseline Combined candidate
Frame p50 (ms) 21.811 23.136
Frame p90 (ms) 27.745 28.453
Frame p99 (ms) 34.273 34.594
Presents / trace duration 656 / 15.023s 632 / 15.010s
GPU busy ms/present 10.892 10.254

The official summary reports Driver.Draw.shader_compile_and_link at 9.366 versus 10.717 ms/frame and Shader.DrawStage at 6.105 versus 6.835 ms/frame. These are inclusive scopes; they do not mean actual shader compilation continued during the window. The candidate p50 was 6.1% higher in this single pair; that is insufficient to establish regression significance, but does not support a performance claim for this scene.

The complete official summary lines, full source pins and comparison conditions are in comparison.json. Full traces are retained locally. Next I will investigate preparation/lookup costs before proposing any speed claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300875349 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6300875349). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-20T20:34:05Z. --- A matched Hades II measurement is now available for the integration branch above (AI-assisted: yes). This pair does **not** show a speedup. Baseline `17558c1cd1bb8b8cb6c0e44c4a7ea7af774016f5` is main `9a97ac784da5d40cc7b7d968898ffbf5b8b5377a` plus the refreshed #6300 depth dependency. Candidate `64ba4ebacf38fead38f699555b2418e1c24463a6` adds the combined descriptor relocation stack and its integration repairs. This is a dependency-baseline comparison, not a main-only result or an isolated measurement of #6539. Both legs used identical starting save hashes, the same inputs and rendered Underworld room, separate initially empty shader/Mesa caches, the same hardware and trace settings (`APS5_TRACE_SECONDS=160:15`, `APS5_TRACE_EVENTS=1048576`). Both compiled 199 shaders from cold caches, exited normally, restored the kernel setting, and produced complete traces (`trace_dropped=false`). Both traces were processed with `tools/trace_digest.py`. | Metric | Baseline | Combined candidate | |---|---:|---:| | Frame p50 (ms) | 21.811 | 23.136 | | Frame p90 (ms) | 27.745 | 28.453 | | Frame p99 (ms) | 34.273 | 34.594 | | Presents / trace duration | 656 / 15.023s | 632 / 15.010s | | GPU busy ms/present | 10.892 | 10.254 | The official summary reports `Driver.Draw.shader_compile_and_link` at 9.366 versus 10.717 ms/frame and `Shader.DrawStage` at 6.105 versus 6.835 ms/frame. These are inclusive scopes; they do not mean actual shader compilation continued during the window. The candidate p50 was 6.1% higher in this single pair; that is insufficient to establish regression significance, but does not support a performance claim for this scene. The complete official summary lines, full source pins and comparison conditions are in [comparison.json](https://gist.github.com/JJenkx/92230908979fbe9ef0ed1fbb8eb5bc8c). Full traces are retained locally. Next I will investigate preparation/lookup costs before proposing any speed claim.
JJenkx commented 2026-10-20 21:25:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T21:25:31Z.


A bounded-cache correctness follow-up is available in 198bca0fd0 on the existing integration branch. AI-assisted: yes. This depends on the relocation stack; it is not an isolated patch against main or a performance claim.

learnPendingRelocation() previously pruned both alias maps whenever their size reached 16,384, including when learning only refreshed an existing key. Stage donors were also checked once before inserting multiple stages, allowing the map to exceed its bound within that loop. The helper now checks each insertion and prunes only for a new key at capacity; existing donors still receive refreshed payloads.

The regression exercises both stage and decode donor maps: updates at capacity preserve every other key and replace payloads; repeated new insertions retain the newest entry, stay within the bound, and account for evictions. The unconditional-pruning negative control fails with updating an existing alias evicted unrelated donors at capacity; the fixed implementation passes.

Full Linux libs build and five focused checks pass on AMD Radeon RX 6650 XT / RADV: shader memory, moved buffer, relocation, data-hit user words and its verification variant. Vulkan required, shader caches disabled, Khronos validation enabled; zero VUIDs, skips or missing-layer warnings. Conventions pass with the existing debt-length warning. These checks validate this integration, not a fresh main-versus-candidate comparison.

Hades II PPSA36082 also reached the expected Underworld room, then closed normally after 188 seconds; PID gone and kernel setting restored. Warm shader cache: 199 hits, zero misses. The sparse screenshot shows no obvious new corruption. Instrumented timings vary, so no title speedup is claimed. Native core validation was not requested; the validation result above applies to the focused tests.

Logs, source patch and compact validation evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301825408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6301825408). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-20T21:25:31Z. --- A bounded-cache correctness follow-up is available in [198bca0fd0](https://github.com/JJenkx/AnyPS5/commit/198bca0fd0640d3d2512edfff7edabb370f00f9d) on the existing integration branch. AI-assisted: yes. This depends on the relocation stack; it is not an isolated patch against main or a performance claim. `learnPendingRelocation()` previously pruned both alias maps whenever their size reached 16,384, including when learning only refreshed an existing key. Stage donors were also checked once before inserting multiple stages, allowing the map to exceed its bound within that loop. The helper now checks each insertion and prunes only for a new key at capacity; existing donors still receive refreshed payloads. The regression exercises both stage and decode donor maps: updates at capacity preserve every other key and replace payloads; repeated new insertions retain the newest entry, stay within the bound, and account for evictions. The unconditional-pruning negative control fails with `updating an existing alias evicted unrelated donors at capacity`; the fixed implementation passes. Full Linux `libs` build and five focused checks pass on AMD Radeon RX 6650 XT / RADV: shader memory, moved buffer, relocation, data-hit user words and its verification variant. Vulkan required, shader caches disabled, Khronos validation enabled; zero VUIDs, skips or missing-layer warnings. Conventions pass with the existing debt-length warning. These checks validate this integration, not a fresh main-versus-candidate comparison. Hades II PPSA36082 also reached the expected Underworld room, then closed normally after 188 seconds; PID gone and kernel setting restored. Warm shader cache: 199 hits, zero misses. The sparse screenshot shows no obvious new corruption. Instrumented timings vary, so no title speedup is claimed. Native core validation was not requested; the validation result above applies to the focused tests. [Logs, source patch and compact validation evidence](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/20261020-donor-bound-validation.tar.gz).
JJenkx commented 2026-10-21 10:06:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T10:06:20Z.


Matched measurement of the integration branch on another title and platform, where the miss pattern is exactly what this stack targets. It shows no gain; the candidate is slower here. AI-assisted: yes.

Setup

  • Machine: Windows 11 22621, RX 6700 XT, AMD driver 26.10.1, Ryzen 9 5950X.
  • Scene: Spirit of the Island (PPSA13934) title screen, no input, 150 s runs, APS5_TRACE_SUMMARY_EVERY=10, steady-state intervals from 60 s on.
  • Baseline: main 71401e331, plus the test-only #8310 so the tree builds on Windows.
  • Candidate: the same main merged with fix/descriptor-relocation-integration at 572fe318c. A local, unpublished merge: the only conflict was ShaderDiskCache::FormatVersion (43 vs 42), set to 44.

This scene issues ~1,650 draws per frame. With APS5_TRACE_DRAW_CACHE, main hits only 0.5–0.8 % of ~410k lookups per 10 s; almost every miss is user words/pointers only and becomes a data-only hit that still compiles ~1.5 stages per draw.

p50 frame (median of intervals) presents / 10 s GPU busy / present Driver.Packet / frame draw-cache hits
main 71401e331 104.8 ms 96 54.6 ms 96.9 ms 0.5–0.8 %
candidate 114.0 ms 88 51.1 ms 102.2 ms 1.4–1.5 %

Candidate data-only hits per 10 s: 219k stages reused, 530k compiled, against 208k/611k on main.

So the relocation path converts a few more lookups, but on this title the per-draw cost it adds outweighs that. That matches the earlier per-draw content hashing concern. The queue worker stays ~90 % busy in both builds, and the frame is worker-bound.

Summaries are in my local evidence; I can share the aps5-summary.jsonl pair if useful.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313360705 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6539#issuecomment-6313360705). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T10:06:20Z. --- Matched measurement of the integration branch on another title and platform, where the miss pattern is exactly what this stack targets. It shows **no gain; the candidate is slower here**. AI-assisted: yes. **Setup** - **Machine:** Windows 11 22621, RX 6700 XT, AMD driver 26.10.1, Ryzen 9 5950X. - **Scene:** Spirit of the Island (PPSA13934) title screen, no input, 150 s runs, `APS5_TRACE_SUMMARY_EVERY=10`, steady-state intervals from 60 s on. - **Baseline:** main `71401e331`, plus the test-only #8310 so the tree builds on Windows. - **Candidate:** the same main merged with `fix/descriptor-relocation-integration` at `572fe318c`. A local, unpublished merge: the only conflict was `ShaderDiskCache::FormatVersion` (43 vs 42), set to 44. This scene issues ~1,650 draws per frame. With `APS5_TRACE_DRAW_CACHE`, main hits only 0.5–0.8 % of ~410k lookups per 10 s; almost every miss is `user words/pointers only` and becomes a data-only hit that still compiles ~1.5 stages per draw. | | p50 frame (median of intervals) | presents / 10 s | GPU busy / present | `Driver.Packet` / frame | draw-cache hits | |---|---|---|---|---|---| | main 71401e331 | 104.8 ms | 96 | 54.6 ms | 96.9 ms | 0.5–0.8 % | | candidate | 114.0 ms | 88 | 51.1 ms | 102.2 ms | 1.4–1.5 % | Candidate data-only hits per 10 s: 219k stages reused, 530k compiled, against 208k/611k on main. So the relocation path converts a few more lookups, but on this title the per-draw cost it adds outweighs that. That matches the earlier per-draw content hashing concern. The queue worker stays ~90 % busy in both builds, and the frame is worker-bound. Summaries are in my local evidence; I can share the `aps5-summary.jsonl` pair if useful.

Pull request closed

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!6539
No description provided.