You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(agc): skip the register read log while no log is open - #6066
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_address call, and a draw decode reads a few hundred registers.
A process-wide count of open logs (RegisterReadLogsOpen(), kept by the new RegisterReadLogScope) 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_address 6.09 to 2.35, pthread_getspecific 2.69 to 1.09, and Driver::decodeDraw 5.61 to 2.88.
The FPS shown in the title went from 4.66 to 5.00 (median of six readings).
Note: measuring base. These numbers come from main 0a56aaa, the last main before #5596. On Windows, later mains compare direct imports on every use, which keeps this menu at 3-4 FPS and hides a change of this size. The base also carries these commits from my fork, in both captures:
The comparison tool marks the window's first present (2148 vs 2229) as a configuration difference: the window opens 200 s into each run. Both summaries set trace_dropped, because the worker filled its event buffer at about 2,700 draws per frame. The phase totals above stay complete.
Checklist
Based on current main; no other open PR implements the same functions
One topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
No notes, investigation .md files or images added to the repository (attach them to this PR)
New third-party code is a submodule built from source
Measured on main 0ae1deb and on this branch (ec615c1), 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 main fa539dd with 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 910f3bc, this change 9b08cb0):
regread-traces.zip