test(libkernel): give the positioned close test a real 300 us head start #7669
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7669"
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 thuanquang on 2026-10-18T21:25:04Z.
What
guest_positioned_close(from #5938) gives the reader thread a 300 us head start beforesceKernelClose, so that close lands while the 32 MiBsceKernelPreadholds the positioned-transfer lock, and it requires at least one of its 60 rounds to overlap that way. On Windows the head start is not there: with the WinLibs toolchain,std::this_thread::sleep_forof anything below 1 ms returns at once. libstdc++ calls winpthreads'nanosleep, which converts the request to whole milliseconds, so 300 us becomes 0 and no wait happens (#1471 tracks the same thing for production code). Close then races the reader's first instructions in every round, and a run where all 60 rounds lose the race aborts withPositioned close check failed at line 69. That is the intermittent failure onmainreported in #7532 (5 of 30 runs on a VM) and #6972.The test now waits with
PreciseSleepUs(300), the sub-millisecond wait production code uses since #1551.Tested
Windows 11 26200, Ryzen 5 5600X, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, onmain48d61f53b.sleep_forof 50, 300 and 999 us took 0.0 us (median of 200 calls each); 1000 us took 15.6 ms.overlapped(not part of this PR), 30 runs each on an idle machine:main56 to 60 of 60 per run (median 59), this change 60 of 60 in every run. With 24 busy threads both overlapped 60 of 60 in 10 runs each: on this machine a loaded main thread is slow to close, so the reader wins. The failing runs in #7532 come from a host where close wins every round, which the real 300 us head start rules out.guest_positioned_closepasses with the change. I did not reproduce the abort on this machine: 45 runs ofmainunder load passed.python tools/check_conventions.py --base origin/mainwith this title and body passes.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 karimibrahim07 on 2026-10-19T04:32:55Z.
Review: COMMENTED
Windows check of head
2c75b6c5b, merged ontomainccbd40240together with #7670, #7709, #7717 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600, WinLibs GCC 15.2.0 r7, Ninja Release,BUILD_TESTING=ON.std::this_thread::sleep_forof 50, 300 and 999 us took a median of 0.1 us (max 2.2 us), and 1000 us took 15.6 ms. That matches your numbers, so onmainthe test's 300 us head start isn't there.PreciseSleepUs(300)fromPreciseWait.hpp, 200 calls on a loaded machine: 368 to 634 us, median 500 us. It always waits at least what was asked, so the head start is real now.guest_positioned_closepasses,--repeat until-fail:3.main's test and this one both passed. Like you, I didn't reproduce the #7532 abort on this machine. There was one abort, in this PR's binary, at line 35 (create_directory). That one comes from my harness: 8 copies in the same working directory, two of which picked the samesteady_clockdirectory name. It isn't the overlap check, and ctest never runs two copies at once.Code:
PreciseSleepUsis what production code uses for sub-millisecond waits since #1551, and on Windows it takes thePreciseSleepHundredNanospath, not winpthreads'nanosleep. The include is the only other change. I have no requests.AI-assisted: yes. I ran the build, the probe and the runs above.