AGC: registered shaders keep decoded programs and resource plans resident; UFC 6 (PPSA23566) exhausts host memory on a 32 GB machine #6139
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 mcsilva-dev on 2026-10-14T23:08:36Z.
What happens
EA SPORTS UFC 6 (PPSA23566, 01.004.000) registers thousands of shaders during start-up. On a 32 GB machine the process commit grows about 8 GB per minute until it ends with
raised in the shader recompiler (
ShaderRecompiler::ValidateProgram,MaskedSelectEliminator::Eliminate,SpirvEmitter::Emit), about 570 s in, at roughly 80 GB of commit. The window stays black until then.How it was measured
VirtualQueryExover the process: the guest direct-memory reservations stay uncommitted; the growth is host heap segments (~16 MB NT heap segments, mostly zero-filled).operator new/deleteoverride in libSceAgcDriver counted live bytes per caller (blocks of 1 KB and up exactly, smaller ones sampled 1 in 64). libSceAgcDriver held about 31 GB live of 38 GB process commit.The two holders
RegisteredPreparation::decoded: 18.7 GB in 12,882 blocks fromShaderRecompiler::DecodeRdnaProgram. Every queued registration preparation keeps its decoded RDNA program (~1.5 MB;DecodeRdnaProgramreserves oneRdnaInstructionper code word) while it waits in the background queue, although onlyPlanRegisteredreads it (UnresolvableSwappcTarget). Releasing it beforePlanRegisteredreturns removes this holder completely; I will open a pull request for that.ShaderDiskCache::DecodePlan, plus ~3 GB underIrValue::AddArgument. Each registered shader keeps its resource plan (~3 MB of IR) resident whether or not it is ever drawn. The title registers ~8,600 shaders before its first frame; ~200 are used up to the title screen.Workaround tested locally
With holder 1 released, commit still grew from holder 2. As a local workaround I added a switch that sends every shader down the existing deferred path (
prepared->deferred = true, no registration preparation), so it is prepared at first use. With both changes the process holds ~9.9 GB, stable, the title screen appears in ~30 s with a warm shader cache, and the main menu is reachable (~11 presents/s at the title screen).The switch trades memory for first-use stalls, so it is probably not the right default. Would you prefer bounding the resident plans (dropping plans of shaders that were prepared but never drawn and reloading them from the disk cache), or another approach? I can work on it in that direction.
Setup
Windows 11 Pro, Intel i5-14600KF, 32 GB RAM + 38 GB page file, AMD Radeon RX 9070 XT, WinLibs GCC 15.2.0, Release + libs,
ANYPS5_ENABLE_SPIRV_TOOLS=ON. Basemainbebff8b0e; the same code is unchanged on currentmain. Bring-up thread: #5996.AI-assisted: yes (Claude Code). The measurements are from runs on this machine.
Imported from boykopovar/AnyPS5. Originally posted by mcsilva-dev on 2026-10-15T02:26:56Z.
Update: the UFC bring-up fork in #5996 (
0xcrstn/AnyPS5ufc6/testing, c222bd2c2) already addresses both holders, independently of this report, and is probably a better shape than my local switch:PlanRegistered,decodedis a local; it moves into the plan only when the plan awaits callees (awaitsCallees), which reads it later (LinkUserDataCalls,FindUserDataCalls). So releasing it unconditionally, as I first did, would be wrong on that branch; keeping it local is the right fix.APS5_REGISTRATION_PREPARE_LIMITand then only while the process commits less thanAPS5_REGISTRATION_PREPARE_COMMIT_GB(default: half of physical memory); past that, shaders take the deferred path. On this 32 GB machine the fork holds ~10.5 GB at the title screen, stable, with no local change, versus ~80 GB andstd::bad_alloconmain.Measured on the same machine (Windows 11, i5-14600KF, 32 GB, RX 9070 XT). Frame-time work on the same title is in #6197 and the progress report in #5996.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-21T02:05:23Z.
Another data point for the fork in #5996 (
0xcrstn/AnyPS5ufc6/testing, c222bd2c2), on Intel + NVIDIA:--windows --to-intel --windows-diagnostics --registry --module-dir .(withEngine.Render.Core2.PlatformPs5.prxbesideeboot.elf, see #6336)APS5_PIPELINE_COMPILE_AHEAD=1,APS5_PIPELINE_COMPILE_THREADS=4,APS5_THREAD_PRIORITY=high,APS5_PREPARE_PRIORITY=normal,APS5_PREPARE_THREADS=14Memory: stable at ~10 GB once the shader cache is warm, as reported above. The first run after new content shows up is slow for a while: about 180 compute pipelines (75k–190k SPIR-V words) compiled one at a time, ~208 s in total. The next run reads them from the pipeline cache.
Frame rate:
Title screen at ~20 FPS. About half of queue worker 0's time went to CPU storage uploads: ~1,550 per 10 s (~6.2 GB), each with a full sync (
StorageTexture::upload→GuestMemory::ReadCommitted→Recorder::SyncThrough, thenCommandBatch::Wait). Their refusal reason isnot registered. The title remaps a pool at 0x11c0000000 in separate 8 MiB pieces, each a registered range, the host import window is also 8 MiB, and render targets that straddle a piece's edge failrunCovers. A local experiment that falls back toimportJoinedinimportAccessfor such accesses (as buffer accesses already do) brought CPU uploads to 0 and the title screen to ~35 FPS with no import churn (27 joined imports, none retired). It doesn't change the cinematic. Not submitted; happy to open a PR if this is the right direction.Cinematic at ~2 FPS. It's an in-engine scene, not a movie: ~3,200 draws and ~85 GPU batches per frame. Queue worker 0 is at ~97%; the GPU reports ~1.2 s of work per 10 s (
[gputime]). Per frame:Packet.draw~350 ms andPacket.memory_wait~280 ms. The draw recipe cache almost never applies:[recipe] drawshows ~100 hits against 20,000–27,000no recipeper 10 s, because no recipe gets built. Counting the first failing condition of the recipe build inGraphics::Draw: ~85%!resolved.moved.empty()(a template hit whose read-only buffers moved; constants in a new ring-buffer slot every frame) and ~15% not cacheable. Allowing recipes with moved buffers (repeatingMovedReadOnlyBuffersafterProveCurrenton a hit and passing them asrecord.moved) builds recipes, but they still match only 0.5–10% of draws. The stage variants are replaced each frame (Driver::cloneVariantfromrelocateDrawEntry), soDrawRecipeRecord::Matchesnever finds the old ones. No FPS change, so I'm not proposing that yet.Dump note in case it helps others: a null dereference in a
ConcurrentExecutor_global_0job atexe+0x3f254cd, about 10 s after the first frame, was not an emulator bug. My dump was missingData/Ps5/superbundlelayout/ufc_installpackage_02/cas_23–27,_03,_05,_06and_07, all listed inapp0/ampr_emu.index. The title gets ENOENT forufc_installpackage_05/cas_01.casand derefs an unbound resource slot. With the full dump it gets past that point.AI-assisted: yes (Claude Code).