Repository navigation
perf(shader): allocate the evaluator's work sets from a per-call arena - #11755
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request is labeled |
|
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.
|
|
Title captures for this change, with the same setup as the captures on #12039. The base is Setup: Super Meat Boy 3D (PPSA31162 02.000.001), release libs, 100 s at a 12 GB cap with the same input script, recompiler cache off (
That mean isn't a comparison of the same work. In rounds 2 and 3 the Boot prepares shaders in nearly the same order every run, so the same work can be compared by taking each run's first 400 worker artifacts and first 350 title-thread artifacts by start time (total ms):
Over the same work, the worker time is 3.3 % higher with this PR, lower in only 1 of 3 rounds, and the title-thread time is 3.8 % lower in 3 of 3. That is no clear change in the title. The replay task-clock measurement in the description remains the evidence for the change. The summary lines of round 2: All six traces, summary lines and AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validation IDs already present on main (4 IDs in 391 tests)Skipped (41)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. |
What
Stacked on #11719: this branch contains its commit, and this PR adds only the second one (
perf(shader): allocate the evaluator's work sets from a per-call arena).After #11719, most of the remaining allocator time in
BasicEvaluator::MayEvaluate(SrtEvaluator.cpp) comes from its per-call work sets. Those are theknownmap, theexpandingset, thependingstack and the requirement list, and each node of anunordered_map/unordered_setis a separatemalloc. This gives the four containers astd::pmr::monotonic_buffer_resourceperMayEvaluatecall, backed by a 2 KiB stack buffer, and switches them to theirstd::pmrforms. Allocations become pointer bumps, and everything is released at once when the call returns. A call that outgrows the buffer gets more memory from the default resource for the rest of that call. The containers, their contents and the evaluation order are unchanged.How
std::array<std::byte, 2048> scratchandstd::pmr::monotonic_buffer_resource arena(scratch.data(), scratch.size())at the top of the four-argumentMayEvaluate.known,expanding,pendingandrequiredbecomestd::pmr::unordered_map,std::pmr::unordered_setandstd::pmr::vectoron&arena, andpending's initial element is now anemplace_back. Includes<array>,<cstddef>and<memory_resource>. The nestedMayEvaluatecall forReadFirstLanegets its own arena on its own stack frame.Changed:
core/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cpp.Tested
Linux, i7-13700K, GCC 15.2, Release with
ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Binaries built withcmake --build build-rel --target agc_shader_replayatmaind093ea9, at #11719'sbf97894bc8, and at this change. The timing runs usedf7d299f9b7, which differs from this head only in include order.ANYPS5_NO_SHADER_CACHE=1 agc_shader_replay --spvover the same 152 Crimson Desert (PPSA25286) and 305 MXGP 26 (PPSA30839) requests as perf(shader): reuse the evaluator's requirement list across values #11719 (hashes in #11719). Each binary ran in an empty directory per set, and thesha256sum * | sort -k2lists were diffed. All 65 and 302 SPIR-V outputs are byte-identical tomain's.ANYPS5_NO_SHADER_CACHE=1 perf stat -x, -e task-clock -o stat.txt agc_shader_replay --prepare <the 152 requests>, each run in a fresh empty directory, three binaries per round in the order shown:main(ms)Over the 18 rounds the means are
main15.70 s, #11719 15.46 s and this PR 15.02 s (medians 15.69, 15.41 and 14.87 s). This PR is 2.9 % below #11719, lower in 16 of 18 rounds, and 4.35 % belowmain, lower in 17 of 18. Its spread is wider (SD 0.32 s against 0.16 and 0.23): rounds 2 and 3 were slower than #11719, and I haven't found why.cfced2eda0) and 3 of 3 at its based093ea9ced.This is a CPU-only shader-compilation change with byte-identical SPIR-V, like #11719, #9132 and #9198, so it uses the paired CPU replay that oneandonlydean accepted for those (#11719) instead of title captures.
Title captures: Super Meat Boy 3D,
main9af563f33d+ #11580 (608dd76843) against the same + this PR (9949c924e6), 3 interleaved rounds, recompiler cache off.Shader.PrepareArtifactworker time over each run's first 400 worker artifacts is 8,953 ms → 9,248 ms (+3.3 %, lower in 1 of 3) and title-thread time over the first 350 is 6,229 ms → 5,993 ms (-3.8 %, 3 of 3), so no clear change in the title (the full-window means aren't comparable:mainreached a later scene in rounds 2 and 3) (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