perf(agc): memoize source failures of draw stages as for compute #422

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/422 into main 2026-10-04 05:49:25 +00:00
MichonGoddijn231849 commented 2026-10-02 23:26:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T23:26:53Z.


What

SourceHandleFor remembers a source that failed to resolve and answers later lookups with the stored failure, but only for compute stages. A draw stage that cannot be resolved was resolved again on every draw: GTA V draws whose descriptor came through a lane-dependent chain repeated the walk and threw each time.

  • Draw stages are poisoned like compute stages. Their memo key also mixes the role and code address of every linked program, because the request's context hash leaves those out.
  • compileDrawStage takes the memoized failure through the existing poisoned out-parameter. The draw is rejected with that message instead of an exception, as Dispatch already does.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • ctest: all tests pass.
  • GTA V (PPSA04264), Prologue, APS5_PROFILE_DRAW=1:
    • time spent on skipped draws dropped from 1187 ms to 50 ms per 10 s (9.8 to 0.4 µs per draw packet);
    • the same draws are still skipped, with the same messages.
    • Measured on my branch that combines this change with my other open PRs. Those draws render since #411.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. #291 (mine) memoizes failed draws in the draw cache, a different layer, but edits the same compileDrawStage call in Draw.cpp; whichever merges second keeps both changes
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4722522444 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/422). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T23:26:53Z. --- ### What `SourceHandleFor` remembers a source that failed to resolve and answers later lookups with the stored failure, but only for compute stages. A draw stage that cannot be resolved was resolved again on every draw: GTA V draws whose descriptor came through a lane-dependent chain repeated the walk and threw each time. - Draw stages are poisoned like compute stages. Their memo key also mixes the role and code address of every linked program, because the request's context hash leaves those out. - `compileDrawStage` takes the memoized failure through the existing `poisoned` out-parameter. The draw is rejected with that message instead of an exception, as `Dispatch` already does. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - `ctest`: all tests pass. - GTA V (PPSA04264), Prologue, `APS5_PROFILE_DRAW=1`: - time spent on skipped draws dropped from 1187 ms to 50 ms per 10 s (9.8 to 0.4 µs per draw packet); - the same draws are still skipped, with the same messages. - Measured on my branch that combines this change with my other open PRs. Those draws render since #411. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none. #291 (mine) memoizes failed draws in the draw cache, a different layer, but edits the same `compileDrawStage` call in `Draw.cpp`; whichever merges second keeps both changes - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-03 06:28:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-03T06:28:30Z.


+1. My integration branch has carried a version of this without the linked-program key. On PPSA21564's world map, unwinding these repeated throws took about 19% of the queue worker's time on Linux (the guest libc's unwinder calls dl_iterate_phdr for every frame), and memoizing the draw-stage failures removed it. I'll switch my branch to this version, since it also keys on the linked programs.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5966362279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/422#issuecomment-5966362279). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T06:28:30Z. --- +1. My integration branch has carried a version of this without the linked-program key. On PPSA21564's world map, unwinding these repeated throws took about 19% of the queue worker's time on Linux (the guest libc's unwinder calls dl_iterate_phdr for every frame), and memoizing the draw-stage failures removed it. I'll switch my branch to this version, since it also keys on the linked programs.
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!422
No description provided.