perf(agc): group resource metadata allocations by lifetime #1366
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1366"
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 TibixDev on 2026-10-08T00:26:38Z.
What
Performance justification remains open: the isolated current-main buffer-only measurements below do not show an improvement. The old stacked timing claim has been removed.
Allocate resource-owned metadata vectors from one monotonic arena, declared before its users so their elements are destroyed first. Arena chunks live until the
ShaderResourcesobject is destroyed; binding records keep their existing ownership.Rebased only the arena change directly onto main
d146ec1b6. Removed the #1324/#1357/#1359/#1360/#1361/#1364 dependency stack. Main's descriptor-cache allocation, deferred construction, image validation and texture-base-level tracking are preserved. Current main can repeatcaptureValidationduring reuse; it assigns the same texture count and reuses vector capacity, so this does not accumulate arena allocations for a fixed resource layout.Depends on: none.
Tested
Fedora 44, GCC 16.2.1, Release:
agc_driver_graphicsandagc_driver_pm4pass (3.28 seconds total), as do contribution checks andgit diff --check. The new--metadata-lifetimefixture covers empty, 1-, 8- and 32-binding resources, abandonment before deferred completion, shared ownership through completion, descriptor data and destruction. It also runs in the regular graphics suite.Targeted upload-lifetime, upload-failure cleanup and descriptor-pool recycling tests pass on RX 6600 RADV and lavapipe with core/synchronization validation and no validation errors. The RADV draw-descriptor/snapshot test also passes without validation errors.
The full recorder suite passes its assertions on lavapipe. With validation enabled, both unchanged main and this PR emit the same existing diagnostics: one
SYNC-HAZARD-WRITE-AFTER-WRITEand tenVUID-vkCmdEndRendering-None-06161errors. This is not a validation-clean full-suite result.AddressSanitizer and leak detection pass for that fixture using
ANYPS5_ENABLE_ASAN=ON. A local negative control insertingallocationArena.release()into the destructor before member destruction fails withheap-use-after-freeinShaderResources::~ShaderResources. Restoring the implementation passes again; the mutation is not part of the PR.The build also used the existing local
FFMPEG_PREBUILT_DIRcache; it is unrelated to this test. No Windows runtime or title FPS result is claimed.Isolated measurement
Ryzen 5 5600, CPU 3, identical GCC/Release flags and benchmark source. Main
d146ec1b6production code versus only this PR's arena change. Three ABBA cycles, six processes per variant; each process reports the median of nine batches of 512 complete resource builds/destructions after one warm-up batch. Each non-empty binding carries 256 bytes of flattened shader data. The Vulkan calls are mocked, and buffer/descriptor pools stay warm across builds.All checksums match. Every row's process-median range overlaps between variants; the medians are approximately 1–9% slower with the arena. This fixture does not justify the optimization. It contains buffers, not the earlier eight-texture workload, and does not establish mixed-resource or title performance. Further performance justification is needed before merging.
For the baseline, build this same harness with main's
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp. All other production files on this branch already match main. Restore the PR header and rebuild for the arena variant.Checklist
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:32:18Z.
Rebased on
1e1e1390. Updated the #1364 prerequisite after #1113 merged. Retained upload pages now count toward the batch memory budget; metadata lifetime and the existing GPU synchronization tests remain intact.Fedora 44 Release:
agc_driver_graphics_tests,agc_driver_pm4_tests,guest_mapping_history_tests,agc_driver_recorder_tests,agc_recorder_kept_bytes_testsbuild; the targeted tests and contribution checks pass. Windows CI is pending.RADV and lavapipe:
--copied-buffers-only,--shader-data-only,--draw-upload-only,--draw-snapshot-only,--draw-descriptors-onlypass with core and synchronization validation; no validation errors.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:40:46Z.
Review: CHANGES_REQUESTED
Reviewed the commit specific to this PR (
f74fa3d6a,ShaderResources.hpp): moving the resource-owned metadata vectors to astd::pmr::monotonic_buffer_resourcedeclared before them looks right (destruction order, the class is non-copyable, and the reuse paths such asnoteReusableandcaptureValidationrun once per build, so the arena stays bounded).Blockers:
main. Nothing can be built or tested for this PR alone, and it can't merge before them. Please rebase once the stack has landed (or been rebased) and keep Depends on current.main+ this commit alone, with the command used, so the arena's effect is separate from the rest of the stack.ShaderResourceswith ASan/valgrind-visible destruction order would cover it, or say why the existing tests already do.Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:01:40Z.
@adriadam10 updated in
24ac32372, directly on maind146ec1b6:Graphics/PM4 and targeted RADV/lavapipe lifetime and descriptor tests pass. The full recorder run reproduces the same existing validation diagnostics on main and this branch, documented in the body. Windows runtime/full CI still need maintainer validation.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:14:27Z.
Closing: the PR's own isolated measurement shows the arena is 1–9% slower on every buffer-only row (0/1/8/32 bindings), the description says further performance justification is needed, and no title or profile shows resource-metadata allocation as a cost. A perf-only change that measures slower doesn't meet CONTRIBUTING (perf PRs post before/after numbers and drop what measured slower). It also currently conflicts with
main.Feel free to reopen, rebased, with a measurement (mixed buffer+texture resources, or a title profile) where the arena wins.
Pull request closed