AGC: whole-registry leases make every guest munmap/mprotect wait for GPU work; Onimusha (PPSA27836) drops below 1 FPS for 15-20 s at a time #6453
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 simonbronk on 2026-10-15T16:04:28Z.
Summary
In Onimusha: Way of the Sword (PPSA27836), the controller-layout screen runs at about 9.7 FPS. Every minute or two it drops below 1 FPS for 15 to 20 seconds. Each drop matches a burst of guest
munmap/mprotectcalls on GPU-registered memory. Each of those calls waits inGuestAllocationsRequireUnpinneduntil GPU work finishes. The pin waiter (WaitForLeasesAndImports) then mostly drains the whole recorder under the GPU mutex, so queue 0's draws slow down 3 to 30 times.The blocks being freed are not what the GPU holds. A
GuestAllocations::Leaseis a snapshot of every readable range (GuestAllocationsAcquire/AcquireAll). Any batch that keeps a lease therefore raises theuse_countof every registered range, andRequireUnpinnedtreats every range as pinned while such a batch is in flight.Setup
Windows 11 26200, RTX 5070 (NVIDIA 617.42), WinLibs GCC 15.2, Release.
main0afa6a607plus the title's open PRs (#5907 #5776 #5770 #5703 #5841 #5884 #5915 #5815). Warm shader cache,APS5_PROFILE_DRAW=1,APS5_TRACE_SUMMARY_EVERY=5. The title sits idle on the controller-layout screen with no input.Measurements
Per 10 s window, from the
[address-sync]and[draw] driver phaseslines (pin counters are deltas):Graphics::Drawper drawDuring a stall the frame summaries show queue worker 0x0 at 99.9% busy, and frame p50 goes from 104 ms to 1.3 to 2.1 s. In the same runs, GPU fence waits from draws (
[recorder]sync sites) barely move. RAM and VRAM stay flat.The waiting calls come from a local trace in
GuestAllocationsRequireUnpinned, not for merging. Over 150 s from boot there were 11,309 waits, 34 s in total:UnmapRegistered9,725,DoMprotect1,584use_countof the pinned range: 3 in 11,190 cases, i.e. the registry plus the two shared lease snapshotsGameThread,JobThread(High),ResourceManager::parallelProc/loadProc. On the idle screen:JobThread(High)andMovieDispatcher.Why it looks avoidable
The 64 KiB blocks are distinct addresses in the title's heap. A wait only ends once every batch holding any lease completes, because the snapshot holds every range. If the pin check were limited to the ranges a batch actually binds, imports, or writes back into, most of these unmaps would not wait at all.
Related, but none covers this:
AcquireAround): lease copy cost.How would you want leases scoped: per batch, with the ranges each one touched, or something else? I can test a change on this title on Windows (NVIDIA and AMD).
AI-assisted: measured with Claude Code. The trace patch was local and has been removed.
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-15T18:30:34Z.
Follow-up: two local experiments (not for merging). Same machine and base, Onimusha booting to the menu, 150 s,
APS5_PROFILE_DRAW=1.1. Skip the wait when it looks safe. A filter in
GuestAllocationsRequireUnpinned, run before the pin waiter with the registry lock released, under the GPU mutex. It let the mutation through only when the bytes overlap no live or parked host import, no recorder pending write (PendingWriteOverlaps) and no pending image result (StorageTexture::AnyPendingOverlaps).So nearly every unmapped 64 KiB block lies inside a live host import, and a filter of this kind cannot help.
2. Never wait (unsafe, to find the upper bound). The filter passed everything. Pin waits dropped to 0 (0.0 s, against 24.1 s in a matching run without the filter). The run then failed within 20 s on the driver side:
So the whole-registry lease also protects the driver's own CPU reads of guest memory, not only the GPU's access through imports. Narrowing which ranges a lease pins is not enough on its own.
Given that, I see two directions, both beyond a quick local change:
RequireAvailable).Which of these, if either, fits the GuestBufferMemory design? I'm happy to measure a branch on this title.
AI-assisted: experiments with Claude Code. Both patches are reverted.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:44:05Z.
I checked the current waiter and import tracking.
HostImport::lastUseis an LRU/use counter today, not a recorder submission serial, and the waiter currently finishes the newest batch holding any address-space lease before retiring overlapping imports. #6182 handles the distinct oversized-registration case where non-overlapping windows keep one allocation range pinned.For this report, a useful split test would be to record (a) which import windows actually overlap each
munmap/mprotectrange and (b) the last recorder batch that used those imports, then compare a wait through that serial with the current newest-lease wait. The title’s experiment shows we must retain the overlapping import and any CPU-read protection until its work completes; it does not show that unrelated leased work must also finish. A regression fixture should keep an unrelated import/batch in flight while mutating a separate range and verify the unrelated work is not drained, then verify the overlapping import is retired only after its last GPU use. I have not implemented this path or claimed the title workload is fixed.