perf(shader): reuse the evaluator's requirement list across values #11719
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11719"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-27T05:28:30Z.
What
BasicEvaluator::MayEvaluate(SrtEvaluator.cpp) builds a newstd::vectorof required arguments for every value it visits, and visits each expanded value twice: once to push the arguments, once to check them. In a DWARF profile of Crimson Desert's shader preparation,MayEvaluateand everything below it is 7.9 % of samples, and about half of that ismalloc/free. This change keeps one requirement list perMayEvaluatecall and refills it for each value instead of returning a new vector, so the list's storage is allocated once per call.How
The
requirementslambda now clears and fills arequiredvector declared before the work loop, and returns nothing. Its two uses read that vector right after calling it. The nestedMayEvaluateforReadFirstLanehas its own list, so no list is shared across calls. The evaluation order and results are unchanged.Changed:
core/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cpp.Tested
All on Linux, i7-13700K, GCC 15.2, Release with SPIR-V Tools off,
maind093ea9cedand this commit.agc_shader_replay --spvover 152 Crimson Desert (PPSA25286) registration requests and MXGP 26's (PPSA30839) 305 dumped requests gives byte-identical SPIR-V for all 65 and 302 outputs.agc_shader_replay --prepareover the 152 Crimson Desert requests,perf stat -e task-clock, 8 rounds withmainand this change interleaved,ANYPS5_NO_SHADER_CACHE=1.maintook 15.59 s on average (SD 0.12) and this change 15.34 s (SD 0.12), 1.6 % less, lower in all 8 rounds.agc_driver_compute_table_calls,compute_fs_table_calls,compute_user_data_calls(_registered),image_table*,buffer_descriptor_runtime,descriptor_web_faults,fragment_user_data_tail,draw_shader_failure_materialization*) pass 3 of 3 on an RTX 4070 Ti (NVIDIA 615.71.09).bf97894bc8) and on its basemaind093ea9ced.#11506 (hugodearaujo) cuts how often
MayDecideis called, by deciding each branch condition once per plan. This PR makes each call cheaper, so the two add up. The two PRs don't touch the same lines.Title captures: Super Meat Boy 3D,
main9af563f33d+ #11580 (608dd76843) against the same + this PR (99e0ed0b22), 3 interleaved rounds, recompiler cache off.Shader.PrepareArtifactworker time is 12,443 ms → 12,250 ms (-1.6 %, lower in 2 of 3 rounds; within the run-to-run spread, and the title thread is +1.5 %) (table and traces). Round 2's summary lines: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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T05:35:50Z.
Review: CHANGES_REQUESTED
The evaluator change is a small reuse of the same per-call vector; after
requirements(current)fills it, the existing loop consumes it before the next call, so I found no changed traversal order in this diff. I also syntax-checked the exact changed translation unit with the configured GCC flags, andgit diff --checkpasses.I cannot approve this performance PR without the required runtime report. The current evidence is from
agc_shader_replay --prepare, not paired AnyPS5 captures for the same title, scene, and machine with bothaps5-summary.jsonllines, traces, andtools/trace_digest.pyoutput. The automated label check has already requested those artifacts. Please add the required report before approval; the reported shader-equivalence and focused test results are useful but do not replace it. I did not rerun those runtime/GPU tests locally, and product CI is skipped by path policy.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T06:42:51Z.
Review: APPROVED
The new evidence resolves my earlier concern about the performance report. This CPU-side shader-compilation change has paired replay timing and byte-identical SPIR-V, and I verified the closely analogous #9132 exception: collaborator oneandonlydean explicitly accepted CPU-only replay evidence for this kind of change and confirmed that acceptance stood. I therefore accept the replay measurements here without requiring a GPU capture. The automated
perf numbers missinglabel may remain until a maintainer clears it, as happened on #9132.The code change reuses a per-call requirements vector without changing traversal or evaluation order; my previous exact-head review and syntax check found no code issue. The author now reports the focused 16 AGC tests passing 3/3 on Windows as well as the reported Linux checks. I did not independently rerun the title/GPU tests or a full build; hosted product jobs are skipped by path policy. Approving based on the reviewed diff, paired CPU measurements, byte-identical shader output, and the accepted repository precedent.