Repository navigation
feat(agc): opt-in raised priority for the queue workers and the presenter - #1873
Conversation
d50cf53 to
c46440b
Compare
|
Added a unit test,
On the branch it passes. Also rebased on f145139. |
|
|
|
Windows run of the Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), GCC 15.2.0 (WinLibs r7), Release. Head The merge conflicts in
No title was run. 🤖 Addressed by Claude Code |
abe8eb6 to
2af260f
Compare
|
Done in 2af260f. The mode now picks one path up front, and a refusal throws:
Two new tests, Linux, RTX 5070 Ti, 595.91.07: @popcoder565 thanks for the Windows run. I added it to the description. AI-assisted: yes |
|
Rechecked the new head
🤖 Addressed by Claude Code |
2af260f to
12f2dec
Compare
12f2dec to
af32113
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Checked on Linux (merged onto main): AGC/VideoOut ctest is green apart from display-dependent video_out tests, and agc_thread_priority, _refused_rt and _refused_high pass. The fallback removal asked for earlier looks right. Three things to fix:
Submission.cpp:317-322:RaiseWorkerThreadPriorityruns in the thread lambda, outside thetryinDriver::run. When rtkit refuses, the exception escapes thestd::threadand callsstd::terminate, while the presenter reports its refusal through the constructor. Catch it there and send it throughDriver::ReportFailurelike the other worker failures, so a refusal surfaces the same way for both threads.ThreadPriority.cpp:288: any unrecognisedAPS5_THREAD_PRIORITYvalue (a typo likehgih) silently becomeshigh. Accept the documented values and throw on anything else, with a test row for it.tests/ThreadPriority.cpp:50: remove the code comment.
Not verified here: the real rtkit path and the Demon's Souls numbers (no title or rtkit on our side); the Windows path rests on @popcoder565's runs.
Read rtkit's MaxRealtimePriority and RTTimeUSecMax before touching the limit, keep a hard limit that already satisfies rtkit, lower the soft limit to at most half of the hard one, and log when the hard limit is lowered. rtkit checks the hard limit, so it cannot be left alone when it is above RTTimeUSecMax; the side effect is listed in TechnicalDebt.md. Log the policy rtkit applied, SCHED_RR by default.
af32113 to
0fe61e4
Compare
|
Merged onto current AI-assisted: yes (Claude Code Fable 5.1 xhigh) |
…and reject unknown APS5_THREAD_PRIORITY values
|
@adriadam10 Thanks. All three points are in f01f95d:
Tested on RADV (Ryzen 5 7600X iGPU, Mesa 26.2.1), because the NVIDIA GPU on this machine is down for now. The branch is still on a29ef59. AI-assisted: yes |
|
Checked
AI-assisted: yes (Claude Code Fable 5.1 xhigh) |
adriadam10
left a comment
There was a problem hiding this comment.
Checked f01f95d merged onto main on Linux (no rtkit): agc_thread_priority, agc_thread_priority_refused_rt/_high, agc_driver_pm4 and agc_driver_pm4_priority_refused pass. Without the Submission.cpp try/catch, agc_driver_pm4_priority_refused aborts, so the test covers the fix. Build and conventions are green on the head; Windows run by @popcoder565 on the previous revision. Merging.
What
Adds an opt-in
APS5_THREAD_PRIORITYthat raises the AGC queue workers and the VideoOut presenter above the title's threads. Guest priorities don't reach host scheduling, so a title whose job system busy-waits on every hardware thread can keep the queue 0 worker off a core and make the driver the bottleneck (#1788).=high: niceAPS5_THREAD_NICE(default -10). On Linux through rtkit (MakeThreadHighPriorityWithPID) over a dlopen'd libdbus-1, the way SDL does it. On Windows,THREAD_PRIORITY_HIGHEST.=rt: real-time priorityAPS5_THREAD_RT(default 10) through rtkit'sMakeThreadRealtimeWithPID. On Windows,THREAD_PRIORITY_TIME_CRITICAL.SetThreadPriorityrefuses, a queue worker sends the refusal throughDriver::ReportFailure, so the next submit, wait or shutdown rethrows it, and the presenter passes it back to the VideoOut constructor.off,highandrtare accepted. Any other value (hgih,1,realtime) is rejected the same way as a refusal.[thread-priority]. Unset means no change.RLIMIT_RTTIMEhandling for=rt(second commit, after @MarcZX100's review in #1788): rtkit'sverify_process_rttimereads the hard limit from/proc/<pid>/limitsand refuses when it is aboveRTTimeUSecMax(source). Lowering only the soft limit is not enough. With soft 100000 us and hard unlimited,MakeThreadRealtimeWithPIDreturns "Access denied"; with hard 200000 it succeeds. So the code now:MaxRealtimePriorityandRTTimeUSecMaxfirst. If rtkit is unreachable or the priority is above its maximum, the limit is not touched.min(APS5_THREAD_RTTIME_US, RTTimeUSecMax), and otherwise lowers it to that value. The soft limit goes to at most half of the hard one.An unprivileged process cannot raise the hard limit again, so once lowered it stays lowered even if rtkit then refuses (burst limit, user or start-time checks). That is listed in TechnicalDebt and in BUILD.md. The log also reports the policy rtkit applied:
SCHED_RRby default, notSCHED_FIFOas the issue says.Why opt-in: it changes host scheduling for every title, rtkit is not on every system, and under
=rta queue worker that runs pastRLIMIT_RTTIMEwithout blocking gets the process a SIGXCPU. #626 (P-core pinning on hybrid CPUs) is complementary.Closes #1788.
Tested
Latest revision (f01f95d), on the same base a29ef59: the NVIDIA GPU on this machine is down for now, so these runs are on RADV (Ryzen 5 7600X iGPU, Mesa 26.2.1).
ctest -R agc_ -j1: 325 of 326. The one failure,agc_driver, segfaults onmainbf6e25a on RADV as well.agc_driver_pm4_priority_refused(new) submits a write withAPS5_THREAD_PRIORITY=highand no rtkit, and expects the refusal fromWaitIdleand from shutdown, with the write not executed. Without theSubmission.cppchange the process aborts instd::terminate.agc_thread_priorityfails without the parser change onAPS5_THREAD_PRIORITY=hgih must be rejected.Earlier revisions:
Linux 7.2 (Nobara 44), GCC 16, RTX 5070 Ti, driver 595.91.07, Ryzen 5 7600X. Rebased on
maina29ef59.ctest -R agc_ -j1on a29ef59 with the variable unset: 324 of 325. The one failure,agc_driver_dcc_keys_first_write, also fails onmain. On the earlier base d70b899: 259 of 260 unset, and the same withAPS5_THREAD_PRIORITY=highand with=rt.agc_thread_priority_refused_rtand_highrun the raise with the system bus pointed at a missing socket and pass only if it throws.ctest -R agc_driver -j1202 of 202, unset and with=rt. In thertrun the queue workers logSCHED_RR 10 via rtkit, and the hard limit is lowered from unlimited to 200000 us once per process.RaiseWorkerThreadPriority(=rt): hard limit unlimited is lowered to 200000 (soft 100000); a preset soft 30000 / hard 150000 is left as is and rtkit grants;APS5_THREAD_RT=99(aboveMaxRealtimePriority20) and an unreachable system bus leave the limit untouched (that run predates the throw).python3 tools/check_conventions.py --base origin/main: passes.=highthe PS Studios movie went from 254-255 to 345 presents per 10 s, and the attract movie from 429-447 to 520-536 presents per 10 s. With the priority on, the boot-time capture race from AGC: a compute dispatch is captured before the title has written its tables when a cross-queue wait passes on a recorded label #1787 became more likely; with that fix, 15 of 15 runs were clean.agc_thread_prioritypasses, and the threads loghighest/time-criticalin the two modes.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