perf(agc): skip the register read log while no log is open #6066
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6066"
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 meh7an on 2026-10-14T21:09:26Z.
What
Every register read of a draw's decode goes through
NoteRegisterRead, which checks the thread's register read log (RegisterReadLog(), thread-local). Only the draw recipe verification and the tests ever open one. Under MinGW a thread-local access is an__emutls_get_addresscall, and a draw decode reads a few hundred registers.A process-wide count of open logs (
RegisterReadLogsOpen(), kept by the newRegisterReadLogScope) now lets a read skip the thread-local lookup while no log is open. Logs are per thread, so a count of zero means no thread has one. The decode and the tests open their logs through the scope.On the S2 page of Sonic Origins Plus's main menu, the queue worker's samples per frame (APS5 sampler, 15 s) fell as follows:
__emutls_get_address6.09 to 2.35,pthread_getspecific2.69 to 1.09, andDriver::decodeDraw5.61 to 2.88.Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.
agc_driver_graphicson mainfa539dd9bwith this change. Its register read checks open their logs through the new scope.APS5_TRACE_SECONDS=200:5on the same machine in one session, caches warm. Traces attached.The FPS shown in the title went from 4.66 to 5.00 (median of six readings).
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Traces and summary lines (baseline 910f3bc97cde, this change 9b08cb001ad5):
regread-traces.zip
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-14T22:02:17Z.
Measured on main
0ae1deb85and on this branch (ec615c145), default CMake build (CMAKE_BUILD_TYPE empty, so unoptimized), lavapipe (llvmpipe), CachyOS Linux 7.2.9,agc_driver_graphics_tests, rebuilt for each ref: 5 of 5 runs pass on both.I read the diff.
RegisterReadLogsOpen()counts open scopes, and the register hook returns early when it is 0. Because the log pointer is thread-local and the counter is global, a scope open on another thread only makes the hook fall through to the old thread-local check, so it never records wrongly.Limits: the added assertion (
the register facade recorded without an open log) does not show the speedup; by reading, the same check holds on main's code too (the pointer is null after the scope). I did not measure the performance change, and I ran only this one test target.AI-assisted: yes