Repository navigation
perf(kernel): read the wait clock only when wait tracing is on - #18864
Conversation
sceKernelWaitSema read steady_clock before and after every wait and passed the difference to KernelTraceWait_nid_postfix, which returns at once unless APS5_TRACE_WAITS is set. The wait now reads the clock only when the variable is set, through one cached flag shared with the trace function. A signal+wait pair drops from 88 ns to 39 ns and from 1909 to 1069 instructions; with a timeout, from 147 ns to 87 ns. The result codes, the wait conditions and the trace output are unchanged.
|
This pull request is labeled |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows check of head 253 of the 254 selected libkernel tests pass in 3 of 3 runs. The selection covers the wait-clock call sites this PR touches; 28 of the selected targets are not built on Windows and were dropped. The one failure, This is a correctness check only; I did not measure the timing change. AI-assisted: yes. |
What
sceKernelWaitSemareadsteady_clockbefore and after every wait and passed the difference toKernelTraceWait_nid_postfix, which returns at once unlessAPS5_TRACE_WAITSis set. The wait now reads the clock only when the variable is set, through one cached flag shared with the trace function. Result codes, wait conditions and trace output are unchanged.On a signal-and-wait pair on one kernel semaphore (single thread, alternating runs of the parent and the change) the cost drops from 88 ns to 39 ns and from 1,909 to 1,069 instructions; with a timeout, from 147 ns to 87 ns. The figures are a fixture measurement, not a title trace.
Tested
macOS 27.0.1, Apple M3 Max (36 GB), Release build with
-DBUILD_TESTING=ON, x86_64 under Rosetta 2.maindoes not run its libraries on macOS, so both sides aremain3b7f31fa7with the macOS port (the squash of #8658, which its author upstreams in parts) and local macOS build fixes for tests ofmainthat Apple clang refuses; the change side adds this PR's commits.guest_*tests whose names match semaphore, condition, mutex, event, wait, sync, thread, sleep, timer and the like), same regex on both sides: 242 tests match on both sides; 240 pass and 2 abort on both:guest_kernel_sys_wait_wait4andguest_kernel_sys_wait_wait4_patchedexpect ECHILD fromwait4(INT_MIN)and macOS answers EINVAL. No test changes status.python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyfound no open pull request that changessceKernelWaitSemaor the wait trace flag.Not tested: Linux and Windows.
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)