test(libSceNKWebKit): wait out the whole nap in the JscTimeLimit waiting test #26052
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26052"
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 danosovsky on 2026-11-23T06:16:01Z.
What
nkwebkit_jsctimelimitfailed about 1 run in 5 on Windows at the last check ofTestTimeSpentWaitingIsNotCounted(#26039). Two things in the test made that check race:nap()slept withstd::this_thread::sleep_for(400ms), which on Windows (WinLibs GCC 15.2.0) sometimes returns up to about 0.5 ms before 400 ms have passed onsteady_clock. It now sleeps the 400 ms and then sleeps 1 ms at a time untilsteady_clockreaches the 400 ms deadline. The 1 ms steps replace an earlier version that usedsleep_until(deadline)and still failed 15 of 60 runs with the old check.Clarification (edited after merge): this text first stated as fact that
sleep_untilwith the sub-millisecond rest becomes a 0 ms sleep on MinGW, spins, and charges CPU time to the limit. A later standalone measurement confirms that it loops (485 passes over 2 early naps), but shows no measurable extra CPU time per nap (at most 0.031 ms, against 0.032 ms with 1 ms steps), so why that version failed is not established. The merged code does not depend on it.The check required
nap + 50 msof wall time, but the 50 ms CPU limit starts atEval, so the CPU used before and during the nap is also charged to it. The check now requiresnapplus the part of the limit left whennap()returns. It still fails by about 50 ms if waiting were counted, because the limit would then fire as soon asnap()returns.WTF::CPUTimeandclock_gettime(CLOCK_THREAD_CPUTIME_ID)are not the cause: over a 500 ms busy loop in the test process the thread CPU clock reads 0.997-0.999 ofsteady_clock, andQueryThreadCycleTimecounts 0.995-0.999 of the TSC ticks in a standalone program.Timings from instrumented runs on
main(thirdnap()and the timedEval, both onsteady_clock):nap()EvalEvalTested
Windows 11 Pro 10.0.26300, AMD Ryzen 5 7600X, WinLibs GCC 15.2.0 r7 (
x86_64-ucrt-posix-seh), Release,main957c68fb42with this change (the test file is unchanged onmainsince):ctest -R "^nkwebkit_jsctimelimit$"alonenkwebkit_tests,-j 12mainpython tools/check_conventions.py --base origin/mainpasses;python tools/pr_overlap.py --branchreports no overlap.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-23T06:20:43Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
a10ee9fe22:tools/check_conventions.pypassed.nkwebkit_jsctimelimit_testsbuilt cleanly.nkwebkit_jsctimelimit):Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T06:22:38Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the reported Windows runs support the fix, but I could not run checks in this review environment.
What I ran
Reviewed head
a10ee9fe22c95da3f31d8c8a968caf020ba6901d. Readdescription.md,commits.md,manifest.json,diff.patch, and the full changed test file. No checks were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports Windows test runs and convention checks; I did not run or independently verify them. No changed files were excluded; the manifest lists one changed file and it was read in full.
files.jsonwas not available in the review folder.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T06:43:14Z.
Review: APPROVED
Reviewed exact head
a10ee9fe22c95da3f31d8c8a968caf020ba6901d. The steady-clock deadline handles early or spurioussleep_forreturns without charging a busy wait to the JSC CPU limit, and the revised lower bound subtracts the thread CPU time already consumed when the callback wakes.An independent Windows/WinLibs host probe reproduced the underlying early wake with a scoped 1 ms timer request: the old path returned below 400 ms in 1/30 runs. In the new path, the first sleep returned early in 2/30 runs (minimum 399.766 ms), but the deadline loop reached 400 ms in all 30. Wait-charged negative controls still failed both CPU and wall gates. This probe did not execute JSC itself.
The real
nkwebkit_jsctimelimitCTest built from this exact head passed in hosted Windows CI (3.37 s), and an independent Ubuntu run passed as well. All hosted checks are terminal with no failures. No blockers found.AI-assisted: yes.