Repository navigation
perf(shader): define IrValue's trivial accessors in its header - #9132
Conversation
|
This pull request is labeled |
|
About the perf label's capture request: this change only affects shader compile time on the CPU. A frame capture would show it only as part of a title's start-up stalls, mixed with everything else that varies there. So it is measured where it applies: the replay of 152 Crimson Desert registration requests, task-clock over 8 interleaved runs per build (median 17.47 → 17.16 s, ranges not overlapping), with byte-identical SPIR-V for the 409 draw-time requests. If the maintainers want a title capture anyway, I can record Crimson Desert's start-up on both builds. AI-assisted: yes (Claude Code) |
|
@milescoviello I'm accepting the CPU-only evidence for this one. The change only touches CPU-side shader compilation, the paired CPU replay shows the compile-time effect, and the SPIR-V output is byte-identical, so a GPU trace couldn't show any difference. I've cleared |
|
@oneandonlydean thanks for clearing it. AI-assisted: yes (Claude Code) |
|
@oneandonlydean a note on the label you cleared: AI-assisted: yes (Claude Code) |
|
@milescoviello thanks for flagging it. My acceptance of the CPU-only replay evidence stands for both this and #9198. The bot putting |
|
Re-measured on current
I dropped one run for this PR: it ended after 9.5 s. Three more runs of each binary all prepared all 152 shaders with identical logs, and the same early exit happened once on the So on current AI-assisted: yes (Claude Code) |
|
Note 🤖 Claude Opus 5.5 responding on behalf of JulesB40 On Windows + NVIDIA (Ada), head Setup: Windows 11 Home 10.0.26200, Intel Core i9-13900HX, NVIDIA GeForce RTX 4070 Laptop GPU ( Command, the same on both sides:
No title was run. |
|
@JulesB40 thanks for the full AI-assisted: yes (Claude Code) |
|
@milescoviello thanks. The code is fine (SPIR-V byte-identical, agc_ parity), but on current Could you post one fresh |
5538df0 to
04cf3a9
Compare
|
@oneandonlydean a fresh pair. This PR rebased onto
Paired by round, this PR used less CPU in 10 of 10 rounds, by -0.93 % to -2.39 % (median -1.27 %; -1.7 % between the medians). The two absolute ranges overlap by about 0.2 s, so this is a small, consistent gain rather than a large one. I don't know of a shader shape where it's bigger: the change only inlines The 10 rounds (task-clock in s, ms per shader in brackets; max RSS in KB)
AI-assisted: yes (Claude Code) |
Id, Arguments, Parent, ImmediateU32, IsPhi, HasUses and UseCount only return a member, but they were defined in IrValue.cpp, so every pass in another translation unit called them out of line. In a profile of shader preparation for 152 Crimson Desert registration requests, these calls were about 7 % of the samples, and ValidateProgram spent a quarter of its time in Parent, Id and Argument calls. They are now inline in IrValue.hpp, next to Opcode, Type and the other accessors already there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
04cf3a9 to
85dce28
Compare
|
@oneandonlydean #11820 merged and conflicted with this PR in
Same picture as before #11820: a small, consistent gain. AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Unstable on main (2, 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
IrValue'sId,Arguments,Parent,ImmediateU32,IsPhi,HasUsesandUseCountonly return a member or compare one, but they were defined inIrValue.cpp. So every IR pass outside that file called them out of line. They are now defined inline inIrValue.hpp, next toOpcode,Type,ArgumentCountand the other accessors already there. Nothing else changes.Why these: in a DWARF profile of shader preparation (
agc_shader_replay --prepareover 152 Crimson Desert registration requests,main2f161d4), calls intoIrValue's out-of-line members were about 13 % of all leaf samples:HasUses3.1 %;Parent2.1 %;Id1.3 %;IsPhi0.3 %;ValidateProgramspent a quarter of its own 8.5 % inParent,IdandArgumentcalls.Tested
Ubuntu 24.04, GCC 13.3, Release (
build-rel, SPIRV-Tools off), i7-13700K, onmain2f161d4 (rebased onto ce7d547 afterwards, no conflict).agc_shader_replay --spvover the 409 draw-time requests of MXGP 26 and Super Meat Boy 3D writes 409 SPIR-V modules on both builds. All 409 are byte-identical.agc_shader_replay --prepareover the same 152 requests, task-clock, 8 interleaved runs per build,ANYPS5_NO_SHADER_CACHE=1:mainThat's 1.8 % less CPU, and the ranges don't overlap.
Tests: the 37 tests matching
^shader|^request_serializer$|^agc_shaderpass.No Vulkan call changes, and the SPIR-V is identical, so I didn't run a validation-layer comparison.
Windows 11 Enterprise 26300, NVIDIA GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0 r7 (UCRT), Release:
agc_validate_program,agc_masked_selectandagc_ir_reclaimpass 3 of 3 onmainand 3 of 3 with this change.Windows 11 Home 10.0.26200, NVIDIA GeForce RTX 4070 Laptop GPU (driver 616.92), WinLibs GCC 15.2.0 r7, Release, run by JulesB40 (results): this head merged onto
maind4cb89300fmatches thatmainacross all 1,125agc_tests with the Khronos validation layer on: 1,117 pass, the same 8 skip, and the same 18VUID-lines, all of them AGC: pipelines use differing per-attachment blend states while independentBlend is never enabled (VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605) #11990's.Not tested: Clang.
Performance captures
The form asks for summary lines, so here are two from a title, with a caveat: this change speeds up shader compilation, and that doesn't show in frame time. The title whose start-up is compile-bound here, Crimson Desert, presents almost no frames then (2 in its first 600 s on 10-21), so it has no window to compare. These are from Super Meat Boy 3D (PPSA31162) start-up:
ANYPS5_NO_SHADER_CACHE=1, every shader goes through the recompiler.APS5_TRACE_SECONDS=10:60, 90 s runs, pad input, no other switch.main2816bd2 and of this PR merged onto it, two rounds interleaved with the other recompiler PR.In that window the shader prepare threads are 1-4 % busy, so the frames show no difference, as expected:
main2816bd2, run 1main, run 2The measurement of this change is the replay timing under Tested. Traces and digests for all runs are in a release on my fork.
{"commit":"2816bd275452","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"10:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA31162","title":"Super Meat Boy 3D","content_version":"02.000.001","resolution":"3840x2160","window":{"spec":"seconds 10:60","first_present":24,"ms":60058.966},"presents":513,"frame_ms":{"p50":134.233,"p90":165.070,"p99":217.141,"max":2955.273},"gpu_busy_ms_per_present":89.154,"worker_busy_pct":{"queue worker 0x0":95.177,"queue worker 0x20":93.562},"top_phases_ms_per_frame":{"Driver.Packet":220.791,"Driver.Packet.memory_wait":106.956,"Driver.Packet.dispatch":63.396,"Driver.Dispatch":62.994,"Recorder.Sync":44.242,"GpuMutex.wait.hook":40.453,"Graphics.Draw":32.101,"Graphics.Draw.draw_and_resource_release":29.659},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":28.862,"events_lost":450991,"totals_full":false}},"trace":"aps5-trace-2816bd275452-3.json.gz"}{"commit":"1b4e4aa0f5c9","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"10:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA31162","title":"Super Meat Boy 3D","content_version":"02.000.001","resolution":"3840x2160","window":{"spec":"seconds 10:60","first_present":26,"ms":60009.942},"presents":454,"frame_ms":{"p50":134.899,"p90":215.696,"p99":743.552,"max":3015.552},"gpu_busy_ms_per_present":80.532,"worker_busy_pct":{"queue worker 0x0":92.895,"queue worker 0x20":89.774},"top_phases_ms_per_frame":{"Driver.Packet":241.358,"Driver.Packet.memory_wait":118.072,"Shader.PrepareArtifact":61.656,"Driver.Packet.dispatch":48.886,"Driver.Dispatch":48.721,"Graphics.Draw":37.864,"Driver.Packet.pipeline_drain":35.519,"Graphics.Draw.draw_and_resource_release":33.660},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":30.811,"events_lost":668152,"totals_full":false}},"trace":"aps5-trace-1b4e4aa0f5c9-3.json.gz"}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