Skip to content

perf(shader): allocate a program's use lists from an arena - #12039

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
milescoviello:perf/ir-use-arena
Oct 30, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
milescoviello:perf/ir-use-arena

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

Performance evidence: this is a CPU-only change to shader compilation, and the SPIR-V is byte-identical. oneandonlydean accepted paired replay timings for this class of change instead of title captures (#9132, #9198), and so did MarcZX10 on #11719. Exact revisions, raw runs, the command and the request set are below.

At the current head 1d9eaeaa89 (rebased onto main aaccd0ba39), with the same replay on an otherwise idle host: 9.86 s → 9.00 s task-clock (−8.7 % median, lower in 10 of 10 rounds, −7.9 % to −9.6 % per round), and max RSS +4.4 MiB (+1.7 %). The SPIR-V is byte-identical: all 65 Crimson Desert modules and all 302 MXGP modules. The 82 focused tests pass 3 of 3 at the head and on that main, and Khronos validation over them has no VUID- messages on either side. Rounds and method. The previous head e7c7184498 on main edf6804cf5 gave −8.6 % (rounds). The measurements below are from the earlier heads.

Every IrValue keeps the list of instructions that read it (operandUses, a std::vector<IrUse>). Each AddArgument, ReplaceArgument and ReplaceAllUsesWith pushes onto a use list, and every growth is a heap reallocation, so a program's use lists churn through malloc/free while the passes run. All of a program's values die with the program, so freeing their use lists one by one buys nothing.

With this change, a program's use lists come from a bump arena (std::pmr::monotonic_buffer_resource) that the program owns. Growing a list bumps a pointer, and freeing the old buffer does nothing. The memory goes back when the program is destroyed.

Measured with the shader replay over the 152 Crimson Desert (PPSA25286) pipeline requests in --prepare mode, the same corpus as #11798, #11820, #11967 and #12002. Both sides are exact upstream revisions: main 9af563f33d and this PR's head 9aaf9be4a0, which sits directly on it:

Build Mean task-clock Median Rounds lower Max RSS (median)
main 9af563f33d 15.67 s 15.69 s 264.7 MB
this PR 9aaf9be4a0 14.53 s (−7.2 %) 14.50 s 10 of 10 268.9 MB
All 10 rounds (task-clock and max RSS of each run)
Round Order main (ms) PR (ms) change main max RSS (KB) PR max RSS (KB)
1 main PR 15,997.8 14,612.6 -8.7 % 271,388 275,428
2 PR main 15,705.9 14,613.0 -7.0 % 271,168 275,548
3 main PR 15,739.0 14,635.6 -7.0 % 270,872 275,344
4 PR main 15,555.0 14,719.1 -5.4 % 270,804 275,668
5 main PR 15,561.6 14,464.9 -7.0 % 270,784 275,440
6 PR main 15,808.7 14,462.1 -8.5 % 271,156 275,324
7 main PR 15,675.1 14,429.4 -7.9 % 271,204 275,240
8 PR main 15,513.1 14,492.3 -6.6 % 270,804 274,928
9 main PR 15,397.4 14,511.8 -5.8 % 271,592 275,256
10 PR main 15,735.3 14,397.4 -8.5 % 271,028 275,328

Max RSS grows by about 4 MB (1.6 %). That's the arena's transient peak while programs are being built. A counting diagnostic build shows the arena peaking at 6.5 MiB in this replay, with no cached program holding arena memory (review reply). Use lists grow geometrically, so a program being built holds at most about twice its final use-list bytes.

Where the time goes, from perf record -F 499 of one replay of the same corpus on each side, taken at the earlier head 787e3f6eae against main c547deaacb (samples, not percentages):

Function main this PR
whole run 7,966 7,174
allocator (malloc, free, new, delete and glibc's internals) 1,948 1,509
ValidateProgram 410 371
IrValue::HasUses 365 326
ConstantFolder::Fold 227 201
DeadCodeEliminator::Eliminate 183 159
IrValue::Parent 181 163

More than half of the saving is in the allocator. The passes that walk use lists gain a little more, because a program's lists now sit together in its arena.

The SPIR-V is byte-identical to main's: all 65 modules from the Crimson Desert requests and all 302 from MXGP 26's (PPSA30839) dump. Only where use-list buffers live changes; the order of uses and every pass's behaviour stay the same.

How

  • IrValue.hpp: IrUseAllocator<T> holds a std::pmr::memory_resource*. With an arena it allocates from it and deallocate does nothing. Without one it is std::allocator. operandUses is an IrUseList (std::vector<IrUse, IrUseAllocator<IrUse>>), and OperandUses() returns it. A copy of a use list (select_on_container_copy_construction) goes back to the heap, so a copy can outlive the program. The allocator propagates on move and swap.
  • IrValue(opcode, type, id, useArena = nullptr): values made outside a program (resource plans, the disk cache, tests) keep the heap.
  • IrUseArena owns the program's monotonic_buffer_resource, created on the first CreateValue. IrProgram declares it before values, so values are destroyed before their arena. Its move assignment swaps, so in a = std::move(b) the old arena of a moves into b and outlives the values a drops. deallocate never touches the arena either way.
  • IrValue grows by the allocator's pointer, from 128 to 136 bytes; ShaderDiskCache.cpp's size check follows. The plan value encoder doesn't serialise use lists, so the disk-cache format is unchanged.
  • ConstantFolder.cpp: the two places that copied a use list into a std::vector<IrUse> copy it as an IrUseList. UseRewrite.cpp compares against IrUseList.
  • A monotonic_buffer_resource isn't thread-safe. A program's values are only changed by the thread compiling it, as std::vector already requires.
  • IrReclaim.cpp adds a case: 40 readers grow one value's use list in its program's arena and keep their order; ReplaceAllUsesWith moves all of them to another value; then move assignment into that program keeps the assigned program's use lists intact.

Cached programs (after review): getSource stores some programs in their SourceEntry. Before it does, IrProgram::ReleaseUseArena() copies each surviving value's use list into a heap vector and frees the arena, so a cached program keeps none of the arena's buffers: neither the ones whose values ReclaimUnusedValues dropped, nor the old buffers growth left. This also holds on the getSource(..., false) path, which caches without reclaiming. Values created after that get a new arena. Second commit: 3d427e3e32.

Merge order:

Tested

Head 0fe2329ee8 (6a98793e3b with main 422f96b3a9 merged in, which brings main's Recompiler.cpp change), built from these exact revisions:

  • shader_ir_use_rewrite, agc_ir_reclaim, agc_constant_select, agc_masked_select and agc_validate_program pass 3 of 3.
  • agc_shader_replay --spv gives byte-identical SPIR-V on main 422f96b3a9 and on this head: all 65 Crimson Desert modules (152 requests) and all 302 MXGP modules (305 requests).
  • Task-clock of --spv over all 457 requests, 10 alternating rounds: 26.61 s mean on main, 19.83 s on this head (−25.5 %), lower in 10 of 10 (24.5–26.0 %). Median max RSS is 1,374,254 KB on main and 1,391,460 KB on this head.

This is a CPU-only change to IR allocation with byte-identical SPIR-V, so it has no GPU-side effect to capture. oneandonlydean accepted replay evidence in place of title captures for such changes on #9132 and #9198.

Earlier:

Exact head 6a98793e3b merged with main dc38224141 (merge b0bf86ca7d, clean), Linux, GCC 15.2, Release, SPIRV-Tools off:

  • shader_ir_use_rewrite, agc_ir_reclaim, agc_constant_select, agc_masked_select and agc_validate_program pass 3 of 3.
  • agc_shader_replay --spv gives byte-identical SPIR-V on main and on the merge: all 65 Crimson Desert modules (152 requests) and all 302 MXGP modules (305 requests).
  • Task-clock of --spv over all 457 requests, 10 alternating rounds: 26.43 s mean on main, 19.85 s on the merge (−24.9 %), lower in 10 of 10 (24.4–25.6 %). Median max RSS is 1,370,986 KB on main and 1,392,566 KB on the merge. This workload includes SPIR-V emission, unlike the --prepare timings below.

Earlier heads:

Linux (Ubuntu 26.04, GCC 15.2), Release:

  • At 787e3f6eae (this patch before the rebase onto 9af563f33d, unchanged by it): the 47 test targets whose sources use the IR API, ctest 3 runs, all 76 entries pass in every run. AddressSanitizer: agc_ir_reclaim, agc_shader_memory, agc_validate_program and shader_ir_use_rewrite, 3 runs, all pass with no AddressSanitizer or LeakSanitizer report.
  • Windows 11 VM (GeForce GT 1030, WinLibs GCC, Release): shader_ir_use_rewrite, agc_ir_reclaim, agc_validate_program, agc_shader_memory and agc_constant_select, 3 runs each on main c547deaacb and at 787e3f6eae: 5 of 5 pass in every run on both sides.

At 3d427e3e32 (after review), with the same replay and 10 rotating rounds against main 9af563f33d and the previous head 9aaf9be4a0, built from those exact revisions:

  • Mean task-clock is 15.55 s on main, 14.37 s on the previous head and 14.64 s on this head: −5.9 % against main, lower in 10 of 10. This head is 1.9 % slower than the previous one.
  • Median max RSS is 271,204, 275,354 and 275,416 KB.
  • SPIR-V is byte-identical to main for all 65 Crimson Desert and 302 MXGP modules.
  • shader_ir_use_rewrite, agc_ir_reclaim, agc_constant_select, agc_masked_select and agc_validate_program pass 3 of 3. A ReleaseUseArena that does nothing fails agc_ir_reclaim. On the Windows 11 VM they pass 3 of 3 at main and at this head.
  • Super Meat Boy 3D, 3 rotating rounds, median RssAnon peak: 608dd76843 5,141 MB, + the previous head 4,856 MB, + this head 4,610 MB. That's within the roughly 600 MB spread between runs of one build.

Combined layout with #11798 and #11820 (033713cac5 on my fork: main 9af563f33d + #11798 c31e8e0fe3 + #11820 e339f57e4d + this change):

  • The conflict with perf(shader): allocate a program's IR values in chunks #11798 resolves as values.Create(opcode, type, nextValueId, useArena.Resource()), with IrValuePool::Create taking the arena and passing it to the value's constructor.
  • IrValue is 144 bytes there. The ShaderDiskCache.cpp check is set to 144 and builds.
  • The 47 IR test targets pass 3 of 3 (76 entries), and the four AddressSanitizer targets pass 3 of 3 with no report.
  • SPIR-V is byte-identical to the same stack without this change: all 65 Crimson Desert and all 302 MXGP modules.
  • Timing, 6 alternating rounds against that stack: 10.40 s → 8.98 s mean task-clock (−13.6 %), lower in 6 of 6. Max RSS goes from 256.2 to 265.8 MB. That's more growth than on main alone, and I haven't looked into why.
All 6 rounds on the stack
Round Order stack (ms) stack+PR (ms) change stack max RSS (KB) stack+PR max RSS (KB)
1 stack+PR stack+PR 10,345.4 8,939.3 -13.6 % 262,200 272,364
2 stack+PR stack+PR 10,362.8 8,892.2 -14.2 % 262,116 273,212
3 stack+PR stack+PR 10,360.8 9,017.6 -13.0 % 262,488 270,724
4 stack+PR stack+PR 10,385.6 9,054.8 -12.8 % 262,208 272,812
5 stack+PR stack+PR 10,448.9 9,030.2 -13.6 % 263,060 271,920
6 stack+PR stack+PR 10,488.0 8,972.8 -14.4 % 263,076 270,200

How the numbers were taken:

  • Builds: release agc_shader_replay (SPIR-V Tools off, as users build) of each exact revision. Replay binary SHA-256 prefixes: main 0b1feee1a3a5, this PR 531fdc2c2a97.
  • Command, per run: ANYPS5_NO_SHADER_CACHE=1 /usr/bin/time -f %M perf stat -x, -e task-clock agc_shader_replay --prepare <the 152 requests>, in a fresh empty directory, alternating which side runs first.
  • Request set: 152 requests. The SHA-256 over the sorted list of their file digests is 4fc9e044c1e59fb3. The 305 MXGP requests give 7a681333ac4a2b4e. The requests themselves are game shader dumps and aren't published.
  • SPIR-V: agc_shader_replay --spv over both sets on each side, then a diff of the sorted sha256sum lists of the output modules.

Supplementary: Black Ops II title captures with a cold recompiler cache (comment). Black Ops II stops at 8 s on main without #9656, so both sides there are local builds of eece5da035 + #9656, with and without this commit. They aren't upstream revisions and aren't the evidence for this PR. They showed 14.5 % and 17.4 % less preparation time per artifact on the title thread, and no change on the workers.

Title captures (after review): Super Meat Boy 3D, main 9af563f33d + #11580 (608dd76843) against the same + this PR (561c7f952a), 3 interleaved rounds, recompiler cache off. Shader.PrepareArtifact worker time is 12,196 ms → 11,322 ms (−7.2 %), lower in 3 of 3 (table and traces). Round 2's summary lines:

{"commit":"608dd7684303","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0: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 0:60","first_present":0,"ms":60032.708},"presents":421,"frame_ms":{"p50":125.841,"p90":141.927,"p99":1311.172,"max":3996.694},"gpu_busy_ms_per_present":87.926,"worker_busy_pct":{"queue worker 0x0":86.308,"queue worker 0x20":84.754},"top_phases_ms_per_frame":{"Driver.Packet":243.826,"Driver.Packet.memory_wait":120.231,"Driver.Packet.dispatch":57.628,"Driver.Dispatch":57.465,"Shader.PrepareArtifact":43.040,"Driver.Packet.pipeline_drain":40.281,"Recorder.Sync":39.168,"GpuMutex.wait.hook":38.208},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.470,"events_lost":327140,"totals_full":false}},"trace":"aps5-trace-608dd7684303-3.json.gz"}
{"commit":"561c7f952a08","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0: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 0:60","first_present":0,"ms":60061.392},"presents":428,"frame_ms":{"p50":125.393,"p90":140.113,"p99":1366.643,"max":3861.073},"gpu_busy_ms_per_present":87.289,"worker_busy_pct":{"queue worker 0x0":87.165,"queue worker 0x20":84.964},"top_phases_ms_per_frame":{"Driver.Packet":241.484,"Driver.Packet.memory_wait":118.840,"Driver.Packet.dispatch":57.317,"Driver.Dispatch":57.176,"Recorder.Sync":39.805,"Driver.Packet.pipeline_drain":39.747,"Shader.PrepareArtifact":39.409,"GpuMutex.wait.hook":37.774},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":38.766,"events_lost":337406,"totals_full":false}},"trace":"aps5-trace-561c7f952a08-3.json.gz"}

Checklist

🤖 Generated with Claude Code

@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line labels Oct 27, 2026
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5021 core/shader/recompiler/Optimization/src/ConstantFolder.cpp
core/shader/recompiler/Recompiler.cpp
PR 5609 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.cpp
PR 6280 core/shader/recompiler/ShaderDiskCache.cpp
PR 6488 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6858 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6924 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6970 core/shader/recompiler/ShaderDiskCache.cpp
PR 7085 core/shader/recompiler/ShaderDiskCache.cpp
PR 7395 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 7622 core/shader/recompiler/ShaderDiskCache.cpp
PR 7642 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 7684 core/shader/recompiler/ShaderDiskCache.cpp
PR 8004 core/shader/recompiler/Recompiler.cpp
PR 9020 core/shader/recompiler/Recompiler.cpp
PR 9183 core/shader/recompiler/ShaderDiskCache.cpp
PR 9335 core/shader/recompiler/Recompiler.cpp
PR 9356 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9387 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9457 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9633 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9748 core/shader/recompiler/Recompiler.cpp
PR 9749 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9790 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9852 core/shader/recompiler/ShaderDiskCache.cpp
PR 9969 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 10000 core/shader/recompiler/ShaderDiskCache.cpp
PR 10049 core/shader/recompiler/ShaderDiskCache.cpp
PR 10193 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 10489 core/shader/recompiler/ShaderDiskCache.cpp
PR 10652 core/shader/recompiler/Recompiler.cpp
PR 10757 core/shader/recompiler/Recompiler.cpp
PR 10846 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 10941 core/shader/recompiler/Recompiler.cpp
PR 11351 core/shader/recompiler/Recompiler.cpp
PR 12246 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 12324 core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrProgram.hpp
core/shader/recompiler/IntermediateRepresentation/src/IrProgram.cpp
core/shader/recompiler/Optimization/src/ConstantFolder.cpp
core/shader/recompiler/Recompiler.cpp
PR 12548 core/shader/recompiler/Recompiler.cpp
PR 12828 core/shader/recompiler/Recompiler.cpp
PR 12840 core/shader/recompiler/Recompiler.cpp

@milescoviello

Copy link
Copy Markdown
Contributor Author

Title captures for the perf label, with the same method as on #11967 and #11820.

Setup

Shader.PrepareArtifact from the traces (total ms / count, per artifact):

Run Title thread Prepare workers Worst frame
main 1 6,015 / 979 = 6.14 ms 2,499 / 663 = 3.77 ms 1,484 ms
main 2 2,842 / 644 = 4.41 ms 2,502 / 681 = 3.67 ms 1,228 ms
main 3 3,009 / 654 = 4.60 ms 2,510 / 660 = 3.80 ms 1,210 ms
this PR 1 2,577 / 631 = 4.08 ms 2,463 / 649 = 3.79 ms 1,200 ms
this PR 2 2,275 / 603 = 3.77 ms 2,352 / 647 = 3.64 ms 1,406 ms
this PR 3 2,293 / 604 = 3.80 ms 2,465 / 661 = 3.73 ms 1,408 ms
  • Title thread: 14.5 % and 17.4 % less per artifact in pairs 2 and 3, lower in all three pairs. In main's first run the title thread prepared 979 artifacts instead of about 650, at 6.14 ms each, so I don't count pair 1's 34 %.
  • Prepare workers: within ±2 % per artifact. I can't call that a change, the same as perf(shader): keep up to three IR operands inside the value #11820 saw.
  • Worst frame: the boot hitch is shorter in pair 1 and longer in pairs 2 and 3, so no claim.
  • Not claimed: present counts and p90/p99 vary with the scene, so there's no frame-rate claim.

Summary lines of pair 2 (main + #9656, then this PR + #9656):

{"commit":"ed3b6566a2c6","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0:150"},"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":"PPSA34502","title":"Call of Duty®: Black Ops II","content_version":"01.010.000","resolution":"1920x1080","window":{"spec":"seconds 0:150","first_present":0,"ms":150023.152},"presents":2146,"frame_ms":{"p50":16.697,"p90":181.907,"p99":229.288,"max":1227.695},"gpu_busy_ms_per_present":19.959,"worker_busy_pct":{"queue worker 0x0":75.561},"top_phases_ms_per_frame":{"Driver.Packet":52.149,"Driver.Packet.draw":33.414,"Driver.Draw":33.151,"Graphics.Draw":27.402,"Graphics.Draw.draw_and_resource_release":25.638,"Driver.Draw.shader_compile_and_link":15.286,"VideoOut.Flip":14.304,"Shader.ResolveAbi":13.995},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":95.904,"events_lost":81720,"totals_full":false},"queue worker 0x0":{"events_full_after_s":25.696,"events_lost":2865070,"totals_full":false},"draw committer":{"events_full_after_s":64.619,"events_lost":504748,"totals_full":false}},"trace":"aps5-trace-ed3b6566a2c6-3.json.gz"}
{"commit":"2bb6ee4de359","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0:150"},"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":"PPSA34502","title":"Call of Duty®: Black Ops II","content_version":"01.010.000","resolution":"1920x1080","window":{"spec":"seconds 0:150","first_present":0,"ms":150046.055},"presents":2212,"frame_ms":{"p50":16.713,"p90":168.629,"p99":222.463,"max":1406.372},"gpu_busy_ms_per_present":18.273,"worker_busy_pct":{"queue worker 0x0":76.249},"top_phases_ms_per_frame":{"Driver.Packet":50.950,"Driver.Packet.draw":33.087,"Driver.Draw":32.839,"Graphics.Draw":27.966,"Graphics.Draw.draw_and_resource_release":26.278,"Driver.Draw.shader_compile_and_link":14.406,"VideoOut.Flip":14.172,"Shader.ResolveAbi":13.497},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":84.353,"events_lost":89874,"totals_full":false},"queue worker 0x0":{"events_full_after_s":24.107,"events_lost":2782005,"totals_full":false},"draw committer":{"events_full_after_s":63.211,"events_lost":555288,"totals_full":false}},"trace":"aps5-trace-2bb6ee4de359-3.json.gz"}

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 787e3f6eae82e11b336343d94f450455bee6907d. The allocator and arena lifetime approach is coherent on inspection, and the PR reports extensive IR, ASan, and Windows/Linux test coverage. I have not independently rebuilt this large shader change in this pass.

There are two repository-rule blockers:

  1. The perf report does not currently meet the required evidence format. The linked title summary lines use commits ed3b6566a2c6 and 2bb6ee4de359; neither resolves as a commit in upstream boykopovar/AnyPS5, and the report describes its other replay baseline as main c547deaacb, rather than the current base. The required tools/trace_digest.py output is also absent, and the trace assets are linked from a separate fork rather than attached here. Please provide the same-title/current-main and PR captures, both summary lines, trace assets and digest, or remove the performance claim/label and resolve the automated report check.

  2. The PR itself identifies unresolved overlapping work: exact pairwise git merge-tree shows content conflicts with open #11798 in IrProgram.cpp and #7689 in ShaderDiskCache.cpp. #11820 also overlaps the IrValue size check and the description says the combined layout requires changing the size from 136 to 144. The description says whichever lands second will be rebased, but CONTRIBUTING.md requires authors to agree the order and declare it with Depends on; the checklist currently says none. Please coordinate the order with those authors, declare dependencies, and validate the combined layout and cache size check after rebasing.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, working on both.

  1. Evidence: this is a CPU-only change to shader compilation with byte-identical SPIR-V, the same class as perf(shader): reuse the evaluator's requirement list across values #11719. I've rebased onto current main 9af563f33d (head is now 9aaf9be4a0). I'm re-running the replay A/B against that exact main and will post the raw per-run numbers, run order, exact revisions, the command, a digest of the request set and the SPIR-V comparison. The Black Ops II captures were extra and used local combinations with fix(libSceVoice): report inactive input voice activity #9656. I'll mark them as supplementary, not as the evidence.
  2. Order:

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 both points are updated in the description:

  1. Evidence, on exact upstream revisions. The head is now 9aaf9be4a0, directly on main 9af563f33d.
    • Timing: 10 alternating replay rounds, 15.67 s → 14.53 s mean task-clock (−7.2 %), lower in 10 of 10. Every run is in a collapsible table, with order, time and max RSS, alongside the command, the replay binary hashes and a digest of the request set.
    • SPIR-V: byte-identical to main, 65 Crimson Desert and 302 MXGP modules, compared by sorted sha256sum lists.
    • Title captures: the Black Ops II captures are now marked supplementary. Black Ops II needs fix(libSceVoice): report inactive input voice activity #9656 to run on main, so those builds can't be upstream revisions.
  2. Order:

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked exact head 9aaf9be4a0d50baf45e59825107eb432e9e5a114. The new report substantially improves the technical evidence: it gives exact replay revisions, ten paired rounds, request-set digest, SPIR-V comparisons, memory cost, and the combined layout tests. The earlier conflicts with #11798 and #11820 now have declared dependencies, and the author of #7689 has proposed the same either-order resolution in a comment there.

Two repository requirements are still unresolved:

  1. This PR still claims a 7.2% speedup and retains the perf title/label. The current PR labels include perf numbers missing, and the description still has no two valid aps5-summary.jsonl lines or attached traces for the same title, scene and machine. The replay timing table is useful supplemental evidence, but CONTRIBUTING.md requires those paired capture summaries and traces for a speed claim; AGENTS.md also requires tools/trace_digest.py summaries. Please add the required report material, or remove the speed claim and perf label so the automated missing-numbers label clears.

  2. #12039 and #7689 both change the ShaderDiskCache.cpp size-assert region. The new checklist declares #11798 and #11820, but still does not declare an agreed order with #7689. The current comment proposes either order, and the #7689 author has not replied to this specific proposal. Please get that order agreed and record it with Depends on as the overlap rule requires.

The report and tests are author-provided; I have not independently rebuilt the shader changes. Current hosted Windows, Ubuntu relinker and ASan checks pass; two macOS relinker checks are still pending. These checks do not resolve the report or overlap items above.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks for rechecking.

  1. Captures. I'll add paired title captures on the exact upstream revisions (main 9af563f33d and this head 9aaf9be4a0). Black Ops II can't be used for that, since it needs fix(libSceVoice): report inactive input voice activity #9656. So the captures will be Metal Gear Solid 4 (PPSA18194), which runs on plain main, from boot with a cold recompiler cache, 3 interleaved runs per side. I'll post both aps5-summary.jsonl lines per pair, the tools/trace_digest.py output, and the traces. I can't attach files to a pull request through the API, so the traces will be release assets on my fork, linked here. That's the same way perf(shader): allocate a program's instruction list nodes from a pool #11967's were shared. They'll follow once the title run currently on this machine finishes.
  2. fix(shader): defer guarded fragment V# type faults #7689. You're fix(shader): defer guarded fragment V# type faults #7689's author, so you can settle this one directly. Which order do you want? Either works for me:

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 an update on the title captures, since none of them is ready yet. On plain main 9af563f33d with the recompiler cache off, every title in my set stops before a trace window closes:

Title Stop on main (cold recompiler cache)
Metal Gear Solid 4 (PPSA18194) the launcher exits at 32 s and hands off to mgs4.elf, so no trace is written
MXGP 26 (PPSA30839) sceHttp2GetMemoryPoolStats not implemented at 9 s (fixed by #11616)
Ghost of Tsushima (PPSA02225) native multisample stencil or depth format import is not implemented at 33–37 s (#9742)
Borderlands 4 (PPSA01494) the converted-float 16-bit refusal at 75–86 s (#11425, fixed by #11580); a 0–60 s window never closed, 3 runs per side
Black Ops II (PPSA34502) needs #9656

So the captures can't be on main alone. My proposal: Borderlands 4 with #11580 applied identically to both sides, so 9af563f33d + #11580 against 9af563f33d + #11580 + this PR. #11580 only changes converted D16 loads and stores, nothing in the IR. Cold recompiler cache, warm driver cache, 3 interleaved runs per side, with the summary lines, trace_digest.py output and traces as before. If you'd rather have a different title or a different unblocking change, tell me and I'll use that.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 28, 2026
@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 the title captures are in. Borderlands 4 couldn't serve: it presents once during boot and then not again for minutes, so a present-based trace window never closes. Super Meat Boy 3D runs to the end on main with #11580, so I used that pair as proposed:

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 (ANYPS5_NO_SHADER_CACHE=1) so every shader is prepared, a warm driver cache, APS5_TRACE_SECONDS=0:60, and 3 rounds alternating which side goes first. Linux, RTX 4070 Ti, 615.71.09.

Shader.PrepareArtifact, summed over the trace window (total ms / slices):

Round main workers this PR workers main title thread this PR title thread
1 (main first) 12,026 / 491 11,464 / 497 6,174 / 382 5,116 / 379
2 (PR first) 12,353 / 490 11,423 / 505 5,766 / 384 5,444 / 374
3 (main first) 12,208 / 491 11,079 / 500 5,706 / 386 5,582 / 387
mean 12,196 11,322 (−7.2 %) 5,882 5,381 (−8.5 %)

The worker sum is lower in all 3 pairs. −7.2 % matches the CPU replay in the description. Frame times are the same within noise (p50 121–126 ms on both sides), because this boot phase is GPU- and compile-bound.

The summary lines of round 2:

{"commit":"608dd7684303","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0: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 0:60","first_present":0,"ms":60032.708},"presents":421,"frame_ms":{"p50":125.841,"p90":141.927,"p99":1311.172,"max":3996.694},"gpu_busy_ms_per_present":87.926,"worker_busy_pct":{"queue worker 0x0":86.308,"queue worker 0x20":84.754},"top_phases_ms_per_frame":{"Driver.Packet":243.826,"Driver.Packet.memory_wait":120.231,"Driver.Packet.dispatch":57.628,"Driver.Dispatch":57.465,"Shader.PrepareArtifact":43.040,"Driver.Packet.pipeline_drain":40.281,"Recorder.Sync":39.168,"GpuMutex.wait.hook":38.208},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.470,"events_lost":327140,"totals_full":false}},"trace":"aps5-trace-608dd7684303-3.json.gz"}
{"commit":"561c7f952a08","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"0: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 0:60","first_present":0,"ms":60061.392},"presents":428,"frame_ms":{"p50":125.393,"p90":140.113,"p99":1366.643,"max":3861.073},"gpu_busy_ms_per_present":87.289,"worker_busy_pct":{"queue worker 0x0":87.165,"queue worker 0x20":84.964},"top_phases_ms_per_frame":{"Driver.Packet":241.484,"Driver.Packet.memory_wait":118.840,"Driver.Packet.dispatch":57.317,"Driver.Dispatch":57.176,"Recorder.Sync":39.805,"Driver.Packet.pipeline_drain":39.747,"Shader.PrepareArtifact":39.409,"GpuMutex.wait.hook":37.774},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":38.766,"events_lost":337406,"totals_full":false}},"trace":"aps5-trace-561c7f952a08-3.json.gz"}

All six traces, summary lines and tools/trace_digest.py outputs are release assets on my fork: pr12039-smb3d-captures. The digests say "no summary line found" because each line sits in a separate file next to its trace. Their tables are complete.

AI-assisted: yes (Claude Code)

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the full diff; the arena lifetime (declared before values, swap on move assignment, heap on copy) and the new IrReclaim case look right. Three things before this can merge:

  • Recompiler.cpp:536-538: source->program is kept in the SourceEntry, and IrProgram::ReclaimUnusedValues (57b2dc8) exists to shrink exactly those cached programs. With the arena, the use-list buffers of the dropped values, and every old buffer left by growth, stay allocated until the entry is destroyed, so reclaim no longer returns that memory. Please bound this (for example keep the arena only for programs that are not cached, or move the surviving use lists to the heap after reclaim) and show peak RSS before/after on a title run that keeps cached programs, not only on the --prepare replay (+1.6 % there, +3.7 % on the stack with #11798/#11820, still unexplained).
  • Order with #7689 on the ShaderDiskCache.cpp size asserts is still not agreed; please get the reply there and record it in Depends on. Note that with #11820 the IrValue check has to be 144: two identical 136 edits merge without a conflict and fail the build.
  • Rebase onto #11798/#11820 once they land, or drop them from the stack, so the head tested is what lands.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@adriadam10 thanks. Point by point:

1. Use-arena memory in cached programs. Pushed 3d427e3e32. IrProgram::ReleaseUseArena() copies each surviving value's use list into a heap vector and frees the arena. getSource calls it right before it stores a program in source->program. That covers both the reclaim path and getSource(..., false) at Recompiler.cpp:1974, which keeps a program without reclaiming. A program built after that gets a new arena. The new agc_ir_reclaim case grows a use list past 40 entries, releases the arena, and checks that every use is still there in order, that the lists are on the heap, and that a value created afterwards gets a new arena. A ReleaseUseArena that does nothing fails it.

To see what the arena actually holds, I put a counting upstream resource under it in a local diagnostic build, not pushed. It reports the arena's live and peak bytes every 10 s:

Run Old head 9aaf9be4a0 This head 3d427e3e32
Crimson Desert --prepare replay (152 requests) peak 6.5 MiB, live 0.0 MiB at every report and at exit peak 6.5 MiB, live 0.0 MiB
Super Meat Boy 3D, 100 s, cold recompiler cache peak 32.1 MiB, live 0.0 MiB at all 5 reports peak 27.2 MiB, live 0.0 MiB at 5 of 6 reports (7.1 MiB once)

So in these runs the arena only holds memory while programs are being built, during the burst of parallel preparations. No cached program kept arena memory, even before this commit. The commit bounds the case you describe for workloads that do keep cached programs; these two don't.

Peak RSS.

  • --prepare replay, 10 rotating rounds, median max RSS: main 271,204 KB, the old head 275,354 KB, this head 275,416 KB. The +4.2 MB is the same with and without the release, which fits the 6.5 MiB transient arena peak above rather than retention.
  • Super Meat Boy 3D, 3 rotating rounds each, median RssAnon peak: base 608dd76843 5,141 MB, + the old head 4,856 MB, + this head 4,610 MB. Runs of the same build spread over about 600 MB, so that doesn't resolve a difference of a few MB either way.
  • I haven't re-measured the stack's +3.7 %.

Timing, same replay, same 10 rounds:

  • This head is 14.64 s on average against main's 15.55 s: −5.9 %, lower in all 10 rounds.
  • The old head was 14.37 s, so this head is 1.9 % slower than it. I haven't counted how often ReleaseUseArena runs in this replay.
  • SPIR-V is byte-identical to main for all 65 Crimson Desert and all 302 MXGP modules.

2. Order with #7689. MarcZX10 agreed the rule for #11820 on #7689: whichever of the two lands second keeps both size checks. I asked there again for #12039 (comment) and will record his answer in Depends on. The 144-byte IrValue check with #11820 is noted in the description.

3. The stack. This PR is one commit on main, plus the new one, and the head tested above is what lands. The numbers on the #11798/#11820 stack are extra. If either of those lands first, I'll rebase onto it and re-measure, including setting the IrValue check to 144 for #11820.

Windows 11 VM (GT 1030, WinLibs GCC 15.2): the five IR tests pass 3 of 3 at main 9af563f33d and at this head.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — changes requested

The author’s latest update adds a focused arena-release test and an independent approval on this exact head. I rechecked the new head against current main; the branch is still based on an older revision, and current main has changed files this PR modifies. The reported performance captures also use the prior PR head, so the current combined change still needs validation.

What I ran

  • Refreshed the PR metadata, discussion, labels, reviews and hosted checks with gh.
  • Compared the PR head with upstream main using git merge-base, git merge-tree --write-tree, and git diff --check.
  • Compared current-main changes since the PR’s base with the files changed by this PR.
  • Did not build or run local tests.

Results

Check Result
Hosted conventions, eligibility, labels, Windows, relinker (macOS and Ubuntu), ASan and report Passed
Hosted Linux product, register-context and write-watch Skipped
Merge preview Clean
git diff --check Passed
Independent local build/tests in this review Not run
Unedited command output
$ git rev-parse refs/review/upstream-12039
3d427e3e3283f576112072da3cbea2965063ce37
$ git rev-parse upstream/main
edf6804cf52c62eacafc592dd6142cb4efe5bd05
$ git merge-base upstream/main refs/review/upstream-12039
9af563f33d43c66d8a30b8bb8a442e8abd120183
$ git merge-tree --write-tree upstream/main refs/review/upstream-12039 | head -40
07bfceffc8b9976e274926cc89a48dbdfbdc8778
$ git diff --check refs/review/upstream-12039^..refs/review/upstream-12039
(no output; exit status 0)
$ gh pr checks 12039 --repo boykopovar/AnyPS5
conventions	pass	16s	https://github.com/boykopovar/AnyPS5/actions/runs/40787031335/job/123162680926
eligibility	pass	7s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122772606866
labels	pass	7s	https://github.com/boykopovar/AnyPS5/actions/runs/40787031415/job/123162680996
relinker (macos-latest, clang++)	pass	2m37s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696640
relinker (macos-latest, clang++, x86_64)	pass	6m20s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696568
relinker (ubuntu-latest, g++)	pass	2m42s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696543
relinker (windows-latest, g++)	pass	9m3s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696450
windows	pass	3m19s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696374
linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774698334
register-context	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774698787
write-watch	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774698803
relinker-asan	pass	2m27s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461677/job/122774696536
report	pass	52s	https://github.com/boykopovar/AnyPS5/actions/runs/40675461543/job/122772605960

Negative control

Not run. I did not build a deliberately failing control or compare test logs locally.

Findings

Blocking

  • Rebase this branch onto current main and rerun the focused shader-recompiler tests on both the same current-main base and the exact PR head, with Vulkan validation configured as the repository requires. Current main has changed IrProgram.hpp, IrProgram.cpp, ConstantFolder.cpp, Recompiler.cpp and ShaderDiskCache.cpp, all paths touched by this PR; the author’s latest test report names the older base 9af563f33d.
  • Refresh the paired performance report for the rebased base and exact current head. The report in the PR body measures the earlier head 9aaf9be4a0; the current head adds ReleaseUseArena(), so the existing capture pair does not measure the full change now under review. Keep the same title, scene and machine and include the required summary lines, traces and digests.

Non-blocking

  • The current merge preview is clean, and the hosted checks listed above pass. Those results do not substitute for checking the changed shader-recompiler paths on current main and this exact head.

Sources

Not verified

  • I did not independently reproduce the author’s IR tests, ASan runs, replay timings, or SPIR-V comparisons.
  • Hosted Linux product, register-context and write-watch jobs were skipped.

To get this to a good state

Rebase onto current main; run the same focused shader-recompiler/Vulkan-validation tests on that base and the exact new head; then refresh the paired performance evidence for those exact revisions.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks. Rebased onto main edf6804cf5; the head is e7c7184498. The rebase had no conflicts. git range-diff shows both commits unchanged apart from one context line in IrProgram.hpp: main added the instructionNodes member next to this PR's.

On that base and head (Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, NVIDIA 615.71.09):

  • Focused recompiler tests: 82 tests pass, 3 of 3 runs at the head and 1 run on main edf6804cf5. The set is the ctest entries of every test target with a source that includes the IR headers, plus the recompiler suites:

    regex

    ^(agc_constant_bit_test|agc_constant_phi|agc_constant_select|agc_denormal_flush_elimination|agc_descriptor_cache_failure|agc_driver_bda_device|agc_driver_bda_device_selection_cpu|agc_driver_host_import_failure_handles|agc_driver_interpolation_modes|agc_guarded_memory_loads|agc_integer_folding|agc_integer_narrowing|agc_ir_reclaim|agc_masked_select|agc_placeholder_images|agc_redundant_value_elimination|agc_scalar_select_mask|agc_shader_bindless|agc_shader_disk_cache|agc_shader_disk_cache_large_file|agc_shader_disk_cache_pack_ownership|agc_shader_entry_lane_proof_budget|agc_shader_frontend_pair|agc_shader_frontend_pair_off|agc_shader_layout_pair|agc_shader_layout_pair_off|agc_shader_memory|agc_shader_quad_mask_no_demote|agc_shader_result_memo_budget|agc_shader_result_memo_budget_masked|agc_shader_result_memo_budget_threads|agc_shader_selected_records_direct_image_limit|agc_shader_selected_records_direct_pair_limit|agc_shader_selected_records_image_limit|agc_shader_selected_records_pair_limit|agc_shader_specialized_bda_abi_full|agc_shader_specialized_bda_abi_none|agc_shader_srt_read_patching|agc_shader_table_snapshot_reuse|agc_shader_table_snapshot_reuse_unmasked|agc_shader_type_zero_image_materialization|agc_spirv_failure_text|agc_tessellation_lowering|agc_validate_program|aperture_sources|interpolation_reference_range|pixel_ancillary|scalar_swappc|shader_ir_use_rewrite)$|^shader_|^agc_ir|^agc_shader_memory$|^agc_constant|^agc_masked|^agc_validate_program$|^agc_structurizer|^agc_spirv|^agc_scalar|^agc_vector|^agc_integer|^agc_dpp|^agc_pass_hazards$|^agc_shader_control_flow$|^agc_shader_disk_cache$

  • Validation layer (Khronos 1.4.363, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, same regex): 82 of 82 on both sides. Neither log has a missing-layer line, the layer checked the 1 device these tests create on each side, and neither side has a VUID- message.

The paired performance report for this base and head is next: the same Crimson Desert replay (152 requests, 10 rotating rounds, task-clock and max RSS), with SPIR-V equivalence over the Crimson Desert and MXGP sets. A backup of this machine is running and slowing its disk, so I'm holding the timing runs until it finishes. I'll then post the numbers here and update the body.

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 here is the refreshed performance report, for main edf6804cf5 and this head e7c7184498. Both sides are exact revisions, built as release agc_shader_replay with SPIR-V Tools off, as users build.

Replay: the same 152 Crimson Desert (PPSA25286) pipeline requests in --prepare mode as before. 10 rounds, alternating which side runs first, with ANYPS5_NO_SHADER_CACHE=1 /usr/bin/time -f %M perf stat -x, -e task-clock agc_shader_replay --prepare <the 152 requests> in a fresh empty directory per run. Ubuntu 26.04.1, i7-13700K.

main edf6804cf5 this head e7c7184498 change
task-clock, median of 10 9.77 s 8.93 s −8.6 % (−7.3 to −9.3 % per round, lower in 10 of 10)
max RSS, median of 10 263.0 MiB 267.2 MiB +4.2 MiB (+1.6 %)
All 10 rounds
round 1 (base head): base 9.77 s 270252 KB  head 8.89 s 273532 KB  
round 2 (head base): base 9.85 s 269360 KB  head 8.94 s 274528 KB  
round 3 (base head): base 9.78 s 269448 KB  head 8.89 s 274440 KB  
round 4 (head base): base 9.66 s 269084 KB  head 8.93 s 273468 KB  
round 5 (base head): base 9.72 s 269088 KB  head 8.93 s 274296 KB  
round 6 (head base): base 9.69 s 269172 KB  head 8.98 s 273228 KB  
round 7 (base head): base 9.88 s 270044 KB  head 9.03 s 274328 KB  
round 8 (head base): base 9.76 s 269300 KB  head 8.88 s 273544 KB  
round 9 (base head): base 9.82 s 269668 KB  head 8.91 s 273756 KB  
round 10 (head base): base 9.88 s 268860 KB  head 9.04 s 273504 KB  

SPIR-V: agc_shader_replay --spv on each side, then a diff of the sorted sha256sum lists. It's byte-identical: all 65 modules from the 152 Crimson Desert requests, and all 302 from the 305 MXGP 26 (PPSA30839) requests.

Replay binary SHA-256 prefixes: main c5ad05b5fbd9, this head 559b9731b9dc. The requests are game shader dumps and aren't published. The SHA-256 over the sorted list of their file digests is unchanged (4fc9e044c1e59fb3 and 7a681333ac4a2b4e).

Title captures, the same method as the earlier ones: Super Meat Boy 3D, with main edf6804cf5 + #11580 on both sides, 3 interleaved rounds, recompiler cache off, summary lines, traces and digests. They're queued behind another title run on this machine, and I'll post them here when they finish.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head e7c7184498e5441dc2e9412e8610fdc010991a49 and your current update. The use-arena lifetime regression and the 82-test/3-run report on edf6804cf5 address the earlier older-base test concern, and the new replay report is well described for that pair. The head still does not include current main 4c7d275bef89d309313d16bc2bc05d37a1b50be2; current main changed core/shader/recompiler/Recompiler.cpp, which this PR also changes. Please integrate current main and rerun the focused tests and paired performance report on that exact current integration. The merge preview is clean; diff check and conventions pass. I did not run the shader/GPU tests locally.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 integrated: rebased onto main aaccd0ba39 (newer than 4c7d275bef); the head is now 1d9eaeaa89. Both commits applied without conflicts. main's Recompiler.cpp change is next to snapshotHash (line 1755), and this PR's is in getSource (line 536). The use-arena diff is unchanged.

At this exact integration (Linux, RTX 4070 Ti, GCC 15.2):

  • Focused tests (the same 82 as before, work/ir12039.rx): 82 of 82 in each of 3 runs at the head, and 82 of 82 on main aaccd0ba39.
  • Khronos validation over those 82: 82 of 82 on both sides, the layer checked the device each side creates, no VUID- messages.
  • SPIR-V: agc_shader_replay --spv, built in build-rel with SPIR-V Tools off at aaccd0ba39 and at the head, over the 152 Crimson Desert requests (65 modules) and the 305 MXGP requests (302 modules): every module is byte-identical.
  • Paired replay timing, the same two binaries: perf stat -e task-clock of --prepare over the Crimson Desert set, 10 rounds alternating which build runs first. The host was otherwise idle: the run held the build/test lock and waited until no title, build or other replay was running. The head took less CPU in 10 of 10 rounds. The median was 9.86 s on main and 9.00 s at the head (-8.7 %), and the per-round change ranged from -7.9 % to -9.6 %. Max RSS was +4.4 MB (269.6 to 274.1 MB, medians).
The 10 rounds
Round Order main (s) Head (s) main max RSS (KB) Head max RSS (KB)
1 base head 9.85 8.98 269704 274400
2 head base 9.83 9.01 271812 274260
3 base head 9.95 8.99 268472 273952
4 head base 9.81 8.94 272384 274264
5 base head 9.91 9.04 270244 273960
6 head base 9.81 8.99 268832 273912
7 base head 9.87 9.01 268924 273408
8 head base 9.81 9.02 269588 274392
9 base head 9.91 9.13 269444 273648
10 head base 9.86 8.97 269552 274168

A first pass of the same 10 rounds ran right before this one, and I'm not reporting it: rounds 2 to 5 overlapped a Super Meat Boy 3D run on the same machine. All 10 of its rounds favoured the head too, by 2.8 % to 12.4 %. Fresh Super Meat Boy 3D title captures of this integration (main + #11580, then that + this PR, 3 interleaved rounds) are queued, and I'll add them when they finish. As before, they're supplementary to the identical-SPIR-V replay evidence.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — approved

The exact head is now rebased onto current main aaccd0ba39; the previously noted Recompiler.cpp integration is included, and the use-arena production diff remains unchanged. The author reports 82 focused tests passing in each of three runs on both the current-main baseline and this head, with the Vulkan validation layer reporting no VUIDs. The SPIR-V output is reported byte-identical across 152 replay requests.

The CPU shader-replay benchmark is reported as 9.86 s to 9.00 s median task-clock (10 paired rounds) with +4.4 MiB maximum RSS. This supports the compiler-time claim; it is not a title frame-time claim. Hosted checks are pending after the update.

I reviewed the integration and evidence but did not rerun the tests or benchmark locally. No blocking issue found; approval covers exact head 1d9eaeaa8950c2ed0b07b068efecddde93a3addc.

@milescoviello

Copy link
Copy Markdown
Contributor Author

The supplementary Super Meat Boy 3D captures of this integration, as promised: release with each run's trace, aps5-summary.jsonl and trace_digest.py output. The runs are 100 s from boot with pad input and ANYPS5_NO_SHADER_CACHE=1, so the title compiles its shaders. Each run holds the build/test lock, so nothing else runs alongside. "main" is 1ba9ce4450 (main aaccd0ba39 + #11580, which this title needs), and "PR" is c589d95aae (that + this PR's 1d9eaeaa89).

Shader.PrepareArtifact from each trace, total / count = per call:

Run Title thread Workers Worst frame
main 1 3,206 / 372 = 8.62 ms 5,873 / 463 = 12.68 ms 36,159 ms
PR 1 2,567 / 382 = 6.72 ms 5,581 / 490 = 11.39 ms 3,751 ms
PR 2 2,676 / 393 = 6.81 ms 5,589 / 506 = 11.05 ms 3,606 ms
main 2 2,855 / 394 = 7.25 ms 5,652 / 509 = 11.10 ms 3,470 ms
main 3 2,660 / 384 = 6.93 ms 5,926 / 506 = 11.71 ms 3,670 ms
PR 3 2,567 / 389 = 6.60 ms 5,687 / 488 = 11.65 ms 4,718 ms

Per call on the title thread, the medians are 7.25 ms on main and 6.72 ms with the PR (-7.3 %). On the workers they are 11.71 ms and 11.39 ms (-2.7 %). main 1 was the first run of the series, and its 36 s worst frame is an outlier: without it, main gives 6.93-7.25 ms and the PR 6.60-6.81 ms per call on the title thread. Three runs per side on a whole title is a small sample. The replay timing above, on identical SPIR-V, remains the primary evidence.

AI-assisted: yes (Claude Code)

@MarcZX10

Copy link
Copy Markdown
Contributor

Thanks for adding the supplementary captures. I checked the six summary and digest files in the linked release: the base/change commits, title, machine and 60-second windows match the report. Five of the six summaries flag trace_dropped; the queue-worker event buffers filled after about 36.7–37.8 seconds, although totals_full remains false. Since these title captures are explicitly supplementary and the identical-SPIR-V replay remains the primary evidence, this does not change my approval. Please treat the detailed worker/frame slices from the affected traces as partial-window evidence, rather than complete 60-second event coverage.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 right, thanks for checking. In the five runs whose worker buffers filled at about 37 s, the Shader.PrepareArtifact sums in my table cover only the events before that point, not the whole 60 s window. So those per-call numbers are partial-window figures, as you say. Next time I'll use a shorter window (or a larger event buffer) so a capture doesn't drop events.

AI-assisted: yes (Claude Code)

milescoviello and others added 3 commits October 29, 2026 21:17
Every IR value keeps a vector of the instructions that read it, and
each one grows by reallocating on the heap. A program's values all
die with the program, so their use lists are now drawn from a bump
arena the program owns: growth is a pointer bump and freeing is
dropped. Values built outside a program keep the heap allocator, and
copies of a use list go back to the heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts arena

A program kept in a SourceEntry held its use-list arena until the entry
was destroyed, so the buffers of values ReclaimUnusedValues dropped, and
the buffers every use list outgrew, stayed allocated for as long as the
program was cached. Before a program is cached, ReleaseUseArena now
copies each value's use list into a heap vector and frees the arena.
Values created after that draw from a new arena.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, changes requested

The two latest code commits are not covered by the performance and focused-test evidence currently reported for older heads.

What I ran

Reviewed exact PR head 6a98793e3b32994bd9f5481f37e925fc6af18a1b, whose GitHub base is 951f374c8716fd69f7241a936fb944ca0e8bf354; current upstream main is 9624d8c6bb9e96b7aa92b815f55690f69b0a88d5. The current-main merge preview is clean. Environment: Linux x86-64, Git and GitHub CLI; no compiler or build was used.

git diff --check fd9b3f62d43d6753d28a31a7c285e1f51e9c1b42..refs/review/pr-12039-head
git merge-tree --write-tree 9624d8c6bb9e96b7aa92b815f55690f69b0a88d5 refs/review/pr-12039-head
git rev-list --count 951f374c8716fd69f7241a936fb944ca0e8bf354..9624d8c6bb9e96b7aa92b815f55690f69b0a88d5

I read the exact-head diff, latest PR description/comments, and hosted check statuses. Reported benchmarks and focused test runs are author-provided; I did not rerun them.

Results

Check Result
Patch whitespace Pass
Merge preview onto current main Clean; tree 19f6a2f34262f608a3cf0b39c07cad9ab2288176
Base freshness PR base 951f374c8716; current main 9624d8c6bb9e, 13 commits ahead
Hosted Windows, Ubuntu/Windows relinker, relinker-asan, conventions, eligibility, labels, report Pass on exact head
Hosted macOS relinker jobs Queued
Hosted Linux product, write-watch, register-context jobs Skipped
Focused tests and performance evidence The description reports runs on 1d9eaeaa89 and 3d427e3e32; neither is the current head 6a98793e3b. The current head adds c01d0bb24f and 6a98793e3b, including the cached-program arena release and the IrValue size update. I found no exact-head matched performance result or focused-run report for those changes.
Local build/tests Not run
Unedited local command output
exit=0
19f6a2f34262f608a3cf0b39c07cad9ab2288176
merge-tree-exit=0
main-base=9624d8c6bb9e96b7aa92b815f55690f69b0a88d5
pr-head=6a98793e3b32994bd9f5481f37e925fc6af18a1b
main-advance-commits=13

Findings

Blocking

  • This performance PR's reported measurements and focused test runs do not cover its submitted head. The latest two commits change where cached programs' use lists are stored and update the IrValue size assertion; those changes can affect the performance and memory behavior being reported. Please rerun the relevant focused tests and matched replay comparison on exact head 6a98793e3b and a current-main baseline.
  • The PR base remains 951f374c8716, while current upstream main is 9624d8c6bb9e. The merge preview is clean, but the repository requires branches to be based on and kept up to date with current main; this exact integration has not been tested by the reported runs.

I found no additional source-level defect in the reviewed diff.

Sources

Not verified

  • I did not independently run the focused IR/AGC tests, replay benchmark, SPIR-V comparison, ASan tests, or title captures.
  • The macOS relinker jobs remain queued; the listed Linux product and specialized jobs were skipped. The Windows hosted job passed on the exact head.

To get this to a good state

Update the branch onto current main, then rerun the focused tests and matched replay benchmark on the resulting exact head and current-main baseline; update the PR report with both exact revisions and results. I will recheck that head and repeat the non-build checks above.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 exact-head evidence for 6a98793e3b, which includes c01d0bb24f and 6a98793e3b. All of it is on the merge with current main dc38224141 (merge preview b0bf86ca7d, clean), built from those exact revisions. Linux, GCC 15.2, Release, SPIRV-Tools off.

  • Focused tests: shader_ir_use_rewrite, agc_ir_reclaim, agc_constant_select, agc_masked_select and agc_validate_program pass 3 of 3.
  • SPIR-V equivalence: agc_shader_replay --spv over the same corpus as before gives byte-identical modules on main dc38224141 and on the merge. That's all 65 Crimson Desert modules (152 requests) and all 302 MXGP modules (305 requests).
  • Timing: perf stat -e task-clock of agc_shader_replay --spv over all 457 requests, 10 rounds, alternating which build runs first, each in a fresh directory with ANYPS5_NO_SHADER_CACHE=1:
    • Mean task-clock is 26.43 s on main and 19.85 s on the merge, −24.9 %. The merge is lower in all 10 rounds, by 24.4 % to 25.6 %.
    • Median max RSS is 1,370,986 KB on main and 1,392,566 KB on the merge.

This is a different workload from the table in the description, which timed --prepare over the Crimson Desert subset only. This one includes SPIR-V emission, over both titles. I've added it to the description as the exact-head result.

AI-assisted: yes (Claude Code)

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 6a98793 merged onto main 76fd1c0 · tested 2026-10-30 02:50 UTC · 23 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,263 passed · 3 failed (0 new, 2 also fail on main, 1 unstable on main) · 41 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,307 of 2,949 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (862 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_bda_device 54.3 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_submit_progress: failed in 5 of the last 7 main runs
Failing on main too (2, not counted against this PR)
guest_mmap_executable
guest_socket_options_multicast
Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_job_manager_compute_capacity: Failed in the parallel run; also passed only on retry in 68 other runs in the last 7 days
Validation IDs already present on main (4 IDs in 390 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (390 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_array_layer_target_cpu, agc_driver_bda_span_reads_draw_pipeline, and 382 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (41)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or plat
Reproduce
git fetch origin 6a98793e3b32994bd9f5481f37e925fc6af18a1b 76fd1c09e9be0465d50a7431a79d371a5a10abb2
git checkout 76fd1c09e9be0465d50a7431a79d371a5a10abb2 && git merge --no-ff 6a98793e3b32994bd9f5481f37e925fc6af18a1b
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated 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.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, changes requested

The new report adds useful replay and focused-test evidence, but it is based on an older main snapshot that has since changed a production file this PR also edits.

What I ran

Reviewed head 6a98793e3b32994bd9f5481f37e925fc6af18a1b; the author’s reported comparison base is dc38224141e0b6096007b876b4c42fc9144d11b8, while current main is 5ecef095b61e7a406b279c97896f3a8a6fbd6353. The current-main merge preview is clean (tree 04bb80575c5ba2585a7d094cb9c4331ee46bbea4), but shared paths changed since the report base include core/shader/recompiler/Recompiler.cpp, which this PR also changes.

git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/upstream/pr-12039
git diff --check refs/remotes/upstream/main...refs/remotes/upstream/pr-12039
git diff --unified=4 dc38224141e0b6096007b876b4c42fc9144d11b8..refs/remotes/upstream/main -- core/shader/recompiler/Recompiler.cpp

Results

Check Result
Current-main merge preview Clean
Diff check Passed; no output
Hosted conventions and Windows Passed
Focused tests and replay timing Author reports 5 focused suites 3/3, byte-identical SPIR-V for 457 requests, and a 10-round replay task-clock reduction; not independently run
Current-main qualification Not reported; the comparison uses dc382241

Findings

Blocking

  • The current-main change in Recompiler.cpp is outside the PR’s reported test/benchmark base, so the reported qualification does not cover the exact integration under review.
  • The PR is labeled perf. The replay timing is useful evidence for agc_shader_replay --spv, but the PR still needs the performance-report evidence required by the repository for the claimed change, or a maintainer decision that this tool-only measurement satisfies that requirement.

Not verified

I did not run a local build, replay benchmarks, tests, or GPU validation. The figures above are author-reported.

To get this to a good state

Please rebase or merge current main and rerun the focused tests and replay comparison on the exact resulting head. Please also attach the required matched performance-report artifacts, or record the maintainer’s accepted equivalent. I’ll re-check the same paths and commands on the new head.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 main is merged in: the head is now 0fe2329ee8 (6a98793e3b plus main 422f96b3a9, no conflicts). I reran on that exact head, built from these revisions:

  • The five focused suites pass 3 of 3.
  • agc_shader_replay --spv gives byte-identical SPIR-V to main 422f96b3a9 for all 65 Crimson Desert and 302 MXGP modules.
  • Ten alternating task-clock rounds: 26.61 s on main and 19.83 s on this head (−25.5 %), lower in 10 of 10.

On the performance report: this is a CPU-only IR allocation change with byte-identical SPIR-V. @oneandonlydean accepted replay timing in place of title captures for changes of that kind on #9132 and #9198, and the description now says so, with the earlier supplementary Super Meat Boy 3D captures kept below.

AI-assisted: yes (Claude Code)

@MarcZX10

Copy link
Copy Markdown
Contributor

Re-checked — new head, changes requested

The new report covers head 0fe2329ee8 against main 422f96b3a9, but current main adds a change to the same SSA read path, so the reported tests and timing do not yet qualify the current integration.

What I ran

Reviewed exact head 0fe2329ee8ecd8ad9c726c68f30d6f83733b68c2 against current main 88e2d98f49c949380b45c9cfa266687e28d4443c; the merge preview is clean (fc52466a29bbebd6f3f2c8a20606d5be3bb440cd). Environment: Linux x86-64; no local build, CTest, replay, or benchmark run.

git diff --check upstream/main...refs/reviews/pr-12039-current
python3 tools/check_conventions.py --base upstream/main --head refs/reviews/pr-12039-current
python3 tools/check_main_sync.py --base upstream/main --head refs/reviews/pr-12039-current
git merge-tree --write-tree upstream/main refs/reviews/pr-12039-current
git diff 422f96b3a92e797c5f69c136c4a394c8da672556..upstream/main -- core/shader/recompiler/Optimization/src/SsaBuilder/SsaPass.cpp

Results

Check Result
Diff check Passed; no output
Conventions Passed; All conventions checks passed.
Current-main merge preview Clean; tree fc52466a29bbebd6f3f2c8a20606d5be3bb440cd
Main synchronization Clean merge; PR is 4 commits ahead and 159 behind current main, with merge base 422f96b3a
Changed-path integration Current main adds an SSA definition-cache fast path in SsaPass.cpp; the author’s matched performance/test baseline is 422f96b3a, before that change
Author-reported exact-head tests and timing Five focused suites pass 3/3; SPIR-V is byte-identical for 457 requests; replay timing is reported 10 rounds lower in all 10. These compare head 0fe2329 with base 422f96b3; I did not reproduce them.
Hosted checks Eligibility and report passed; conventions, labels, Windows, and relinker jobs pending; Linux and specialized jobs skipped
Relevant command output
All conventions checks passed.
refs/reviews/pr-12039-current is 4 ahead and 159 behind upstream/main (merge base 422f96b3a)
merge: clean

Findings

Blocking

  • Current-main test and performance comparison is missing. The PR is a performance change. The author’s latest run is useful exact-head evidence, but its baseline is 422f96b3a; current main 88e2d98f adds a shortcut to Pass::Read in SsaPass.cpp, a hot path exercised by this change’s workloads. Please rerun the focused suites and the matched replay comparison on current main and the exact PR head merged with current main. Report the exact commits and preserve the existing performance report requirements or document the maintainer-accepted equivalent for this CPU-only compiler change.

Non-blocking

  • The current-main merge preview is clean. No local build, tests, replay, or performance measurements were run; the new numerical results are author-reported.

Sources

Not verified

I did not independently run the focused C++ tests, SPIR-V comparisons, or benchmarks. No current-main hardware or title run was performed by me. Current hosted Windows/relinker checks are pending.

To get this to a good state

Run the same focused tests and replay comparison with current main and the exact current integration, then update the report with the two commit IDs and results. I will recheck the exact new head and repeat the non-building checks above.

@adriadam10
adriadam10 merged commit d998343 into boykopovar:main Oct 30, 2026
14 of 15 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked on head 0fe2329ee8: the production diff is unchanged from 6a98793e3b (only main merged in). ReleaseUseArena() runs before source->program is stored, the IrReclaim case fails without it, and the ShaderDiskCache.cpp:109 size check is 144, matching IrValue with #11820's operands plus the allocator pointer. The SsaPass.cpp read shortcut on main doesn't touch use lists or their allocation, and SPIR-V is byte-identical on the reported replay; the merge queue's full Build covers the exact integration; merged.

Celegans12 pushed a commit to Celegans12/AnyPS5-Ghost-of-Yotei that referenced this pull request Oct 31, 2026
Main's boykopovar#12039 grows IrValue to 144 bytes next to this branch's
IrResourcePlan of 752 bytes in ShaderDiskCache.cpp's size asserts.
Each side changed only its own struct, so the merge keeps both values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* perf Performance change shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants