perf(agc): bind chunk-crossing shared imports into the 64 MiB chunk imports #23272
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23272"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-18T21:41:16Z.
What
On Linux, a shared-backed guest range that lies inside one 64 MiB chunk of the direct-memory file is bound into that chunk's udmabuf import (
b7443c4424), and a range above 64 MiB is one sparse buffer bound to the chunk imports (5894feff7e). A range at or below 64 MiB that crosses a chunk boundary, or has several backing runs, still became a udmabuf import of its own, becausecreateSparseDmaBufImportreturned early forentry.bytes <= ImportChunkBytes.amdgpu validates every imported buffer object at every command submission, so each such range adds to the cost of every
vkQueueSubmit. This drops the size condition: those ranges now take the existing sparse path and add no buffer object of their own. A range inside one chunk still takes the plain chunk import first, and every other condition of the sparse path (sparse binding, a sparse queue of its own or the GPU mutex, 64 KiB block alignment, chunk memory types, the backing file covering the last chunk) is unchanged.Performance
Infliction: Extended Cut (PPSA02688) is CPU-bound on the draw committer at about 7 FPS, submitting about 4,900 times per 10 s. A DWARF
perfprofile putsRecorder::Submitat 19% of the committer's samples, nearly all of it inamdgpu_cs_ioctl. At 170 s the title has about 3,070 live host imports (5.4 GiB), almost all of them dma-buf: about 2,700 are bound into 87 shared chunk imports, but about 380 crossing ranges are udmabuf buffer objects of their own.The comparison changes only this condition: a local build of
mainfeb04e7e3f66(plus the one-line #21747 change Infliction needs to reach gameplay, and a local import counter) with an environment switch that skipsentry.bytes <= ImportChunkBytes, which is exactly what this PR removes. Runs alternate, 180 s each, the same scripted input, mean FPS over 120 to 175 s; submit cost is the marginalvkQueueSubmittime over the last 50 s from the[recorder]profile lines (APS5_PROFILE_DRAW=1).vkQueueSubmitmainmainMeans 7.44 against 8.88 FPS (+19%); the ranges do not overlap. All four runs exit 0. The second pair ran under a higher host load (17 to 19) with a low-priority build running alongside both, more of it during B2. Linux 7.2.14, Ryzen 9 7950X, RX 6650 XT, RADV Mesa 26.2.7, Release.
Why the count matters: a standalone Vulkan test (not in the tree) that imports N buffers and times 200 empty
vkQueueSubmitcalls on the same machine gives, for 2 MiB each, 0.25 / 0.84 / 1.81 ms per submit with 500 / 1,500 / 3,000 udmabuf imports (about 0.6 µs per buffer object), against 6.6 / 19.7 / 42.6 ms with host-pointer imports; buffer device address does not change it.Tested
Linux 7.2.14, Ryzen 9 7950X, RX 6650 XT, RADV (Mesa 26.2.7), GCC 16.2.1, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF,/dev/udmabufaccessible (size_limit_mb64).agc_driver_sparse_dma_buf_straddle: a 2 MiB memfd-backed range inside one 64 MiB chunk is bound into the chunk import (unchanged); a 2 MiB range across the 64 MiB boundary must be dma-buf, bound into chunk imports and without aVkDeviceMemoryof its own, and a GPU fill over it must land in both chunks and nowhere outside it. Withmain's condition it fails withstraddling import: a 2 MiB range across a chunk boundary was imported as a buffer object of its own instead of being bound into the two chunk imports; with this change it passes.agc_driver_sparse_dma_buf_importandagc_driver_scattered_runspass.ctest -j 12at this head (code identical tob40458da3b17; the head commit differs only in the debt entry's wording): 6158 of 6162 pass. The four failures,agc_driver_host_write_shadowed_unit,agc_driver_image_table_packed_guards,guest_libressl3_aes_wrapandguest_libressl3_aes, fail the same way onmain6f023a5bae9fbuilt with the same options (0 of 4 pass there); none of them involves imports of shared memory.Checklist
main; no other open PR implements the same functions (#21649 adds a bind probe to the same sparse path; it does not change which ranges take it)NotImplemented_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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T23:27:53Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at
b4b3f14924779ee25117a0103e592571bd9d0c6ehas no verified blocking defects; the reported test and performance results are author supplied and were not run in this review.What I ran
Read the prepared description, commit list, manifest, diff, changed test, changed documentation, and the relevant import implementation and caller at the pinned head. No tests or builds were run.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
GuestBufferMemory.cppwas excluded by the review bundle size limit; only the changed hunk and the relevant surrounding function and caller were read through the repository reader. The performance measurements and test outcomes in the PR description were not independently reproduced. No tests were run.To get this to a good state
Nothing is required.