perf(libkernel): return at once from a zero-timeout semaphore or event flag wait that cannot be satisfied #22073
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22073"
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 nicolasabosch on 2026-11-17T03:55:16Z.
What
sceKernelWaitSemaandsceKernelWaitEventFlagwith a timeout of 0 now returnSCE_KERNEL_ERROR_ETIMEDOUTas soon as the token or pattern check fails. Before, they queued a waiter, read the clock, ran the timed wait and woke the other waiters on the way out, only to time out. The results are the same as the slow path (the timeout stays 0 and the event flag reports its pattern), and the check order, the deleted and single-waiter errors and the token handout are unchanged. The event flag wait's clock reads that only feed theAPS5_TRACE_WAITStrace now run only when it is set.Overlap: #22055 makes
sceKernelWaitEventFlagwrite its result pattern and timeout through checked guest copies, in the same lines as this early return. If #22055 merges first, this PR will be rebased and its early return will report the pattern through the same checked write (ReportPattern). If this one merges first, #22055 needs to cover the early return too. #10558 adds test cases next to this PR's inGuestSemaphore.cpp; that conflict is textual.Tested
Windows 11, MinGW (GCC, Release), no title.
ctest -R '^(guest_semaphore|guest_semaphore_trace|guest_semaphore_handoff|guest_kernel_errors|guest_event_flag_wake|guest_event_flag_released_waiter|guest_wait_trace)$'passed (7/7);guest_semaphoreandguest_kernel_errorsgained cases for a zero timeout that is satisfied, that times out with and without another waiter queued, and that is followed by a signal.Performance: two 60 s captures each with
APS5_TRACE_SECONDS=660:60, same machine and session (NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Intel Core i9-14900HX, Windows 11 Pro 26300), warm shader caches, in the same scripted scene of EA SPORTS UFC 6 (PPSA23566, 01.004.000): the first practice fight of the tutorial ("LAND 5 PUNCHES"), reached through the menus withAPS5_PAD_SCRIPT. Both builds aremain2a8a0d1fc3plus the pad-script commit of #22064, which only injects the scripted input; the change adds this commit on top.mainseconds 660:60 from present 11012: 55 presents, frame p50 1004.2 / p90 1086.4 / p99 5716.0 / max 5716.0 ms, GPU busy 288.6 ms per presentseconds 660:60 from present 11464: 69 presents, frame p50 861.1 / p90 953.3 / p99 1027.6 / max 1027.6 ms, GPU busy 181.0 ms per presentseconds 660:60 from present 11549: 56 presents, frame p50 1071.4 / p90 1128.7 / p99 1215.3 / max 1215.3 ms, GPU busy 327.3 ms per presentseconds 660:60 from present 11552: 59 presents, frame p50 1038.4 / p90 1065.9 / p99 1115.4 / max 1115.4 ms, GPU busy 270.8 ms per presentBoth runs of the change present more often than both runs of
main(59 and 69 against 55 and 56), but the gain varies between runs: +5 % to +25 % presents, p50 frame time -3 % to -14 %. All traces reporttrace_droppedafter the queue-worker event buffer fills; the summary lines are complete. Traces andtrace_digest.pyoutputs:mainrun 1: trace, digest;mainrun 2: trace, digest; this change run 1: trace, digest; this change run 2: trace, digest.aps5-summary.jsonllinesmain, run 1:
main, run 2:
this change, run 1:
this change, run 2:
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T03:59:25Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
4d059d71b8:tools/check_conventions.pypassed.guest_kernel_error_tests,guest_semaphore_testsbuilt cleanly.guest_semaphore,guest_kernel_errors):core/libs/prx/libkernel/EventFlag/src/EventFlag.cpp,core/libs/prx/libkernel/Semaphore/src/Semaphore.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me