Repository navigation
perf(agc): reuse read-only sparse buffer address uploads - #27991
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Change: Refactor Merge Risk:
|
|
AMD Linux check of the exact head
This is correctness only. I didn't measure the performance effect, which would need matched title traces. AI-assisted: yes |
|
In KytyPS5 #1270, page-table physical storage and uploaded address content have separate lifetimes. For the read-only address cache here, rebind just one backing page and require a new lookup for that page, with neighboring unchanged address uploads remaining cache hits. Track the page-table bytes and payload-upload bytes separately. This is a proposed synthetic control, without a memory or performance claim. |
|
@akimfomin I ran the single-page rebind control on The fixture kept three separate sparse uploads live. Each contained two backed 64 KiB pages with a hole between them. It checked the address-table entries against the Vulkan buffer device addresses after each lookup. A second build of the same commit counted the range-table bytes written and guest payload bytes copied separately. Both GPUs gave the same results.
The 128 KiB copy covers both backed pages of the replaced upload. All eight runs across the submitted and instrumented drivers, with reuse enabled and disabled, loaded Khronos validation and reported zero VUIDs or synchronization hazards. This control measures correctness and copy volume only. @JJenkx thanks for independently checking the PR’s read-only flush test on the RX 6650 XT under Linux. 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.
|
Plyxen
left a comment
There was a problem hiding this comment.
Checked head 7042da5d05. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to main 4c7578e0a4 together with #28006, #27985, #28002, #28001, #27987, #28007, #27994. tools/check_conventions.py --head and tools/debt_fold.py --check passed and the full build succeeded. In the full CPU suite (5,135 tests) the only failure is windows_read_trap_unknown, which fails on main too (fixed in #28028). The full GPU suite (2,249 tests) on both GPUs, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer and the 1.4.363 layer inserted, matches main on the same machine. The GPUs were an NVIDIA RTX 5080 (621.24) and an AMD Radeon gfx1036 iGPU (26.11.2). Only agc_driver_linear_target_import_creation fails, as on main (fixed in #28029), and neither log has a VUID- or SYNC-HAZARD line.
agc_driver_upload_cache_read_only_flush, which sets APS5_COMPARE_SPARSE_UPLOADS and runs CheckSparseAddressReads when buffer device addresses are available, passes on both GPUs.
One non-blocking note: the whole-title table shows the feature at 1.05 s per present against 0.66 s on main. So the title-level gain isn't shown yet, only the per-upload one. Since the path stays behind APS5_COMPARE_SPARSE_UPLOADS, the default is unchanged.
AI-assisted: yes (Claude Code)
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The read-only sparse upload reuse is guarded by address write permissions and write overlap checks, and the added test exercises cache reuse, mutation, and writable separation.
What I ran
Reviewed head 7042da5d054c33622b5f9704acc964960d2305bc. I inspected the prepared diff, changed source context, and the added execution test through repo_read.py; I ran no build or tests.
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | Two changed files read |
| Build and runtime tests | not run | No commands run |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or runtime test was run in this review. The author reports GPU tests and performance measurements, which I did not independently verify. The manifest lists two changed files; both were read. GuestBufferMemory.cpp was excluded from the review folder due to size and read through repo_read.py.
To get this to a good state
Nothing is required.
ligmaSec
left a comment
There was a problem hiding this comment.
The new fixture checks that a guest byte change creates a new sparse address upload while the earlier upload remains intact. Could the same fixture also change the committed pieces with the guest range otherwise unchanged, then verify the newly absent bytes read as zero? That tests the pieces check on the addressable cache lookup.
Source review at 7042da5d05. The head trial-merges onto 700fae9438. Paired Vulkan execution is queued.
AI-assisted: yes.
What
Repeated read-only draws can share one unchanged Vulkan buffer, avoiding a request for another backing buffer, a guest-to-host copy and a hole clear. In a 220 MiB upload with 79 of 80 backed spans write-tracked, this reduced median host time per upload from 16.25–17.49 ms to 0.36–0.41 ms on an RTX 4070 Laptop.
A sparse buffer can have a shader device address even when every use of that address is read-only. The opt-in sparse comparison cache previously excluded every addressable buffer. Planet Zoo's Animal Market repeatedly uploaded large ranges with identical backing and bytes.
Allow a fresh sparse upload into the existing comparison cache when the address table grants no write permission and no declared shader write overlaps the full guest range. Addressable snapshots stay immutable. A live GPU write is flushed before validation. Spans without a valid unchanged-generation proof are compared byte for byte. A mismatch or inaccessible span falls back to the ordinary upload. A single backed span that already fills the trimmed allocation stays on the normal copy path. Matching device, usage, extent and backed layout are still required. The optimization uses the existing
APS5_COMPARE_SPARSE_UPLOADS=1switch.#27451 covers a sparse piece that disappears between registration and upload. The addressable comparison here can only return an unchanged buffer. The existing upload path determines how to handle an inaccessible piece. Warm-cache integration review
Tested
Planet Zoo (PPSA18026), Goodwin House loading, RTX 4070 Laptop at 1920×1080. Four fresh processes used the same title executable, runtime libraries, preset, warm shader-cache seed and screen-triggered 60-second capture. Only the graphics driver changed. The measured revisions were
8c02bb89f41candd39c2210ebf5. The submitted patch has the same stable Git patch ID after rebasing onto4814cae85517. All four native traces retained every event. A separate, later 140-second window on main ended when the title exited before writing a summary and is excluded.Across the four windows the pooled frame time was 0.66 s on main and 1.05 s on the feature (60.4% higher). The mix of quick loading-screen presents and long scene-transition frames varied across launches, limiting what these means say about park performance. The public Perfetto extracts retain the native present markers and presentation and resource-completion durations on anonymous tracks. Frame digests · Summary lines
Two additional fresh processes used the submitted revisions and the same shader seed, GPU, settings and Goodwin scene. They requested a 30-second capture starting 110 seconds after confirming the loading screen.
4814cae855177042da5d054cThe later window has a small sample count because each heavy loading frame can exceed the requested window length.
Host cost per upload. One reader held the original snapshot. Four fresh RTX processes per layout each timed ten registrations and
Upload(true)calls, in main / feature / feature / main order. The table reports each process median after discarding its first two samples. The 80-span layouts have 220 MiB of data across a 300 MiB guest range, with a 1 MiB hole after each backed span.On each 80-span layout, the feature returned the held Vulkan buffer in all 20 timed uploads. Main returned a buffer distinct from the held reader in all 20. On the trimmed dense control both revisions used the ordinary path for all 20 uploads. Comparing that dense buffer had been slower in an exploratory build, which motivated the fully backed check. Individual samples
Animal Market prototype. In five consecutive ten-present windows on the earlier park-capable renderer, enabling read-only address reuse saved 9.8% and 12.0% against adjacent controls. Those measurements used a separate integration build with the warm-decommit fix and allowed refresh of exclusively owned buffers. The submitted implementation keeps addressable snapshots immutable. The park percentages apply to the prototype.
GPU correctness. On Windows 11, the sparse-hole and read-only flush tests passed on each tested adapter on main and the feature. The read-only flush test also passed with sparse comparison explicitly enabled on both revisions. The feature fixture checks equal handles, a guest CPU mutation, GPU readback of the old and new snapshots, and exclusion of an overlapping shader write. The validation layer was loaded, the shader cache disabled, Vulkan required, and these runs logged zero VUIDs.
As a separate diagnostic, forcing the comparison cache on in the non-addressable pool-identity test on Intel caused the shortened upload to miss the pre-primed Vulkan handle on both main and this patch. Both diagnostic runs then logged the same device-destruction VUID during cleanup. The pool test passes under its normal settings on both revisions and GPUs.
Summary extracts and trace links
Run 1 · Run 2 · Run 3 · Run 4 · Run 5 · Run 6
{"commit":"8c02bb89f41c","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:60","first_present":777,"ms":103179.029},"presents":138,"frame_ms":{"p50":157.189,"p90":174.438,"p99":785.943,"max":80849.852},"gpu_busy_ms_per_present":44.954,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:60","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-addr-main-8c02bb89f41c.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}} {"commit":"d39c2210ebf5","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:60","first_present":916,"ms":96570.268},"presents":88,"frame_ms":{"p50":168.941,"p90":200.88,"p99":45925.886,"max":45925.886},"gpu_busy_ms_per_present":56.746,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:60","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-addr-feature-d39c2210ebf5.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}} {"commit":"d39c2210ebf5","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:60","first_present":941,"ms":77120.347},"presents":77,"frame_ms":{"p50":153.031,"p90":192.132,"p99":32455.733,"max":32455.733},"gpu_busy_ms_per_present":50.011,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:60","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-addr-feature-repeat-d39c2210ebf5.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}} {"commit":"8c02bb89f41c","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:60","first_present":895,"ms":73328.283},"presents":131,"frame_ms":{"p50":207.497,"p90":235.691,"p99":1029.028,"max":44996.214},"gpu_busy_ms_per_present":51.297,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:60","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-addr-main-repeat-8c02bb89f41c.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}} {"commit":"4814cae85517","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:30","first_present":1055,"ms":36876.862},"presents":1,"frame_ms":{"p50":36876.862,"p90":36876.862,"p99":36876.862,"max":36876.862},"gpu_busy_ms_per_present":739.905,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:30","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-current-main-late-4814cae85517.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}} {"commit":"7042da5d054c","dirty":null,"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 621.24","os":"Windows 10.0.26200","resolution":"1920x1080","title_id":"PPSA18026","window":{"spec":"seconds 0:30","first_present":1023,"ms":60236.436},"presents":2,"frame_ms":{"p50":30635.496,"p90":30635.496,"p99":30635.496,"max":30635.496},"gpu_busy_ms_per_present":752.627,"trace_dropped":false,"env":{"APS5_COMPARE_SPARSE_UPLOADS":"1","APS5_DRAW_CACHE_INDIRECT":"1","APS5_DRAW_CACHE_PUSH_WORD":"1","APS5_TRACE_SECONDS":"0:30","APS5_UNIFORM_INDIRECT_RECORDS":"1"},"trace":"sparse-current-feature-late-7042da5d054c.json.gz","worker_busy_pct":{},"top_phases_ms_per_frame":{}}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)Summary by CodeRabbit