perf(agc): vertex-stage fetch resources leave same-shape draws unrelocatable (PPSA03524: 96% of blocking user words unmarked) #26595

Open
opened 2026-11-24 08:54:36 +00:00 by akkadbakkad89 · 0 comments
akkadbakkad89 commented 2026-11-24 08:54:36 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-24T08:54:36Z.


Summary

On titles that rotate per-draw resource pointers through a descriptor ring (UE4 pattern), the draw data-hit path already reuses the decode for 99.7% of lookups — but the stage variants still re-materialize, because vertex stages carrying fetch resources are categorically ineligible for relocation tagging. The result on GTA: San Andreas (PPSA03524): ~28% of stage slots reuse a donor variant, every draw key is unique, record.Matches can never hit, and every draw pays the full ~53 µs localDevice->Draw() recording path on the committer (~7.1 s of 10 s).

The eligibility gate is in Execution/src/Driver/Draw/DrawCapture.cpp:

const bool relocatable = decodeReads[i].empty() && (!vertexInfos[i] || vertexInfos[i]->resourcesNum == 0);

resourcesNum != 0 (or any decode-time read) skips tagVariantRuns/tagUserValueWords entirely, so the vertex stage's asBase user words are never marked. #13610 added relocation for moved V#s and fetch subroutines in user words, but this gate sits in front of that marking — a stage with vertex fetch resources never reaches it.

Measured (PPSA03524, RTX 3070, Windows 11, main dba06f681a, in-world)

  • ~133k draw packets / 10 s, ~2,800 draws/present, ~5.4 FPS
  • [draw-cache]: 133,689 lookups → 154 full hits (0.1%), 133,535 data-only hits; user words/pointers only for essentially every miss
  • Stage slots under data hits: 73,712 reused / 193,348 compiled (~28%)
  • [draw-relocate]: 100,351 alias lookups → 154 donors, 0 refusals
  • Instrumented the data-hit candidate gate: the blocking words are ~16 user-word pairs (even/odd pointer-pair pattern), classified 96% unmarked / 3% relocatable / 1% value / 0 callee — the vertex stage's per-draw resource pointers, exactly the words the gate excludes
  • stage-data-hits: 0 (dataPositions empty — no FlattenedSrt bindings in this title)

Full datapoint with phase breakdown: https://github.com/boykopovar/AnyPS5/issues/17533#issuecomment-7125377282

Proposed path

  1. Allow tagVariantRuns/tagUserValueWords on vertex stages and extend the relocated/patched variant construction to re-materialize vertexInfo fetch-resource descriptors from current user words (it is shared_ptr<const> baked state — a relocated variant needs a freshly built one).
  2. Let the data-hit candidate path accept a donor variant whose used diffs are confined to relocatable words, producing the patched copy the way relocateDrawEntry already does per-variant — validation, pending-write and gate checks unchanged as the safety net.
  3. If canonical variants hold: stage reuse rises toward ~90%+, recompile ~9 µs/draw drops, Matches unblocks recipe replay on data hits, and the ~53 µs commit path shrinks accordingly.

Validation would follow #13610's precedent: agc_driver_draw_relocate_* tests extended to a vertex-fetch-resource case, APS5_VERIFY_DRAW_DATA_HITS=1 runs, and before/after aps5-summary.jsonl + trace_digest on the same scene.

Caveats

  • The gate presumably exists because vertexInfo is decode-baked state — re-materializing it on a patched variant needs care around fetch-resource rebinding (the same question MovedDispatchBuffers/PrepareDrawBindings answers on the dispatch side, so there may be an established pattern).
  • Even with canonical variants, both draw threads sit ~60% wall-clock idle in this title — pipeline dependencies cap the achievable gain short of the theoretical bound.
  • #13610: relocation for moved V#s and fetch subroutines in user words (merged) — this issue is about the eligibility gate in front of it
  • #17533: the umbrella per-draw-cost discussion (datapoint posted there)
  • #24661: the same relocation model on the dispatch cache (open)
  • #7895: the queue-0 committer bound, which this work would partially relieve

AI-assisted: yes. Measurements and instrumentation are from this machine (RTX 3070 / Windows 11).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6578123888 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/26595). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-11-24T08:54:36Z. --- ## Summary On titles that rotate per-draw resource pointers through a descriptor ring (UE4 pattern), the draw data-hit path already reuses the decode for 99.7% of lookups — but the stage variants still re-materialize, because vertex stages carrying fetch resources are categorically ineligible for relocation tagging. The result on GTA: San Andreas (PPSA03524): ~28% of stage slots reuse a donor variant, every draw key is unique, `record.Matches` can never hit, and every draw pays the full ~53 µs `localDevice->Draw()` recording path on the committer (~7.1 s of 10 s). The eligibility gate is in `Execution/src/Driver/Draw/DrawCapture.cpp`: ```cpp const bool relocatable = decodeReads[i].empty() && (!vertexInfos[i] || vertexInfos[i]->resourcesNum == 0); ``` `resourcesNum != 0` (or any decode-time read) skips `tagVariantRuns`/`tagUserValueWords` entirely, so the vertex stage's `asBase` user words are never marked. #13610 added relocation for moved V#s and fetch subroutines in user words, but this gate sits in front of that marking — a stage with vertex fetch resources never reaches it. ## Measured (PPSA03524, RTX 3070, Windows 11, `main` `dba06f681a`, in-world) - ~133k draw packets / 10 s, ~2,800 draws/present, ~5.4 FPS - `[draw-cache]`: 133,689 lookups → 154 full hits (0.1%), 133,535 data-only hits; `user words/pointers only` for essentially every miss - Stage slots under data hits: 73,712 reused / 193,348 compiled (~28%) - `[draw-relocate]`: 100,351 alias lookups → 154 donors, 0 refusals - Instrumented the data-hit candidate gate: the blocking words are ~16 user-word pairs (even/odd pointer-pair pattern), classified **96% unmarked / 3% relocatable / 1% value / 0 callee** — the vertex stage's per-draw resource pointers, exactly the words the gate excludes - stage-data-hits: 0 (`dataPositions` empty — no FlattenedSrt bindings in this title) Full datapoint with phase breakdown: https://github.com/boykopovar/AnyPS5/issues/17533#issuecomment-7125377282 ## Proposed path 1. Allow `tagVariantRuns`/`tagUserValueWords` on vertex stages and extend the relocated/patched variant construction to re-materialize `vertexInfo` fetch-resource descriptors from current user words (it is `shared_ptr<const>` baked state — a relocated variant needs a freshly built one). 2. Let the data-hit candidate path accept a donor variant whose used diffs are confined to relocatable words, producing the patched copy the way `relocateDrawEntry` already does per-variant — validation, pending-write and gate checks unchanged as the safety net. 3. If canonical variants hold: stage reuse rises toward ~90%+, `recompile ~9 µs/draw` drops, `Matches` unblocks recipe replay on data hits, and the ~53 µs commit path shrinks accordingly. Validation would follow #13610's precedent: `agc_driver_draw_relocate_*` tests extended to a vertex-fetch-resource case, `APS5_VERIFY_DRAW_DATA_HITS=1` runs, and before/after `aps5-summary.jsonl` + `trace_digest` on the same scene. ## Caveats - The gate presumably exists because `vertexInfo` is decode-baked state — re-materializing it on a patched variant needs care around fetch-resource rebinding (the same question `MovedDispatchBuffers`/`PrepareDrawBindings` answers on the dispatch side, so there may be an established pattern). - Even with canonical variants, both draw threads sit ~60% wall-clock idle in this title — pipeline dependencies cap the achievable gain short of the theoretical bound. ## Related - #13610: relocation for moved V#s and fetch subroutines in user words (merged) — this issue is about the eligibility gate in front of it - #17533: the umbrella per-draw-cost discussion (datapoint posted there) - #24661: the same relocation model on the dispatch cache (open) - #7895: the queue-0 committer bound, which this work would partially relieve AI-assisted: yes. Measurements and instrumentation are from this machine (RTX 3070 / Windows 11).
Sign in to join this conversation.
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#26595
No description provided.