AGC: on lavapipe, released descriptor sets stay allocated in chain pools that still hold a live set (about 30 per frame in Ghost of Yōtei PPSA26344) #6608
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Dextroid17 on 2026-10-15T22:46:11Z.
What
The debt entry "Descriptor pool recycling" (#1333,
docs/dev/debt/libSceAgcDriver.md) says "A cached set can retain unused slots in an exhausted pool until eviction; peak gameplay pool memory remains unmeasured." I measured it in Ghost of Yōtei (PPSA26344) on lavapipe.DescriptorCache::Freeresets a chain pool only after its last live set is released. Until then, every set released from that pool stays allocated in Vulkan. On a tree based on currentmain, the sets still allocated in Vulkan grew by about 30 per presented frame during gameplay, and memory grew with them. With each set freed individually, the count stayed flat.Measurements (tree based on main
31cbb55d7)Two 900 s runs with the same binary, with the shader cache deleted before each run. The only difference was a local switch that creates chain pools with
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BITand frees each set inFreewithvkFreeDescriptorSets, as the code did before #1333. The pool chain and the reset of an emptied pool are kept. A local probe wraps the Vulkan descriptor pool and set calls, counts the sets still allocated, and reads the cgroup'smemory.currentand the process's memfd sizes every 10 s.cgroup
memory.current, at the first probe at or after each presented frame:At 900 s:
VkDeviceMemorywas the same in both runs (8,036 MiB live at the end). Theallocation fdmemfd accounts for 4,709 MiB of the 5,372 MiBmemory.currentdifference. I did not measure the size of each set.Recyclein both runs. With individual frees it stayed between 271 and 352, soRecycle's lists do not account for the growth.On a tree based on main
a08de68(before #1201), four runs gave about 79 sets per frame without individual frees (peaks 22,027 and 22,141 MiB against the 22 GiB limit; one run used 5.8 GiB of swap) and a flat 11.8 GiB with them. I have not measured how much of the lower rate on currentmaincomes from #1201.Why lavapipe
In Mesa 26.2.4,
lvp_descriptor_set_create(src/gallium/frontends/lavapipe/lvp_descriptor_set.c) allocates a block for each set in llvmpipe'sallocation fdmemfd. The block is freed only byvkFreeDescriptorSets,vkResetDescriptorPoolorvkDestroyDescriptorPool. Freed blocks are reused, but the memfd does not shrink. So each released set in a pool that is not reset keeps its memory. Drivers that carve sets out of one buffer per pool should not use more memory for these sets. I did not measure RADV, NVIDIA or Windows.I did not find which sets keep the pools alive. Candidates: cached sets (the case in the debt entry) and, on current
main, released draw sets held byRecycle(up to 4,096 per layout), which never reachFree.Why this is an issue and not a PR
The local switch is the individually freed path that #1333 removed because RADV 26.2.2 can place a set past a
FREE_DESCRIPTOR_SETpool's buffer. It is not a fix formain. Possible directions:VK_DRIVER_ID_MESA_LLVMPIPE), create chain pools withFREE_DESCRIPTOR_SETand free each set. RADV keeps the reset-only pools that #1333 needs. The device already branches on the driver ID inFragmentBarycentric.hppandSubgroupClock.cpp.I can measure any of these in the same scene.
Environment
systemd-run --scope -p MemoryMax=22G -p MemorySwapMax=8G.GALLIUM_OVERRIDE_CPU_CAPS=avx.-O2build (CMAKE_CXX_FLAGS=-O2, no build type) with GCC 16.2.1.31cbb55d7(contains #1201) plus the first two commits of #6054 and local changes that let the title reach gameplay. Only the switch and the probe touchDescriptorCache. One local change adds a separate reset-only descriptor ring inTextureDetilerfor a channel-extract compute pass; the probe counts its pools and sets in both runs.ShaderResources.cppandShaderResources.hppare unchanged on main5d9dcc42d.Related: #1333 (pool recycling), #1201 (draw sets released through
Recycle), #6567 (open: reuse a recycled descriptor set only for a table of its own size).