Repository navigation
perf(shader): leave out the dead code pass after masked-select elimination - #7522
Conversation
…ation MaskedSelectEliminator::Eliminate runs dead code elimination after every round that removes a select, and returns after a round that removes nothing, which changes nothing. So the program it returns is already free of dead code, and the dead code pass the pipeline ran right after it, when no packed ancillary input is live, never removed anything. It now runs only after the ancillary refolding. agc_masked_select now checks, after each elimination that removed selects, that a further dead code pass removes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
|
First AMD-on-Linux (RADV) run of this PR. Merged onto AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite ( GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes |
|
@DavidAmsellem thank you, the gfx1100 full-suite run is in the description now. AI-assisted: yes (Claude Code) |
|
This pull request is labeled |
|
The title capture the AI-assisted: yes (Claude Code) |
|
Windows run of #7520 and #7522 together. Host: Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2 r7, Release. I stacked #7520 at
Not checked: a full build, the Written with Claude Code assistance (validation by a subagent, reviewed in this session). |
|
Thanks @screamm, the first Windows title runs of this one, and the identical cache entries and replay hashes are the right check for a bit-exact change. Added to the description. AI-assisted: yes (Claude Code) |
|
A data point from a second title, and it doesn't show a gain here. Crimson Desert (PPSA25286) replay: a fixed subset of 152 of its 6,065 registration requests,
The medians are within noise of each other; one run on each side was slowed by other load on the host. The prepared SPIR-V of the 152 requests is byte-identical to In this title's profile, the dead-code passes inside AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (4 IDs in 495 tests)Skipped (45)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. |
BunnyFl
left a comment
There was a problem hiding this comment.
Windows 11, AMD RX 9070 XT, WinLibs GCC 15.2.0, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, merged onto current main f6232fcfda (clean merge): agc_masked_select passes, including the new check in eliminate() that one more DeadCodeEliminator pass removes nothing after selects were removed. With main's core/shader/recompiler/Recompiler.cpp restored it passes too. That's expected: the test checks the property this PR relies on, inside MaskedSelectEliminator::Eliminate, not the removed call. The removed pass is still in PrepareResourceProgram on current main (the merge is clean). I didn't reproduce the timing; the summary lines and digests in the description are the performance evidence.
|
@BunnyFl thanks for the Windows and AMD run. Yes, the new check in AI-assisted: yes (Claude Code) |
|
Checked that |
What
PrepareResourceProgram's simplification step runsMaskedSelectEliminator::Eliminate. When it removed selects, the step then ranDeadCodeEliminator::Eliminateover the whole program, after refolding first if a packed ancillary input is live.MaskedSelectEliminator::Eliminatealready runs dead code elimination at the end of every round that removes a select. It returns only after a round that removes nothing, and such a round doesn't change the program. So the program it returns is already free of dead code. Without the ancillary refolding, the following pass had nothing to remove. It now runs only after that refolding, which can create dead code.To check this, I logged the instructions each
Eliminate(IrProgram&)call removed, by call site, over 466 dumped shader requests (below). This call ran 833 times, never with a live ancillary input, and removed nothing each time. Over the 355 PPSA30839 requests plus PPSA31162's 46, it took 115 ms in 712 calls.agc_masked_selectroutes its 39 cases through oneeliminate()helper. After an elimination that removed selects, that helper now runs one more dead code pass and fails if it removes anything. That is the property this PR relies on. With the dead code pass insideMaskedSelectEliminator::Eliminateremoved, 4 cases fail with "dead code is left after the selects were removed".HostInterpolationChecker::Lowerhas the same pattern on its own path. I left it as it is, since #6222 and #7332 add code right after that line.Tested
Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02.
ctest -R "^agc_|^shader_ir"on 3e3e8b9: 710/710 pass (3 skipped: host import sparse, sparse dma-buf import, stencil ref export). That run also had theHostInterpolationCheckerchange, which I then dropped. On the final code, the 6 tests matchingmasked_select|interpolat|barycentricpass.agc_shader_replay --spv(Release,ANYPS5_ENABLE_SPIRV_TOOLSoff,ANYPS5_NO_SHADER_CACHE=1) on 466 shader requests I had dumped withAPS5_DUMP_SHADERS: 355 from MXGP 26 (PPSA30839), 107 from PPSA31162 and 4 from another app. All 462.spvfiles (a few names repeat across the dumps) have the same SHA-256 onmain3e3e8b9 and with this PR, and the replay output is identical.main, 25,161 to 25,493 ms with this PR), so I'm only claiming the 115 ms of the removed pass.Title level: no speed claim.
tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pylists only conflicting PRs that it could not compare onRecompiler.cpp; none of their diffs touch these lines.main0fbfd91. It matchesmain, with the same two failures (agc_driver_image_table_vouched_lookups fails on RADV since the image-table reuse v3 merge (#6454, 23629c284) #7766, agc_driver_guest_memory_lifetime fails on RADV since the host-import cut larger-side keep (16473dbbe, #6499 family) #7784), and no test is added, skipped or removed. That's correctness only.Title capture
As the
perflabel asks, these are captures of one title and scene on one machine. MXGP26 (PPSA30839) ran from boot withAPS5_TRACE_SECONDS=0:60,ANYPS5_NO_SHADER_CACHE=1and a fresh run directory (cold AnyPS5 and NVIDIA caches), so the shaders compile inside the window. NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04, release libs, Xvfb display, no input.maindbac9fa was captured five times: before the PR captures, after them, and three more times in a row after that. Each PR capture and the first twomaincaptures followed a rebuild of the release libraries; the last threemaincaptures did not, and they came out lower. The change ismainwith this PR merged on top as a local merge commit (81180e30362c). The time is the wall time of theShader.PrepareArtifactslices on theshader preparethreads in each trace.main1main2main3main4main5The five
maincaptures span 17.7% in total prepare time, and the 13 prepare threads run in parallel with the title, so a title capture can't resolve a recompiler change of a few percent. The replay measurement above is this change's measurement. This PR's capture falls inside the range of the fivemaincaptures.main1 trace, digest,main2 trace, digest,main3 trace, digest,main4 trace, digest,main5 trace, digest, this PR trace, digest{"commit":"dbac9fa15b61","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":120148.301},"presents":194,"frame_ms":{"p50":16.686,"p90":32.765,"p99":2921.590,"max":112847.624},"gpu_busy_ms_per_present":6.483,"worker_busy_pct":{"queue worker 0x0":88.481,"queue worker 0x20":73.127},"top_phases_ms_per_frame":{"Driver.Packet":1000.862,"Driver.Packet.dispatch":503.561,"Driver.Dispatch":503.451,"Shader.PrepareArtifact":450.125,"Driver.Packet.memory_wait":424.003,"Vulkan.GraphicsPipeline":132.519,"Vulkan.GraphicsPipelineLibrary":126.497,"Vulkan.GraphicsPipelinePrebuild":77.312},"trace_dropped":false,"trace":"aps5-trace-dbac9fa15b61-3.json.gz"} {"commit":"81180e30362c","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":112864.040},"presents":195,"frame_ms":{"p50":16.689,"p90":28.698,"p99":1844.369,"max":106806.209},"gpu_busy_ms_per_present":4.938,"worker_busy_pct":{"queue worker 0x0":88.961,"queue worker 0x20":71.973},"top_phases_ms_per_frame":{"Driver.Packet":931.461,"Driver.Packet.dispatch":472.715,"Driver.Dispatch":472.625,"Shader.PrepareArtifact":464.413,"Driver.Packet.memory_wait":389.638,"Vulkan.GraphicsPipeline":119.169,"Vulkan.GraphicsPipelineLibrary":113.480,"Vulkan.GraphicsPipelinePrebuild":69.047},"trace_dropped":false,"trace":"aps5-trace-81180e30362c-3.json.gz"}VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -Vonmaine2a2914 and onmain+ this PR (cabf6ad, a local merge).main: 815 of 815 pass; with this PR: 815 of 815 pass. Neither log reports the layer missing. VUIDs onmain:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2; with this PR:VUID-VkImageViewCreateInfo-usage-02275×6,VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605×18,VUID-vkCmdCopyBuffer-srcBuffer-00118×2,VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2,VUID-vkCmdWaitEvents-srcStageMask-01158×2,VUID-vkSetEvent-event-09543×2. None is new with this PR.main1d41645 + perf(shader): leave out the both-zero select of f16 min and max #7516 + perf(shader): end dead code elimination when no released value is left dead #7494:agc_masked_selectwith the no-dead-code check and the 41-test set pass 3 of 3; identical shader-cache entries and replay hashes against twomainruns (Showcase PPSA99005, RetroArch PPSA99169, vkQuake PPSA99010), static frames bit-identical, and draw-path recompile time withinmain's spread.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