fix(libSceLibcInternal): sleep precisely in _Thrd_sleep_for on Windows #18299
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18299"
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 AlfaRojo on 2026-11-11T04:41:40Z.
What
On Windows,
std::__sce_v2::_Thrd_sleep_for(_ZNSt8__sce_v215_Thrd_sleep_forEm, libSceLibcInternal) slept throughstd::this_thread::sleep_for, which winpthreads ends on 15.6 ms timer ticks, so a 1 ms guest sleep took about 15.6 ms. It now sleeps throughPreciseSleepHundredNanos, the helper libc's_Thrd_sleephas used since #8129. This is one of the timed-wait call sites #1471 still tracks; it does not close that issue.The zero-duration yield, the one-day chunking and the non-Windows path are unchanged, and no guest semantics change. The debt entry for the function now names both sleep paths.
Tested
Windows 11 Pro 10.0.26200, WinLibs GCC 15.2.0 r7 UCRT, Release, Ninja. Not built or run on Linux or macOS; those platforms compile the same
sleep_forline as before.200 calls of
_Thrd_sleep_for(1), three runs each, same machine:main774111474cguest_relative_sleepgains a check that 20 repeated 1 ms sleeps take at least 20 ms and less than 200 ms, the boundsGuestSelect.cppandGuestSelectWait.cppuse. With only the test added onmainit fails in 3 of 3 runs ("repeated 1 ms sleeps took the wrong total time"); with the fix it passes in 3 of 3 runs, andguest_relative_sleepplusguest_relative_sleep_largepass in 10 of 10 repeated runs.tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pyfound no conflicting line in the pull requests it could compare and failed closed on ten that conflict withmainthemselves (#5021, #13778, #13782, #14212, #14660, #14834, #15822, #17300, #18081, #18135); they share onlydocs/dev/debt/libSceLibcInternal.md, and none of their diffs has a line naming_Thrd_sleep_fororRelativeSleep.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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T04:45:25Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c4d26cd6f3:tools/check_conventions.pypassed;git diff --checkclean.guest_relative_sleep_testsbuilt cleanly.guest_relative_sleep,guest_relative_sleep_large):Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T17:51:22Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c4d26cd6f3:tools/check_conventions.pypassed;git diff --checkclean.guest_relative_sleep_testsbuilt cleanly.guest_relative_sleep,guest_relative_sleep_large):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T19:15:27Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
The change routes the Windows path of
_Thrd_sleep_forthroughPreciseSleepHundredNanos, keeps the zero-duration yield and the one-day chunking, and the code reads as intended at headc4d26cd6f3bfa80f5115e898e8b6e1e0e4019106.What I ran
c4d26cd6f3bfa80f5115e898e8b6e1e0e4019106, basemain.repo_read.py searchandrepo_read.py cat.Commands
Results
RelativeSleep.cpp, full textGuestRelativeSleep.cpp, full textPreciseWait.hppprx/libcheaderscheck_conventions.pyNegative control
Not run here. The author reports that the new test fails on
mainin 3 of 3 runs and passes with the fix.Findings
Blocking
None.
Non-blocking
None.
Sources
Read at head
c4d26cd6f3bfa80f5115e898e8b6e1e0e4019106:core/libs/prx/libSceLibcInternal/RelativeSleep.cppcore/libs/prx/libc/include/PreciseWait.hppcore/libs/tests/GuestRelativeSleep.cppdocs/dev/debt/libSceLibcInternal.mdNot verified
_Thrd_sleephas usedPreciseSleepHundredNanossince #8129, and that #1471 still tracks this call site. I did not check the history.tools/pr_overlap.pyresult against other open pull requests.sleep_forpath.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T01:03:11Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c4d26cd6f3:tools/check_conventions.pypassed;git diff --checkclean.guest_relative_sleep_testsbuilt cleanly.guest_relative_sleep):core/libs/prx/libSceLibcInternal/RelativeSleep.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me