perf(agc): take the host import budget from the device's memory budget #6479
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6479"
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 EagleBearerYS on 2026-10-15T16:56:40Z.
What
Host imports were held to a configured budget only, not to what the driver can pin. A budget above the driver's limit makes every later import fail at
vkAllocateMemory; a budget below it refuses imports that would fit.VK_EXT_memory_budget, no budget is set and an import'svkAllocateMemoryhas failed, the effective budget is at most the host heap's reported budget, less that heap's usage by everything other than the imports, less an eighth of the budget, rounded down to 64 MiB. It is read at most once a second. A setAPS5_HOST_IMPORT_MIBis never lowered by the report, and before a failure main's default stands. Without the extension the configured budget applies, as before.vkAllocateMemoryfailure of an import within an eighth of the budget, or the third in a row, lowers the budget to the live imports. Later imports are then refused (and remembered, #6457) or evict, instead of failing. It prints once:[gpu] host import budget lowered to the N MiB live after vkAllocateMemory failed within an eighth of the budget.maxMemoryAllocationCount. NVIDIA's Windows driver reports 4,096, while Resident Evil Village held 27,167 live imports without allocation failures, so the reported value isn't where the driver fails.vkAllocateMemoryfailure turns the report on and counts toward the ceiling whatever its code, so a range a driver refuses for another reason counts too. An out-of-memory-only filter isn't safe: NVIDIA's pinning failures here were -2 (VK_ERROR_OUT_OF_DEVICE_MEMORY), and Mesa's RADV returnsVK_ERROR_INVALID_EXTERNAL_HANDLEwhen it can't pin a host pointer, so such a filter would turn the protection off there.APS5_HEAP_MIRROR_MIBbudget (24 GiB by default), as onmain. When this PR lowers the import budget, refused heaps move into mirrors. Deriving the mirror budget from the same report would be a follow-up.The device report no longer lowers a set budget, or the default before a failure. On Resident Evil Village (PPSA01556), on an RTX 3070 Laptop GPU with
APS5_HOST_IMPORT_MIB=6400, the host heap'sVK_EXT_memory_budgetreport lowered the import budget to 4480 MiB and refused 85,047 imports (115,203 MiB), although 6400 MiB runs without a singlevkAllocateMemoryfailure on that machine. The report's "other usage" includes the host-visible copies and heap mirrors that stand in for refused imports, so it grows with every refusal and pushes the next budget down. Now a setAPS5_HOST_IMPORT_MIBis never lowered by the report. Without a setting, the budget stays at main's default until an import'svkAllocateMemoryfails, and only then can the report lower it. The failure ceiling is unchanged: a failure within an eighth of the budget, or the third in a row, still lowers the budget to the live imports. The first time the report would lower the budget, a[gpu] host import budget: host heap ...line prints the heap's reported budget and usage and the live imports, and the refusal line names its budget's source.With #6472: #6472 changes how the default (configured) budget is computed. This PR lowers the effective budget on allocation failures whatever the configured value is, and lets the device's report cap it only when no budget is set and an import has failed, so the two compose. Textually they overlap on one declaration line in
GuestBufferMemory.hppand on the "Host import windows and budget" debt entry.This branch is on #6457's branch. This PR's own commits are
98c72e9f83(the device budget),ac9ccfb89c(the report kept off a set budget, and off the default until an import fails) anda7928027fc(a report with no room leaves a 1-byte budget); the merges between them bring in #6457's newer commits.Tested
Resident Evil Village (PPSA01556), Windows 11, RTX 3070 Laptop GPU (driver 617.42):
6ea62f9b40with our open fixes for the stops before its title, at main's default budget. The log:[gpu] host import budget: 5840 MiB live of 5840 MiB (APS5_HOST_IMPORT_MIB), then... 21138 imports (71872 MiB) refused so far, last 0x200200000+0x30000000.APS5_HOST_IMPORT_MIB=6864, imports failed at the driver instead, 992 times from 6,557.7 MiB live on:[gpu] host import of 0x23944b0000+0x10000 failed at vkAllocateMemory (-2); falling back to copies.Linux, lavapipe:
^agc598/598 at this commit (on its earlier base; the code is identical).BdaResources.cpp), red on #6457's code and green here:Windows 11, RTX 3070 Laptop GPU (driver 617.42):
agc_driver_graphics, with the new tests, passes 5 of 5. Each run logs both ceilings:[gpu] host import budget lowered to the 0.1 MiB live after vkAllocateMemory failed within an eighth of the budgetand... after vkAllocateMemory failed 3 times in a row.GitHub's runners, at this PR's commit
98c72e9f83(later merges of #6457's branch bring only #6457's own changes): Linux, lavapipe:^agc604 of 605, the one failure the known parallel-load flakeagc_driver_preparation_scope_settle(run). Windows, no Vulkan device: 597 of 599 (467 skip) (run). The two failures also fail onmainon that runner:agc_driver_pm4_replay_tool(0xc0000139), andagc_interpolant_mapping, which prints its pass and then times out at exit.maindoesn't build in full with MinGW since #5747 (alignas(65536)intests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp), so the Windows sweep ran with #6452's fix for that test applied, for this check only.The report kept off a set budget (
ac9ccfb89c):importReportFloorTestsinagc_driver_graphicschecks that a set budget and main's default stay put while the report is low, and that the report lowers the default only after an import fails. Added alone on 9c4bb70741's code it fails for both the set and the default case (Linux, lavapipe); eight newHostImportBudgetWithcases, which need the fix's API, cover the formula with Resident Evil Village's numbers. With the fix:ctest -R '^agc'605/605,agc_driver_graphics10 of 10. On GitHub's runnersagc_driver_graphicsand the tests run with it pass 5 of 5 on Linux and Windows (run). The run's Windows job is marked failed for two reasons outside this change: its arm on the previous code can't build the new tests, andguest_kqueuein the libkernel suite failed, as it has in our other Windows verify runs today on unrelated changes.A report with no room (
a7928027fc):importDeviceBudgetTestschecks that such a report doesn't make the default budget 0, and the newimportReportRefusalMemoryTeststhat a second address-based build under it answers the refused ranges from the refusal memory. On GitHub's runners, with the previous commit's code the tests fail in every one of 3 runs on Linux and Windows ("a host heap report that leaves imports no room made the default import budget 0, which the refusal memory reads as no budget"); with the fix they pass 10 of 10 on both (run). Linux, lavapipe:ctest -R '^agc'605 of 605 (42 skipped).Checklist
main0029e62f97(merges cleanly withfa9365ca74); no other open PR implements the same functions. Overlaps:NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T17:29:12Z.
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.
main)docs/dev/debt/libSceAgcDriver.mdL137core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1253-1256, L1272-1276, L1347, L1489core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1406-1407, L1522-1523, L3447-3448, L3451core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppL7, L75core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1603-1608, L1841-1843, L3205-3206, L3223docs/dev/debt/libSceAgcDriver.mdL137-138core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1506docs/dev/debt/libSceAgcDriver.mdL195core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL1801-1810Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T19:33:58Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.