test(libkernel): time blocking waits from before the writer thread starts #7670
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7670"
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:10Z.
What
guest_kqueue(PipeRead) starts a writer thread that sleeps 50 ms and then writes one byte to a pipe, and requires the main thread's blockingkeventto have waited at least 40 ms for it. The wait was measured from astarttaken after the writer thread was created. When the main thread is preempted between creating the writer and takingstart, the writer's 50 ms run partly or wholly beforestart, sokeventreturns sooner afterstartthan 40 ms although it did wait for the write, and the test aborts atGuestKqueue.cpp:246. This is the abort under parallel load that @wachi35676 (keventreturned 13 us to 35 ms into the wait) and @screamm reported on #7492.startis now taken before the writer thread is created, so the measured wait always includes the writer's sleep. The blocking read inguest_socket_events(GuestSocketEvents.cpp) has the same order, a sender thread that sends after 50 ms and a 40 ms check on astarttaken after the thread, and gets the same change. That sleep does not end early on Windows: with WinLibs GCC 15.2.0 r7, 120 calls ofsleep_for(50 ms)here took 58.2 to 77.6 ms (winpthreads rounds timed waits toGetTickCount64steps, #1471). Akeventthat returns before the write still fails the test: before 40 ms at the same check, later at thedata == 1check.Tested
Windows 11 26200, Ryzen 5 5600X, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON.main6685795f7, 8 parallel copies ofguest_kqueueplus 12 busy processes: 9 of 120 runs aborted (0xC0000409). With a local probe (not part of this PR) that printed the timings ofPipeRead, every abort looked the same (4 of 4): the main thread tookstart38.7 to 67.7 ms after creating the writer, the write came 28.5 to 39.6 ms afterstart, andkeventreturned 0.3 to 1.4 ms after the write withdata1. So the pipe was never reported before the write.sleep_for(50 ms): 120 calls took 58.2 to 77.6 ms (median 62.1 ms).main48d61f53b:guest_kqueueandguest_socket_eventspass 3 of 3 underctest --repeat until-fail:3. Run 15 times in a row with 24 busy threads, neithermainnor this change failed, so this machine needs the parallel load above to show it.guest_socket_eventsdid not fail onmainin our load runs; it is changed because its wait is measured the same way.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 github-actions[bot] on 2026-10-18T21:36:30Z.
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.
core/libs/tests/GuestKqueue.cppcore/libs/tests/GuestSocketEvents.cppcore/libs/tests/GuestKqueue.cppcore/libs/tests/GuestKqueue.cppcore/libs/tests/GuestKqueue.cppcore/libs/tests/GuestKqueue.cppcore/libs/tests/GuestKqueue.cppImported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-19T04:32:57Z.
Review: COMMENTED
Windows check of head
e0da1fb1c, merged ontomainccbd40240together with #7669, #7709, #7717 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600 (6 cores, 12 threads), WinLibs GCC 15.2.0 r7, Ninja Release,BUILD_TESTING=ON.guest_kqueueandguest_socket_eventspass,--repeat until-fail:3.Under load, with
main's and this PR's test binaries built from the same tree, started directly:mainguest_kqueueguest_kqueueguest_socket_eventsIn an earlier run that accidentally overlapped two of these batches,
main'sguest_kqueueaborted in 4 of 8 copies in one round.Requirethere callsabort()without a line, so I can't confirm these aborts are theGuestKqueue.cpp:246check. They do only show up onmain's binary.A note so nobody chases it: in two batches where this PR's
guest_socket_eventsran right aftermain's, 2 of 160 copies hung past my 60 s limit. With the order swapped, this PR's binary passed 160 of 160 first. So that depends on what ran before (16 copies at once leave many sockets behind), not on this change. It was a hang, not the 40 ms check, and this PR only movesstart.Code: taking
startbefore the thread is created makes the measured wait include the writer's whole 50 ms sleep, so the>= 40 msbound can't fail because of a slow main thread. AkeventorsceKernelWaitEqueuethat returns without the event still fails at the== 1/datachecks after it. The same order inGuestSocketEvents.cppis right for the same reason. I have no requests.AI-assisted: yes. I ran the build and the runs above.