Skip to content

perf(shader): keep up to three IR operands inside the value - #11820

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
milescoviello:perf/ir-inline-operands
Oct 29, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
milescoviello:perf/ir-inline-operands

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

Every IR value keeps its operands in a std::vector<IrValue*>, which the constructor reserves to the opcode's operand count. So almost every value makes a second heap allocation, and each operand read follows a pointer away from the value itself.

This change replaces the vector with IrOperands. It holds up to three operands inside the value and moves to a heap array only when a value gets more, for example a phi with many predecessors.

On 152 Crimson Desert (PPSA25286 01.000.568) shader requests:

All 65 Crimson Desert and 302 MXGP 26 (PPSA30839 01.003.000) SPIR-V outputs are byte-identical.

How

IrOperands (in IrValue.hpp):

  • Layout: a 32-bit size, a 32-bit capacity, and a union of three inline pointers with a heap pointer. It is 8 bytes larger than the vector it replaces (IrValue goes from 128 to 136 bytes) and needs no allocation for up to three operands.
  • Growth: past three operands, it allocates an array of the requested size and doubles from there. It frees that array on destruction.
  • Interface: size, empty, begin/end, operator[], at, front, back, push_back, reserve, clear, and assignment from the vector SetDetachedOperands takes. That covers every use of Arguments(), which only iterates, indexes or copies the operands into a vector.

IrValue::Arguments() now returns const IrOperands&. Nothing else changes: same operand order, and the same use lists, IDs and dumps.

ShaderDiskCache.cpp asserts sizeof(IrValue) as a reminder for the plan value encoder. The encoder writes operands one at a time through ArgumentCount() and Arguments(), so the disk format doesn't change; only the asserted size moves to 136.

Where the time goes: one DWARF profile per side (perf record --call-graph dwarf -F 199, same input) shows:

  • Samples fall from 3451 to 2956.
  • Allocator functions fall from 861 to 753.
  • IrValue accessors fall from 482 to 355. For example, Argument drops from 28 to 6 and HasUses from 169 to 115.

The operands now sit next to the rest of the value.

Tested

Linux, i7-13700K, GCC 15.2, Release with ANYPS5_ENABLE_SPIRV_TOOLS=OFF. I built cmake --build build-rel --target agc_shader_replay at main 1392606, at this change, and at this change merged with #11798.

Round Order main (ms) this PR (ms) change #11798 (ms) both (ms) main RSS (KB) this PR RSS (KB)
1 main, #11798, this, both 15568 12563 -19.3 % 12716 10479 271348 264896
2 both, this, #11798, main 15712 12526 -20.3 % 12888 10425 271492 264200
3 this, main, both, #11798 15715 12784 -18.6 % 12976 10518 271736 264144
4 #11798, both, main, this 15726 12919 -17.8 % 12794 10469 271332 263808
5 main, #11798, this, both 15860 12805 -19.3 % 12896 10509 271804 263840
6 both, this, #11798, main 15840 12878 -18.7 % 12916 10529 271568 263452
7 this, main, both, #11798 16014 12822 -19.9 % 12864 10592 272060 263644
8 #11798, both, main, this 15775 12638 -19.9 % 12983 10472 270948 263180

Means over the 8 rounds:

Build CPU time vs main Mean max RSS
main 15.78 s (SD 0.13) — 271.5 MB
this PR 12.74 s (SD 0.15) −19.2 % 263.9 MB
#11798 12.88 s −18.4 % 269.5 MB
both 10.50 s −33.5 % 263.0 MB

This PR is lower than main in all 8 rounds. The binaries' sha256 prefixes are 50c1220f47cc (main), c78ab132d352 (this PR) and 576b021a843d (both). These numbers use glibc's allocator, which titles use on Linux; I haven't measured Windows' default heap.

  • Tests: I ran the 19 AGC test targets whose sources use IrProgram (the same set as perf(shader): allocate a program's IR values in chunks #11798, 20 ctest entries) and agc_shader_disk_cache_tests (7 entries), because of the size assert. Each passes 3 of 3 (--repeat until-fail:3) on an RTX 4070 Ti (NVIDIA 615.71.09) at this head. This PR also extends agc_ir_reclaim:

    • a value with seven operands, checking each operand and its use;
    • ReplaceArgument on heap-stored operands;
    • SetDetachedOperands with five operands;
    • a reclaim that must remove exactly the detached value and the operand that lost its last use, leaving the live value's operands intact.

    On Windows 11 (WinLibs GCC 15.2, Release, GT 1030 with NVIDIA R580), the same 26 ctest entries pass 3 of 3 at this head and at its base 13926067ac. Under AddressSanitizer (ANYPS5_ENABLE_ASAN=ON, RelWithDebInfo), agc_ir_reclaim, including the new grown-operand cases, and agc_validate_program pass 3 of 3 at this head with no ASan report.

This is a CPU-only shader-compilation change with byte-identical SPIR-V, like #11719, #9132 and #9198. It therefore uses the paired CPU replay that oneandonlydean accepted for those (#11719) instead of title captures.

Rebased head e339f57e4d (on main ca0e9557aa), after review:

  • agc_shader_memory's compaction check now asserts Arguments().capacity() == max(ArgumentCount(), IrOperands::InlineCapacity), meaning no spare heap operand storage. SetDetachedOperands gives detached operands exactly the storage they need, as the vector it replaced did.
  • I built all 46 test targets whose sources use the IR API (Arguments(), OperandUses(), the IR value types), agc_shader_memory_tests and agc_ir_reclaim_tests included. All 75 of their ctest entries pass 3 of 3 (--repeat until-fail:3) on an RTX 4070 Ti, the 7 disk-cache entries among them.
  • AddressSanitizer: agc_ir_reclaim, agc_validate_program and agc_shader_memory pass 3 of 3 with no report.
  • Against main's agc_shader_replay rebuilt at the same base ca0e9557aa, all 65 Crimson Desert and 302 MXGP 26 SPIR-V outputs are byte-identical. Four alternating --prepare rounds give 15.59/15.72/15.59/15.39 s for main and 12.54/12.91/12.40/12.57 s for this PR (means 15.57 and 12.61 s, −19.0 %).
  • Windows 11 VM, rebased head: queued; I'll add the result.

Merge order

Title captures: Super Meat Boy 3D, main 9af563f33d + #11580 (608dd76843) against the same + this PR (4f3d1e1d88), 5 interleaved rounds, recompiler cache off. Shader.PrepareArtifact worker time over each run's first 400 worker artifacts is 8,696 ms → 7,335 ms (-15.6 %, lower in 5 of 5) and title-thread time over the first 350 is 5,781 ms → 5,337 ms (-7.7 %, 4 of 5); over the whole window, leaving out rounds 2 and 4 where the PR run reached a later scene, workers are 12,018 ms → 10,397 ms (-13.5 %) (table and traces). Round 3'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":60083.567},"presents":410,"frame_ms":{"p50":130.925,"p90":145.249,"p99":1415.722,"max":4010.583},"gpu_busy_ms_per_present":90.480,"worker_busy_pct":{"queue worker 0x0":86.259,"queue worker 0x20":83.401},"top_phases_ms_per_frame":{"Driver.Packet":248.556,"Driver.Packet.memory_wait":122.360,"Driver.Packet.dispatch":57.426,"Driver.Dispatch":57.237,"Driver.Packet.pipeline_drain":43.140,"Shader.PrepareArtifact":42.567,"Recorder.Sync":40.107,"Graphics.Draw":34.456},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.507,"events_lost":311938,"totals_full":false}},"trace":"aps5-trace-608dd7684303-3.json.gz"}
{"commit":"4f3d1e1d888f","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":60041.991},"presents":416,"frame_ms":{"p50":127.514,"p90":145.863,"p99":1424.379,"max":3983.692},"gpu_busy_ms_per_present":88.201,"worker_busy_pct":{"queue worker 0x0":86.397,"queue worker 0x20":84.361},"top_phases_ms_per_frame":{"Driver.Packet":246.394,"Driver.Packet.memory_wait":121.039,"Driver.Packet.dispatch":58.239,"Driver.Dispatch":58.088,"Driver.Packet.pipeline_drain":40.545,"Recorder.Sync":39.036,"GpuMutex.wait.hook":37.480,"Shader.PrepareArtifact":36.561},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.199,"events_lost":334373,"totals_full":false}},"trace":"aps5-trace-4f3d1e1d888f-3.json.gz"}

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: perf(shader): define IrValue's trivial accessors in its header #9132 (textual overlap in IrValue.cpp; it lands first and this PR rebases onto it)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 4070 Ti (Linux, 615.71.09) for the AGC tests; the replay itself is CPU-only
  • AI-assisted: yes

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

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

Requesting changes: the current IR API change breaks the existing AGC shader-memory test. In core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:759, agc_shader_memory_tests calls value.Arguments().capacity(). The new IrOperands type has no public capacity() method; its capacity field is private. I reproduced the compile error against the exact PR header with GCC 12.2: the call resolves to the private uint32_t field and cannot be invoked as a function. CMake includes ShaderMemory.cpp in agc_shader_memory_tests and registers that target for BUILD_TESTING, so this prevents the target from compiling. Please update the compaction assertion to express the intended no-spare-heap-storage invariant for inline operands, or provide a suitable public API and adjust the assertion for inline capacity, then rerun this target at the exact updated head. The hosted relinker jobs do not compile this target, and the full product jobs are skipped, so current green/pending checks do not cover the failure.

@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 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5609 core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6280 core/shader/recompiler/ShaderDiskCache.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6924 core/shader/recompiler/ShaderDiskCache.cpp
PR 6959 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 6970 core/shader/recompiler/ShaderDiskCache.cpp
PR 7085 core/shader/recompiler/ShaderDiskCache.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 7689 core/shader/recompiler/ShaderDiskCache.cpp
PR 8004 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9020 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9335 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9748 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9889 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 10049 core/shader/recompiler/ShaderDiskCache.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 10233 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 12132 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12662 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, you're right. I only built the 19 targets plus the disk-cache test, and agc_shader_memory_tests wasn't among them. Fixed in 8e813345e7:

  • IrOperands now has a public capacity() and an InlineCapacity constant (3). The private field is renamed allocated, so capacity is no longer ambiguous.
  • ShaderMemory.cpp:759 now asserts value.Arguments().capacity() == std::max(value.ArgumentCount(), IrOperands::InlineCapacity), with the message "spare heap operand capacity". That's the compaction invariant once small operand lists live inline. Plan values are built through SetDetachedOperands, which reserves exactly the operand count, so a plan value with more than three operands has no spare heap slots, and one with three or fewer uses no heap at all.

To catch anything else that compiles against this API, I've queued a build of every test target whose sources use Arguments(), OperandUses() or the IR value types. That's 46 targets, agc_shader_memory_tests included, at this head, with each ctest entry run 3 times. I'll post the results here and update Tested.

AI-assisted: yes (Claude Code)

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@milescoviello one blocker: agc_shader_memory_tests no longer builds. core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:759 calls value.Arguments().capacity(), and IrOperands has no public capacity() (its storage is also never below the three inline slots).

Could you restate that plan-compaction check for IrOperands, keeping what it asserts (compaction leaves no unnecessary heap operand storage), either through the new representation or a small public inspection API? Please add agc_shader_memory_tests to the tests you run, keep the inline and grown-operand coverage, and paste the result together with the existing IrReclaim and disk-cache tests on the corrected head. The disk-cache encoding should stay unchanged.

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

Follow-up review of the updated head 3c6629017d1c3ffe96b0c5c037a3cac20913075f: the earlier compile issue I found (Arguments().capacity() missing on the new type) appears addressed by the new public capacity() and the inline-capacity-aware assertion. The updated Windows/product and relinker CI jobs are still pending, so I cannot yet verify the fix in the project targets.

Three repository requirements still block approval:

  1. This is titled perf(shader) and carries the perf numbers missing label. The report contains useful replay timings and allocator data, but not the required two valid aps5-summary.jsonl lines from different commits or the attached traces described by the Performance report form. Please add that required evidence or have maintainers record an applicable exception.
  2. The branch base is 5bc84038c490a0427ff272e39e2a1cdf6fdc3c0e, while current main is 801d5b9bc11049e6274daca09d70690bd5b8d0a9. Rebase/update to current main and rerun the affected tests.
  3. The body identifies overlap with open #9132 and #7689, but says either can land second and leaves Depends on: none. CONTRIBUTING asks authors to agree with the overlapping PR authors on landing order and declare the dependency. Please record the agreed order and update the checklist.

I did not run the full shader build or tests locally. I am requesting changes for the missing performance evidence, stale base, and unresolved overlap order; the earlier API compile finding appears fixed, but the current CI run has not completed.

milescoviello and others added 3 commits October 27, 2026 11:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…luded

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello
milescoviello force-pushed the perf/ir-inline-operands branch from 3c66290 to e339f57 Compare October 27, 2026 11:43
@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, taking these in order.

  1. Performance evidence: this is a CPU-only change to shader compilation, and the SPIR-V is byte-identical. That's the class oneandonlydean accepted paired replay timings for instead of title captures (perf(shader): define IrValue's trivial accessors in its header #9132 and perf(shader): validate value IR dominance with a dominator tree #9198, re-confirmed for perf(shader): reuse the evaluator's requirement list across values #11719 in this comment). @oneandonlydean, could you record whether that exception covers this PR too? If it doesn't, I'll add title captures. My usual compile-bound title, Crimson Desert, currently stops 1 s after launch on main (sceHttp2SendRequestAsync, see feat(http2): complete asynchronous send and read #11630), so I'd use another title.
  2. Base: rebased onto current main (ca0e9557aa); the head is now e339f57e4d. I'm rerunning everything on that head: the 46 test targets whose sources use the IR API (75 ctest entries, 3 runs each, agc_shader_memory included), AddressSanitizer for agc_ir_reclaim, agc_validate_program and agc_shader_memory, and SPIR-V equivalence against main's replay binary rebuilt at the same base. I'll post the results here.
  3. Order:

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 @oneandonlydean results on the rebased head e339f57e4d (main ca0e9557aa), now in Tested as well:

  • The 46 test targets that use the IR API, agc_shader_memory_tests, agc_ir_reclaim_tests and the disk-cache tests included: all 75 ctest entries pass 3 of 3 on an RTX 4070 Ti (NVIDIA 615.71.09, Linux, GCC 15.2). The first run at 8e813345e7 did fail agc_shader_memory at runtime, on its own compaction check. The IrValue constructor reserves the opcode's operand count, and SetDetachedOperands kept that reservation where the old vector move replaced it. e339f57e4d now gives detached operands exactly the storage they need, so plan values keep no spare heap storage again.
  • AddressSanitizer: agc_ir_reclaim (with the inline and grown-operand cases), agc_validate_program and agc_shader_memory pass 3 of 3 with no report.
  • SPIR-V: against main's replay binary rebuilt at the same base, all 65 Crimson Desert and 302 MXGP 26 outputs are byte-identical. Four more timing rounds give −19.0 %, in line with the earlier 8.
  • Disk-cache encoding: unchanged. Only the sizeof(IrValue) reminder moved to 136, because the encoder writes operands one at a time.
  • Order: Depends on: #9132 is set, and the fix(shader): defer guarded fragment V# type faults #7689 order is agreed (whichever of the two lands second keeps both assert values). Both are recorded in the body.

The Windows VM rerun on the rebased head is queued. The perf-evidence question is still with oneandonlydean.

AI-assisted: yes (Claude Code)

@milescoviello

milescoviello commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Setup

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

Run Title thread Prepare workers Worst frame
main 1 2,547 / 604 = 4.22 ms 2,500 / 676 = 3.70 ms 1,555 ms
main 2 2,606 / 617 = 4.22 ms 2,403 / 678 = 3.54 ms 1,477 ms
main 3 5,156 / 896 = 5.75 ms 2,337 / 659 = 3.55 ms 1,427 ms
this PR 1 2,359 / 603 = 3.91 ms 2,463 / 646 = 3.81 ms 1,455 ms
this PR 2 2,298 / 598 = 3.84 ms 2,291 / 637 = 3.60 ms 1,431 ms
this PR 3 4,999 / 911 = 5.49 ms 2,313 / 661 = 3.50 ms 1,390 ms

The in-title effect is small:

  • Title thread: 4.5–9 % less per artifact, lower in all three pairs.
  • Worst frame: the boot shader-preparation hitch is 2.6–6 % shorter, also in all three pairs.
  • Prepare workers: within ±3 % per artifact. I can't call that a change.
  • Not claimed: present counts and p90/p99 vary with the scene, so there's no frame-rate claim.

That's well below the replay's −19 %. I haven't profiled where the rest of a prepared artifact's time goes in the title.

Summary lines of the first pair (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":150026.262},"presents":2233,"frame_ms":{"p50":16.694,"p90":190.971,"p99":240.998,"max":1554.838},"gpu_busy_ms_per_present":18.850,"worker_busy_pct":{"queue worker 0x0":77.302},"top_phases_ms_per_frame":{"Driver.Packet":51.240,"Driver.Packet.draw":32.070,"Driver.Draw":31.825,"Graphics.Draw":26.670,"Graphics.Draw.draw_and_resource_release":24.985,"VideoOut.Flip":14.507,"Driver.Draw.shader_compile_and_link":14.251,"Shader.ResolveAbi":12.980},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":95.466,"events_lost":79253,"totals_full":false},"queue worker 0x0":{"events_full_after_s":25.447,"events_lost":2863844,"totals_full":false},"draw committer":{"events_full_after_s":65.833,"events_lost":509726,"totals_full":false}},"trace":"aps5-trace-ed3b6566a2c6-3.json.gz"}
{"commit":"789b0a598ee2","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":150013.049},"presents":2140,"frame_ms":{"p50":16.708,"p90":189.083,"p99":245.821,"max":1454.636},"gpu_busy_ms_per_present":19.757,"worker_busy_pct":{"queue worker 0x0":76.717},"top_phases_ms_per_frame":{"Driver.Packet":53.081,"Driver.Packet.draw":34.310,"Driver.Draw":34.053,"Graphics.Draw":28.711,"Graphics.Draw.draw_and_resource_release":26.993,"Driver.Draw.shader_compile_and_link":15.306,"VideoOut.Flip":14.234,"Shader.ResolveAbi":13.636},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":92.336,"events_lost":83588,"totals_full":false},"queue worker 0x0":{"events_full_after_s":25.917,"events_lost":2898901,"totals_full":false},"draw committer":{"events_full_after_s":64.463,"events_lost":495402,"totals_full":false}},"trace":"aps5-trace-789b0a598ee2-3.json.gz"}

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

Title captures for this change, with the same setup as the captures on #12039. The base is 608dd76843, which is main 9af563f33d + #11580: Super Meat Boy 3D needs #11580 to run past 11 s on main. The comparison is with this PR (head e339f57e4d) merged on top of it (4f3d1e1d88).

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 5 rounds alternating which side goes first. Rounds 4 and 5 used a second build of the same merge (abf1c66996, same tree as 4f3d1e1d88). 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,456 / 496 10,414 / 498 6,694 / 393 5,473 / 375
2 (PR first) (excluded) 11,844 / 483 20,970 / 598 6,476 / 381 6,185 / 450
3 (main first) 11,737 / 487 9,898 / 488 5,714 / 389 5,310 / 386
4 (PR first) (excluded) 12,983 / 501 19,373 / 634 6,021 / 384 7,097 / 542
5 (main first) 11,861 / 488 10,878 / 502 5,230 / 399 5,421 / 389
mean without rounds 2 and 4 12,018 10,397 (-13.5 %) 5,879 5,401 (-8.1 %)

The PR runs in rounds 2 and 4 reached a later scene. They prepared 598 and 634 worker artifacts against 483 to 502 in the other eight runs, so their window totals don't measure the same work, and the mean above leaves those two rounds out.

The same boot work, each run's first 400 worker artifacts and first 350 title-thread artifacts by start time, covers all 5 rounds (total ms):

Round main workers this PR workers main title thread this PR title thread
1 (main first) 8,910 7,441 6,436 5,332
2 (PR first) 8,895 6,991 6,337 5,490
3 (main first) 8,777 7,116 5,403 5,116
4 (PR first) 8,819 7,903 5,812 5,530
5 (main first) 8,078 7,225 4,920 5,218
mean 8,696 7,335 (-15.6 %) 5,781 5,337 (-7.7 %)

Workers are lower in all 5 rounds and the title thread in 4 of 5.

The summary lines of round 3:

{"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":60083.567},"presents":410,"frame_ms":{"p50":130.925,"p90":145.249,"p99":1415.722,"max":4010.583},"gpu_busy_ms_per_present":90.480,"worker_busy_pct":{"queue worker 0x0":86.259,"queue worker 0x20":83.401},"top_phases_ms_per_frame":{"Driver.Packet":248.556,"Driver.Packet.memory_wait":122.360,"Driver.Packet.dispatch":57.426,"Driver.Dispatch":57.237,"Driver.Packet.pipeline_drain":43.140,"Shader.PrepareArtifact":42.567,"Recorder.Sync":40.107,"Graphics.Draw":34.456},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.507,"events_lost":311938,"totals_full":false}},"trace":"aps5-trace-608dd7684303-3.json.gz"}
{"commit":"4f3d1e1d888f","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":60041.991},"presents":416,"frame_ms":{"p50":127.514,"p90":145.863,"p99":1424.379,"max":3983.692},"gpu_busy_ms_per_present":88.201,"worker_busy_pct":{"queue worker 0x0":86.397,"queue worker 0x20":84.361},"top_phases_ms_per_frame":{"Driver.Packet":246.394,"Driver.Packet.memory_wait":121.039,"Driver.Packet.dispatch":58.239,"Driver.Dispatch":58.088,"Driver.Packet.pipeline_drain":40.545,"Recorder.Sync":39.036,"GpuMutex.wait.hook":37.480,"Shader.PrepareArtifact":36.561},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":39.199,"events_lost":334373,"totals_full":false}},"trace":"aps5-trace-4f3d1e1d888f-3.json.gz"}

All ten traces, summary lines and tools/trace_digest.py outputs are release assets on my fork: pr11820-smb3d-captures.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot removed the perf numbers missing perf pull request without a before and after summary line label Oct 28, 2026
@adriadam10 adriadam10 self-assigned this Oct 28, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 28, 2026 17:27

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

TheBlenDed pushed a commit to TheBlenDed/AnyPS5 that referenced this pull request Oct 29, 2026
Adapt upstream PR boykopovar#11820 at 3c66290. Keep up to three operands inside each value, retain heap storage for longer lists, and reject capacities outside the 32-bit counters. Update the plan compaction check and IrValue size assertion without changing the wire format. Paired focused validation passes on the saved main and candidate; synthetic SPIR-V is byte-identical. Real Yotei request performance remains unmeasured.
@adriadam10
adriadam10 merged commit c33bb03 into boykopovar:main Oct 29, 2026
25 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the IrOperands growth, assignment and destructor paths, the extended agc_ir_reclaim cases (7 operands, ReplaceArgument, SetDetachedOperands, reclaim), the agc_shader_memory capacity check and the IrValue size assert (disk format unchanged). The points from the earlier review are met on this head: title captures added, rebased onto main, Depends on: #9132 declared. Conventions, relinker and Windows are green; merged.

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