Repository navigation
perf(agc): publish storage-image results into resident heap mirrors - #17796
oneandonlydean merged 6 commits into
Conversation
While a resident heap mirror's run is refreshed, pending storage images overlapping it are no longer stored back to guest memory. Their pending units are retiled on the GPU into the mirror after the shadow flush; blocks the CPU or another store wrote since the unit's generation are left out. Images stay pending, so CPU readers, labels and idle stores behave as before. Unsupported cases fall back to the old store and are counted by reason. APS5_NO_MIRROR_PUBLISH=1 restores the old path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
On the order with #12840 (BDA stores into writable heap mirrors), which conflicts with this PR in The merge calls #12840's #12840's checklist will say |
…images Add a draw-based case to the resident heap mirror tests: an image store deferred into a heap mirror, then a draw that retakes the cached address space (the reuse path). The draw must read the stored value, and the reuse counter must advance by exactly one per draw. Requested in review of the publish-into-mirrors change.
|
This pull request is labeled |
|
Hi @ashwin280802, I pushed two commits to your branch so this can go into a merge batch, without changing your source:
Nothing for you to do; if you push to the branch, pull first. |
|
Hi @ashwin280802, we merged current main into your branch again so it can merge (de3da06). The only conflict was in Graphics/include/Texture.hpp, where main added a |
…er input mirror Recorder: main added CommandClass::InputMirror in the slot this change used for MirrorPublish. MirrorPublish now follows it, with its entry in CommandClassNames, BarrierScopes and BarrierMergedScopes. GuestBufferMemory: main's profile line (growth rebuilds) followed by this change's mirror publish line. ENVIRONMENT.md: both rows kept.
|
Tested on Cyberpunk 2077 (PPSA03974) 02.120.000, the intro movie at 3200x1800, Windows 11 (10.0.26200), RTX 5090 (NVIDIA 617.42), Ryzen 9 9950X3D, WinLibs GCC 15.2 Release. Base: current
About 11% below the boots around it. Single boot; I'll repeat it next session and post the result here. CP77 on Windows has no resident heap mirrors as far as I know, so if this holds it would come from the path itself rather than from publishes. No errors or aborts. |
|
The repeat I promised, on Linux this time: no measurable difference here. The PR runs the Cyberpunk intro within 0.5 % of the boots around it, well inside the spread between boots. Setup: Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 2080 Ti (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release. Base:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the inspected code supports the described resident mirror publication flow, with some edge cases explicitly left unverified.
What I ran
Reviewed head 38ecc79651f123a77d602bce24c2d53f2b803570 using the prepared diff and repo_read.py. No tests or builds were run; the test results in the PR description are author reported.
Results
| Check | Result | Note |
|---|---|---|
| Patch and targeted source review | passed | Main defer and publish paths inspected |
| Tests and build | not run | Author reports test runs |
| Console and other GPUs | not run | Not verified by this review |
Findings
Blocking
None.
Non-blocking
- The PR description identifies untested paths for reused-build publish drains and mirror eviction during the same build, plus array layers, multiple mips, edge blocks, and memo eviction. Add targeted coverage for these cases as the implementation is extended.
Sources
Reviewed GuestBufferMemory.cpp, Texture.cpp, ResidentMirror.cpp, Recorder.cpp, and ResidentHeapMirror.cpp at the pinned head, alongside the prepared diff. The diff adds fallback checks for read traps, DCC state, drawn rectangles, write-watch coverage, pending generations, and writable mirror writes; it also guards publication with mirror serials and refreshes guest changes before recording GPU copies.
Not verified
No build or tests were run. The PR description’s reported test and performance results were not independently verified. Console behavior, other GPU vendors, and the listed untested edge cases were not verified. Full source text for GuestBufferMemory.cpp and Texture.cpp was excluded from the review bundle; targeted ranges were read through repo_read.py. All changed files listed in the manifest were identified, but not every changed file was read in full. Other changed files not listed above were not reviewed in detail.
To get this to a good state
Nothing is required. Optional: add coverage for the untested paths listed in the PR description.
|
Validation-layer run of this PR on an NVIDIA GPU under Linux, since CI covers only lavapipe. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release,
The pattern is the one from the Tested section. The branch is based on No new AI-assisted: yes (Claude Code) |
|
Starting a Windows 007 cross-test of your existing implementation, not a competing PR. Public source-only branch: codex/007-pending-mirror-publication-nov18, head This integration carries #9508 and the #15295/#12827/#15296 prototype, whose existing unchanged-byte redundant-upload assertion still fails. I have preserved that assertion and its failure status, the partial/concurrent CPU-write checks, zero-store test, transfer-wave limits and the removal of slab host copies. The only substantive adaptation to your upload-generation contract records each touched block's serial at its actual GPU copy/fill recording point, since this prototype reads guest memory into transient staging instead of retaining One caller distinction I am checking before extending anything: 007's latest guarded load has one address-based build versus 946,670 per-resource sparse mirror bindings. Windows 11 26200, RTX 5070 Ti/NVIDIA 617.42, GCC 15.2 r7 Release, Vulkan headers 1.4.340, Khronos layer 1.4.363, SPIRV-Tools OFF. Raw title code, logs, captures and traces stay local. AI-assisted. Windows follow-up: the original integration The additional sparse-caller gap is now reproduced and fixed in the same public branch, head
Conventions pass (only the inherited #22072 debt-length warning); no game/FPS result yet. I am preparing a clean child on your exact branch so you can take the small caller fix and its regression without the 007 memory prototype, and will cross-test 007 separately. Raw title data stays local. Clean follow-up is now public: codex/sparse-descriptor-mirror-publication, head Further matched regression gate on the integration: the same ten address-space reuse cases (including heap/stages/transitions) pass three rounds on the canonical provider and three on the sparse-scope provider: 30/30 each, ten actual Khronos insertions per round, no skips, missing layer or VUID/SYNC identifiers. Same fixture and supports; only the graphics provider changes. Packaging relinked the provider, so that exact new artifact was checked again for classic and actual-heap sparse publication and later resident data completion. The original redundant-upload failure remains separate. The guarded 007 run is now active on the packaged integration, same executable and other 417 module hashes, original safeguards and 2048 MiB texture cap. It has rendered the title prompt; there is no gameplay, memory improvement or FPS result yet. No concurrent builds, native GPU tests or replay. Its text-log capture is empty so far, so absence of logged faults is not a success claim. A read-only check of 184 bytes of this hash-verified renderer's own publication counters will establish whether the path is actually used; no title memory or pointers are read. 007 title trial complete: rendered title/offline menu, Resume accepted, then the unchanged free-RAM guard stopped it after 835.013 s total / 86.467 s after queueing Resume. Peak sampled private commitment 29.342 GB, minimum free RAM 1.917 GB, four bounded trims. The text log became available after exit (5.31 MB), with no fatal/unhandled report; the earlier empty-live-log limitation is now resolved for this completed run. All own-publication counter samples remain zero, last at 12:51:11.775 UTC, about 7.44 s before guard exit. Final mirror summary has 1,088,025 sparse bindings, one address-based build, 1112 heap mirrors / 4308.4 MiB. Thus this run does not demonstrate #17796 or the added scope helping 007, despite the synthetic red/green proof. No gameplay, memory reduction or FPS gain claimed. I am preserving the generic six-line fix and clean regression for your review, and moving the title investigation to existing #15297's overlapping joined-mirror work rather than growing this patch speculatively. All guards and title-data privacy remain. |
|
Windows + AMD run; I found no AMD run in the description or in the comments. Head Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (
AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above). |
What
When an address-based build refreshes a resident heap mirror, pending storage images inside it are no longer stored back to guest memory first. Their pending units are retiled on the GPU into the mirror, so the build reads the results without a CPU round trip. The images stay pending: a hooked CPU read, a label or an idle store writes guest memory as before. Blocks the CPU or another store wrote since a unit's generation are left out, as in the write-back. DCC keys that do not read uncompressed, partly drawn rectangles, read traps, unwatched memory, copied heap mirrors and ranges the build itself writes fall back to the old store.
APS5_NO_MIRROR_PUBLISH=1restores the old path; the debt entry lists what stays unproven.Overlap: 79 open PRs could not be checked automatically. By title none implements this; #13251 (storage image units on the device) is closest, and #15296 touches the same mirror code.
Tested
Windows 11 10.0.26300, MinGW UCRT64 GCC, NVIDIA GeForce RTX 5070 (driver 617.42), commit faf7f5a2650481abb11e5392d7267cb9d76b7739.
ctest --test-dir build-full -R "^agc_driver_(resident_heap_mirror|address_draw_space_reuse)" --output-on-failureThe tests check that a published image leaves guest memory untouched yet reads back through the hook, that unchanged rebuilds skip the publish, that CPU writes win, that DCC images with uncompressed keys publish and that writable and copied mirrors fall back;
_no_publishis the negative control.With
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the same tests on main (9d2e737, built here) and the change; the new negative control has no main counterpart and ran on the change alone:The full Windows suite passed except tests that also fail on main here (
vulkan_validation_gate_commands;guest_timed_join_import_libkernel_web, fixed on main by 07572f5). Linux (llvmpipe, 0 failures) and ASan ran on the revision before the last two fixes, not on this commit. I changed 20 conditions one at a time: 10 failed the tests, 1 did not build; of the other 9, five are equivalent, diagnostic or lifetime guards and four are the untested paths below.Speed, Jusant (PPSA10264). It needs #8089 to run, so both sides are one build of this patch on top of #8089 with publishing on and off (
APS5_NO_MIRROR_PUBLISH=1stores as main does). Measured on the revision before the last fix, which only changes what happens when a mirror is evicted during the build.Guest flips per 10 s, ABBA:
01-change02-off03-off04-changeAPS5_TRACE_SECONDS=200:20captures, warm caches, no other trace or profile switch (tools/trace_digest.py):Phase breakdown (
draw committerthread):Change first, publishing off second. GPU time is unchanged; the gain is the CPU store-backs the build no longer waits for. Traces: change aps5-trace-475c6eb5d3ff-25588.json.gz, publishing off aps5-trace-475c6eb5d3ff-43440.json.gz.
Summary lines (
aps5-summary.jsonl, one per capture, in the order above):{"commit":"475c6eb5d3ff","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_SECONDS":"200:20"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600K","cpu_threads":20,"memory_mib":16147,"title_id":"PPSA10264","title":"Jusant","content_version":"02.000.000","resolution":"3840x2160","window":{"spec":"seconds 200:20","first_present":348,"ms":20280.093},"presents":57,"frame_ms":{"p50":351.917,"p90":374.204,"p99":545.87,"max":545.87},"gpu_busy_ms_per_present":147.635,"worker_busy_pct":{"queue worker 0x0":98.335,"queue worker 0x20":75.629},"top_phases_ms_per_frame":{"Driver.Packet":613.356,"Driver.Packet.dispatch":293.082,"Driver.Dispatch":185.387,"Recorder.Sync":137.559,"Graphics.Draw":111.687,"Graphics.Draw.draw_and_resource_release":104.057,"Resources.Complete":88.254,"Driver.Packet.prepare_memory":85.999},"trace_dropped":false,"trace":"aps5-trace-475c6eb5d3ff-25588.json.gz"} {"commit":"9d2e737432d","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_SECONDS":"200:20"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600K","cpu_threads":20,"memory_mib":16147,"title_id":"PPSA10264","title":"Jusant","content_version":"02.000.000","resolution":"3840x2160","window":{"spec":"seconds 200:20","first_present":153,"ms":20161.35},"presents":30,"frame_ms":{"p50":672.733,"p90":692.634,"p99":729.904,"max":729.904},"gpu_busy_ms_per_present":151.647,"worker_busy_pct":{"queue worker 0x0":97.477,"queue worker 0x20":66.991},"top_phases_ms_per_frame":{"Driver.Packet":1099.931,"Driver.Packet.dispatch":461.8,"Graphics.Draw":379.564,"Graphics.Draw.draw_and_resource_release":372.194,"Driver.Dispatch":272.052,"Driver.Packet.pipeline_drain":184.101,"Driver.Packet.prepare_memory":181.467,"Recorder.Sync":176.318},"trace_dropped":false,"trace":"aps5-trace-475c6eb5d3ff-43440.json.gz"}Not verified: on a console; on GPUs other than this one; Jusant on plain main (it does not run without #8089).
Not covered by a test: the publish drain of a reused address-based build (
GuestBufferMemory::RecordStagingCopies); a heap mirror evicted by the same build after an image was deferred into it (the publish then finds the mirror gone by base and serial and stores the image instead); images outside the write watch, array layers, multiple mips, edge blocks and memo eviction. Devices without sparse residency never publish; there the negative control skips.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code