perf(agc): answer verifications of the caller's own live stack without a page query #459
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/459"
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 oneandonlydean on 2026-10-03T13:52:09Z.
What
Driver::Submitchecks the title's submission packet withGuestMemory::CheckRange, and titles pass that packet on their own thread stack. Host thread stacks are neither registry mappings nor write-watched, so no cached page table covers them, and on Linux every such check scans/proc/self/mapsline by line. In PPSA21564 that was about 1.5 ms per submission on the render thread, 66% of that thread's samples inperfat the title screen.A range between the calling thread's current frame and the top of its stack holds the frames of every caller, so it is mapped readable and writable for as long as the call lasts.
verify()now accepts such a range without a page query:pthread_getattr_np(Linux) orGetCurrentThreadStackLimits(Windows), once per thread;GetCurrentThreadStackLimitsneeds_WIN32_WINNT0x0602 on MinGW, as libkernel already sets. Several targets compileGuestMemory.cpp, so the definition is a property of that source file.#157 caches the parsed maps for these queries; if it lands, this saves less, and I will measure it again then. #157 already conflicts with
maininGuestMemory.cpp.Tested
BUILD_TESTING=ONandctestpass (145/145).RunLiveStackAccessTestsinagc_driver_graphics_tests(tests/LiveStack.cpp): a packet on the test's own stack is accessible and passesCheckRange; a thread on a stack of its own with an inaccessible page above and one at the bottom sees its stack top accessible, a range past the top and the page above it rejected (AccessibleandCheckRange), and the inaccessible page below its frames rejected. After the thread ends, that memory is reported as the page query says. The checks bound the new path: dropping the past-the-top bound fails with "a range past the stack's top counts as accessible", and starting the accepted range at the stack's bottom instead of the frame fails with "an inaccessible page of the stack below the live frames counts as accessible". Without the change the test passes too, since the answers are the same; only the cost differs.CheckRangeon the stack, in the test process (a short maps file): 12.3 us before, 0.01 us after. The title's maps file has thousands of lines (mostly driver mappings), hence the 1.5 ms above.GuestMemory.cpp,BdaTests.hppandtests/Graphics.cpp; the two merge cleanly in either order.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)