Repository navigation
perf(shader): do not memoize donor-patched results - #16234
Conversation
A draw that is patched from a masked-memo donor is recompiled cheaply from its donor, and only about 1% of such results are ever hit again. Inserting each one into the exact result memo cost a resultBytes walk, insert and eviction bookkeeping, and a free of the evicted result inside the source mutex, while holding tens of thousands of results. Return the patched result without inserting it.
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, Radeon RX 6700 XT, AMD driver 26.10.1, through the Windows test queue with
AI-assisted: yes. |
|
This pull request is labeled |
❌ NVIDIA GPU test: failedPR head
Failing testsThis PR changes test files, so each failing test was also built and run on main with only the PR's test changes applied. ✅ there means the failure comes from the PR's other changes; ❌ means the test fails on main too, so this run does not show the PR caused it.
agc_driver_prepared_shaders: Failed (also failed when re-run alone), assertion and diagnosticsUnstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validation IDs already present on main (9 IDs in 585 tests)Skipped (51)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
Perf numbers from another title for the label: METAL GEAR SOLID 4 (PPSA18194) at its title screen, which issues about 430k to 535k draw packets per 10 s window. Setup: Linux 7.0, RTX 4070 Ti, NVIDIA 615.71.09, i7-13700K, Release.
Last result memo line of each run:
So here too the exact-memo hits go away, and recompile time per packet drops by about 40%. The title screen is capped at 60 fps on both arms (queue 0's worker is 94% to 97% busy), so I'm not claiming an fps change. I didn't capture traces. One summary line from each arm, the 100 to 110 s window of a main and a PR run ( aps5-summary.jsonl linesAI-assisted: yes (Claude Code) |
|
Looked into the one new NVIDIA CI failure: it is The two structures the layer rejects are What I cannot explain from the logs is the arm split for this one test: with identical tests, identical pNext-building code and the same container, AI-assisted: yes |
|
Follow-up on the arm split from my comment above: it is not environment drift — the failure reproduces on Linux/RADV, and it is behavioral. Setup. CachyOS x86-64, AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.5, Vulkan 1.4.363 loader with Khronos validation layer 1.4.363 ( Results.
So removing the insert for donor-patched results regresses the prepared-shaders invariant on both vendors: a prepared invocation now rebuilds an unchanged materialized result. The exact-memo insert this PR removes appears to be what the prepared path relied on to avoid that rebuild, so this needs a fix (or a follow-up draft reconciling it with #10757) before merge. AI-assisted: yes |
|
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.
|
The tests check that a prepared invocation returns the same result object for an unchanged capture. Donor-patched results are no longer inserted in the exact memo, so with a masked donor present that check cannot hold; the tests now run without the masked memo, as the result memo budget tests do.
What
materializePreparedMemoizedno longer inserts a donor-patched shader result into the exact result memo. A draw that is served by patching a masked-memo donor returns the patched result directly; the donor copy and the patch are unchanged. About 97-99% of in-level draws take the patched path and only 0.2-1.4% of lookups hit the exact memo, so each patched result was sized, inserted and later evicted (freed undersource.mutex) for almost no reuse.Related drafts touching the same function: #10757 reuses an evicted result's storage for the next patched result, and #12828 sizes the result memo from host memory. This change removes the insert (and so the eviction) for patched results instead, so it overlaps #10757 in
materializePreparedMemoized.agc_shader_result_memo_budget_maskedasserted that a patched result is counted in the memo; it now asserts that it is not inserted.Tested
Linux, RTX 4090 (NVIDIA 610.57.04), PPSA21564 rocket_space_station, same machine and scene, three paired runs of 180 s with the arm order rotated,
APS5_PROFILE_DRAW=1on both arms. In-level draw windows only (at least 1000 draw packets per 10 s window).Last in-level result memo line of run 2 (10 s):
1.4% hits, 97.7% patched, 246333 evictions, 45920 results held, 191.6 MiB0.2% hits, 99.3% patched, 1291 evictions, 8932 results held, 45.3 MiBThe exact-memo hit rate drops because patched results are no longer kept, so a repeat of one is patched again (patch is about 1.2 us). In-level fps is within noise in every arm (about 4-5 fps), so no fps claim is made. Total us/packet differs between runs because the draw load differs.
APS5_VERIFY_MASKED_RESULT_MEMO=1agc ctests pass andtools/check_conventions.pypasses. Not tested on Windows or on other GPUs.Checklist
main; the overlapping drafts perf(shader): reuse an evicted result's storage for the next patched result #10757 and perf(shader): size the result memo from host memory #12828 are named aboveNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)