Marvel's Wolverine (PPSA03671) on an 8 GB card: storage images cycle ~5.4 GB through the 2 GB storage cache, and evicted images stay alive until device memory runs out #5961
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 tv7 on 2026-10-14T17:13:03Z.
Marvel's Wolverine (PPSA03671) on plain
maine34c47921(which has #757) now gets past its old stops and presents 3840x2160 frames. After a few minutes it aborts because device memory runs out:Setup: Windows 11, NVIDIA GeForce RTX 3070 8 GB (driver 617.14,
VK_EXT_memory_budgetreports a budget of about 7 GB for heap 0), MinGW GCC 15.2 Release, relinked with--to-intel.Before the abort, heap 0 usage swings between about 4.5 and 13 GB while the
[gpu]budget lines report only about 2 GB of sampled textures and 2 GB of cached storage images. The host-memory fallback count inDeviceMemoryTypereaches 65,536 allocations (182 GB in total).I measured where the memory goes with two local debug hooks (not for merging): one wraps
vkAllocateMemory/vkFreeMemoryand sums live bytes per call site, and one keeps aweak_ptrto every imageevictStorageremoves.StorageTexture::StorageTextureholds 10.0 GB in 2,191 allocations, all in memory type 0 (heap 1, the host fallback).createHostPointerImportholds 5.2 GB (expected). Texture and buffer-pool allocations make up the rest.MetadataMoved), and 11,894 of 13,265 creations were for a key evicted earlier. Only about 245 distinct base addresses are involved.heldBytes, and 1,359 of them were created again within the last 10 seconds.Two things I tried locally that did not help:
APS5_TEXTURE_CACHE_MIB=3072: about 34,000 evictions, same abort.texture.use_count() > 1: re-creations fell from about 11,900 to about 1,700, but evicted images still reached about 4 GB alive, and the run aborted sooner, on a device buffer allocation in presentation.So on an 8 GB card the problem seems to be two things together: a storage working set of about 5.4 GB cycling through a 2 GB LRU budget, and each evicted image staying alive until its other owners let go, so the re-created copy and the old one exist at the same time. #3256 had a similar shape (the resource cache's entry bound pinned storage images past their budget, fixed by #3473 and #3474). I have not identified the other owners yet. The image tables from #757 are one candidate, since their resource-cache keys include the table's T# list, but I have not confirmed that.
I can run any proposed change on this card with Wolverine and post the same numbers. Full logs are available if useful (no game data in them).
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T17:33:42Z.
I traced the eviction path on current
main.evictStoragemarks an image uncached and queues it withnoteUncached; sampled views that hold the image are removed later whendropUncachedViewsdrains that queue from a sampled-cache lookup (orTextureCacheUsage). So a stretch of storage-only lookups can leave stale sampled-view references alive after storage-cache eviction.Could your existing eviction hook count how many
TextureCache.viewsentries point at each evicted image, then compare that with the images that remain alive? If the sampled-view count tracks those survivors, we have a focused cleanup path to investigate. If it does not, the remaining owners are more likely in-flight resource captures or another cache, and we should trace those separately.Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-14T18:29:49Z.
@MarcZX100 I counted it. Under the storage-cache mutex, every 10 s, each evicted image that is still alive is checked against
Textures().views(taken withtry_lockon the sampled cache's mutex; it was never busy at a report), together with the size of theUncached()queue. Same setup as above (maine34c47921, RTX 3070 8 GB, Wolverine), one 900 s run:Uncached()queueThe sampled cache held 880 to 1,740 entries and 490 to 970 views at the same points. So the survivors are not held by sampled views: the drain keeps up and at most one survivor has a view. Going by your split, that points at owners outside the texture caches, such as recorded work that has not completed yet. I can count a specific holder next if you have one in mind.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T18:35:19Z.
Thanks, that rules out sampled views as the main owner. I traced the current eviction path a step further:
cachedStorageTexturecallsSharedResourceCache().RemoveImage, then passes each returnedShaderResourcestoRecorder::Keepwhile recording. The resource cache removes entries that read the evicted image atResourceCache::RemoveImage.Could you count, at each report, how many surviving images are referenced by those recorder-kept
ShaderResourcesobjects (and whether their owning submissions have completed)? If that matches the survivor count, it would narrow this to recording/submission retirement; if not, we can trace another owner class. This is a more direct next check than sampled-cache accounting.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T18:47:58Z.
I opened PR #5998 to charge storage images retained by recorded draw/dispatch batches against the existing recorder kept-byte budget. It covers direct storage operations,
ShaderResourcesreferences and draw targets, with per-image deduplication within each batch.The local checkout could not be built because its SDL2 submodule/system package is unavailable, and CI skipped compilation jobs, so this still needs runtime confirmation. Since you offered to rerun Wolverine, could you try this branch and share the same evicted-but-alive image counts and peak allocation/heap usage? That should show whether recorder-held references account for the survivors and whether recorder backpressure reduces overlap between evicted images and recreated copies.
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-14T19:39:32Z.
Opened #6030 for the abort part: the storage cache keeps new images in the open batch without their size, and an evicted image that recorded work still holds is not counted anywhere, so
Recorder::BoundKeptBytesnever bounds them. With their size in the batch's kept bytes, Wolverine ran 900 s on this card without the abort (296 non-fatal storage-texture allocation failures remain, peak heap usage 8.7 GiB). The eviction churn itself is unchanged.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Thunderhawkk on 2026-10-15T02:33:57Z.
Measured follow-up on the same machine (RTX 5070 Ti 16 GB, Windows 11 26200, driver 617.42) while bringing PPSA03671 up on current
mainwith #6194 in the build — the CPU side of the same scene, separate from the storage churn:APS5_PROFILE_DRAW,[resources]over 3000 builds: stage B 98–100 s, images 88–90 s; one dispatch (421,247-word shader) spent 9,575 ms in resources alone.image tables 0 reused, 703 resolvedper 10 s.FindReusedTablereportsno match100% with remembered tables = 0, because the remember gate is all-or-nothing: one element that is not a clean lookup (DCC address, storage-sourced view, …) discards the whole table.APS5_RESOURCE_CACHE_TABLE_ELEMENTS16× changes nothing; the ~4,000 resource-cache misses per 10 s are not a table-budget problem.Proposal (your call on safety): remember tables with per-element flags and reuse per element; gate cross-submission reuse on
GuestMemory::Watched(stamps trustworthy on watched ranges) instead of the thread epoch inTableState, which currently blocks all cross-submission reuse. I can implement and measure this on the title.A performance-trace capture can be produced on request.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T08:46:22Z.
I checked the current table reuse path. A potentially narrow option is to cache eligible elements within the existing collect-epoch and invalidation rules, so one ineligible element no longer prevents the rest of a table from being reused. I would keep the current memory, pending-write, depth-surface, allocation, and texture-cache checks;
Watchedalone is not enough because GPU writes have separate stamps. Could you capture, for repeated identical tables, how many elements meet the current direct-cache criteria (source == nullptr, nonzero generation, uncompressed keys, no DCC) and how many are rejected for each reason? That would show whether a focused same-epoch change would address measurable work.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T15:39:50Z.
The retained-image accounting fix has now merged in #5998 (merge commit
91ddd9e3a, now onmain). It charges storage images retained by recorded work to the recorder budget, addressing the reported case where evicted images stayed alive but were no longer counted. I have not rerun the original 8 GB Wolverine scenario on this merged main, so the title outcome remains unverified. The separate image-table reuse and eviction-churn work is still tracked in open PRs #6340, #6223, and #6194.