kernel: start the semaphore wait timer after the early returns #1173
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!1173
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1173/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 23:46 UTC · original
romainhedouin:perf/semaphore-wait-timer→main· +6 −6 · 1 files · 1 commits · merged 2026-10-08 15:21 UTCWait()started a timer and looked up the thread id before checking for an available token. Both are only needed when the thread has to block, so they now come after the early returns.Uncontended signal then wait on an M4 Macbook: 70 ns to 51 ns, so about 19 ns saved per wait that finds a token.
Only matters if the waiting thread is the bottleneck.
I ran the old and new objects through a standalone test (return codes, timeouts, wakeups, cancel, delete, 120,000 tokens across 4 producers and 6 consumers) and the output is identical. Not run on x86_64 or with a game.
AI tools were used for code review and for drafting the checks I ran. I reviewed the diff and ran them
@coderabbitai[bot] on GitHub · 2026-10-07 23:55 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
9d80cdf6-bbee-4f0c-909f-54ee01afccbb📥 Commits
Reviewing files that changed from the base of the PR and between
5a8808086aand2309fa57ce.📒 Files selected for processing (1)
src/kernel/semaphore.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough
KernelSemaPrivate::Waitnow performs elapsed-time, timer, and current-thread ID initialization after the immediate-success and zero-timeout checks. Blocking waits still perform this initialization.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Refactor
Merge Risk: ⚪ Minimal · up to
2309fThe change defers setup until a wait must block. No actionable merge risk is evident from the supplied context.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.