libkernel (Windows): guest_raise_exception slowed about 3x and sometimes aborts at "address waking" since 540364a24 (#10666) #11813

Closed
opened 2026-10-27 08:39:51 +00:00 by babyhuey · 0 comments
babyhuey commented 2026-10-27 08:39:51 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-27T08:39:51Z.


What happens

On Windows, guest_raise_exception got about 3x slower after #10666 and now sometimes aborts. Its HandlerLeavesAddressLock(AddressWaking, "address waking") case (core/libs/tests/GuestRaiseException.cpp:757) raises SIGUSR1 at a thread that loops on sceKernelSyncOnAddressWake, and the handler now sometimes doesn't run within the test's 5 s limit:

address waking round 0: the handler did not run within 5 s
FATAL: abort() (SIGABRT) on thread 60928

The process then exits with 0xc0000409. When it doesn't abort, the test passes in 51-57 s instead of about 18 s, which is close to the 60 s ctest timeout, so under select_tests.py ctest --parallel 4 it fails or times out in most runs. GuestRaiseException.cpp itself is unchanged in this range. This is separate from closed #9610, which measured the same AddressWaking case at about 14.8 s over 50 raises before #10666.

Bisect

Windows 11, Ryzen 7 5800X, WinLibs GCC 15.2, Release, only guest_raise_exception_tests built, run alone, two runs per commit. Bad = a failure or over 35 s.

commit run 1 run 2 verdict
c72ed0b7c87 (#10666's first parent on main) pass 17.6 s pass 17.9 s good
169f3e3e736 (#10666 merge) abort 28.9 s ("address waking round 15") pass 55.1 s bad
1b9c5feb302 (540364a24's parent on the branch) pass 11.3 s pass 11.4 s good
540364a24f4 pass 40.6 s pass 55.0 s bad

Before the bisect: main 27ad7244d22 passed 3 of 3 alone (17.6-18.5 s), and main 0a570f617d8 failed 1 of 3 alone (the abort above at 16.4 s; the passes took 52.7 and 57.5 s). Under --parallel 4 on 0a570f617d8 it failed in all 8 runs that selected it, by the abort or the 60 s timeout.

The first bad commit is 540364a24 ("queue a raise's APC only for a thread in a libkernel wait"). AddressWaking spends its time inside sceKernelSyncOnAddressWake, which isn't a libkernel wait, so waitCount is 0 there and the raise no longer queues the APC. Delivery then has to wait for the thread to come back to guest code. This matches the slowdown, but I haven't traced which part takes the time.

Possible directions

  • Keep the APC gate from 540364a24 (running the handler in an arbitrary alertable host wait with a lock held is what it prevents), and make delivery to a host-code target that isn't waiting faster, so the address-waking case returns well inside the limit again.
  • Or, if the slower path is acceptable, change the test's time limits instead, though a 3x slowdown of a raise at a busy thread may matter to titles too.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6055752311 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/11813). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-27T08:39:51Z. --- ### What happens On Windows, `guest_raise_exception` got about 3x slower after #10666 and now sometimes aborts. Its `HandlerLeavesAddressLock(AddressWaking, "address waking")` case (`core/libs/tests/GuestRaiseException.cpp:757`) raises SIGUSR1 at a thread that loops on `sceKernelSyncOnAddressWake`, and the handler now sometimes doesn't run within the test's 5 s limit: ```text address waking round 0: the handler did not run within 5 s FATAL: abort() (SIGABRT) on thread 60928 ``` The process then exits with `0xc0000409`. When it doesn't abort, the test passes in 51-57 s instead of about 18 s, which is close to the 60 s ctest timeout, so under `select_tests.py ctest --parallel 4` it fails or times out in most runs. `GuestRaiseException.cpp` itself is unchanged in this range. This is separate from closed #9610, which measured the same `AddressWaking` case at about 14.8 s over 50 raises before #10666. ### Bisect Windows 11, Ryzen 7 5800X, WinLibs GCC 15.2, Release, only `guest_raise_exception_tests` built, run alone, two runs per commit. Bad = a failure or over 35 s. | commit | run 1 | run 2 | verdict | |---|---|---|---| | `c72ed0b7c87` (#10666's first parent on `main`) | pass 17.6 s | pass 17.9 s | good | | `169f3e3e736` (#10666 merge) | **abort** 28.9 s ("address waking round 15") | pass 55.1 s | bad | | `1b9c5feb302` (`540364a24`'s parent on the branch) | pass 11.3 s | pass 11.4 s | good | | `540364a24f4` | pass 40.6 s | pass 55.0 s | bad | Before the bisect: `main` `27ad7244d22` passed 3 of 3 alone (17.6-18.5 s), and `main` `0a570f617d8` failed 1 of 3 alone (the abort above at 16.4 s; the passes took 52.7 and 57.5 s). Under `--parallel 4` on `0a570f617d8` it failed in all 8 runs that selected it, by the abort or the 60 s timeout. The first bad commit is `540364a24` ("queue a raise's APC only for a thread in a libkernel wait"). `AddressWaking` spends its time inside `sceKernelSyncOnAddressWake`, which isn't a libkernel wait, so `waitCount` is 0 there and the raise no longer queues the APC. Delivery then has to wait for the thread to come back to guest code. This matches the slowdown, but I haven't traced which part takes the time. ### Possible directions - Keep the APC gate from `540364a24` (running the handler in an arbitrary alertable host wait with a lock held is what it prevents), and make delivery to a host-code target that isn't waiting faster, so the address-waking case returns well inside the limit again. - Or, if the slower path is acceptable, change the test's time limits instead, though a 3x slowdown of a raise at a busy thread may matter to titles too. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#11813
No description provided.