kernel: skip the locked read-modify-write when no signal is pending #1168
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1168
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1168/head"
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?
@romainhedouin on GitHub · 2026-10-07 22:37 UTC · original
romainhedouin:perf/pending-signal-fast-path→main· +3 −0 · 1 files · 1 commits · closed without mergingWhenever a thread wakes up from a sleep, a semaphore or a wait, it checks all 64 signal numbers for a pending signal. Each check was an atomic
fetch_and, even though nothing is pending almost every time.Now it reads the mask first and only does the
fetch_andwhen the bit is actually set. A signal that arrives right after the read is simply picked up on the next poll.On an M series Mac, checking all 64 signals on an empty mask takes 0.130 us instead of 0.208 us. With 4 threads checking the same thread object (synthetic) it is 0.13 us instead of 3.74 us.
What I tested, with a standalone test program built before and after the change: the bit semantics, out of range numbers, and 4 threads queuing signals while 3 others take them, checking each signal is delivered exactly once. It passes on main and on this branch, and it fails if I break the change on purpose (inverted check, or a load plus store instead of the
fetch_and). The emulator does not build on arm64 macOS, so I linked the existing objects by hand and stubbed the 9 symbols from the x86 only files. Not run on x86_64.I wrote this as a unit test but it seemed superfluous, let me know if I should add it to the PR
AI tools were used for code review and for drafting the checks I ran. I reviewed the diff and ran them
Pull request closed