perf(libkernel): shard SyncOnAddress waiters across hashed buckets #2528
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2528"
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 FitzVB on 2026-10-10T01:48:15Z.
What
sceKernelSyncOnAddressWait/Wakecurrently share one mutex for every address. Unrelated waiters serialize on that lock even when they never share a key.This keeps the existing waiter queues and wake semantics, and hashes each address into one of 64 cache-line-aligned buckets so wait and wake on different addresses can proceed in parallel.
Complementary to #1482: that change reuses this waiter queue for
_umtx_op. This PR does not implement_umtx_op.Tested
Windows 10, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON.guest_sync_on_address: passed (1.17 s)python3 tools/check_conventions.py --base upstream/main: passedChecklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T01:54:34Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:57:50Z.
Thanks for reopening this. It no longer merges cleanly into current main. Could you rebase onto current main? SyncOnAddress still uses one global lock on main, so sharding the waiters is still wanted. We'll review and run full CI on the new head.
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-20T09:36:50Z.
Thanks @FitzVB for the bucket design in this PR. A new PR, #8304, adds
UMTX_OP_SEM_WAITandUMTX_OP_SEM_WAKEinSyncOnAddress.cpp, and it touches the same waiter queue this PR shards.What #8304 needs from the queue, so the two merge cleanly:
WaitOnKeyLockedandWaitOnKeyUntiltake a readiness callable, andWaitOnAddressUntiluses them with the value check. A semaphore wait supplies its own check on_count.WakeSemaphoreLockedreads the waiter count for a key, and it clears_has_waiterswhen exactly one waiter is queued. That count is the bucket's queue length, so it must come from the bucket for the key.Whichever merges second should rebase onto the other. The sharded version should keep the per-key queue and the readiness callable as they are.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T09:38:59Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cppL135-139, L149-150Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-20T10:00:08Z.
Thanks @nahshongraham97 for the sharding. Its change is now ported onto the semaphore branch in #8304 (commit
e3eb745c9), with you credited as co-author, and the three queue sites are converted: the wait helper, the address wake and the semaphore wake all useBucketOf(key).guest_umtx_oppasses on the port.This leaves #2528 with nothing new to add, so the port is the one to review. Thanks again for the design.
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-20T10:05:39Z.
Correction to my earlier note: the sharding is not in #8304 any more. It is ported onto current
mainin #8323, with you credited as co-author, because CONTRIBUTING asks for one topic per PR. #2528 is left open for you, and #8323 is the one to review.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-21T05:06:45Z.
Heads-up (support triage): #8323 ("refactor(libkernel): shard SyncOnAddress waiters across hashed buckets", Aryansh1520, opened 2026-10-20) changes
SyncOnAddress/src/SyncOnAddress.cppwith content identical to this PR — same bucket/shard hunks, byte-for-byte. Your PR is 10 days older; the other author has been pointed here. Please agree which one lands first and declare it withDepends onon the checklist line.Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-21T09:16:31Z.
@oneandonlydean as requested, here is the rebase of this change onto current
main:2e35702df(one commit on top off894ba69d), with nahshongraham97 kept as co-author.The only file changed is
core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cpp. The port maps the three queue sites (wait, address wake, semaphore wake) onto the same 64 buckets, using the key's bucket for each.ctest -R '^guest_umtx_op$'passes andtools/check_conventions.py --base origin/mainis clean on that commit.Use it however suits this PR. @FitzVB, this is for your review as well.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T10:09:28Z.
@FitzVB @Aryansh1520 thanks.
2e35702dfis a clean port. The three queue sites (wait, address wake, semaphore wake) each lockBucketOf(key)for their one key, and nothing works on two keys under one lock. The semaphore'shasWaitersflag is set in the wait's readiness check and cleared in the wake, both under the semaphore address's bucket, so they stay serialised as before. Main hasn't touchedSyncOnAddress.cppsince its base.We'll carry it here by merging current
maininto this branch withSyncOnAddress.cpptaken from2e35702df. nahshongraham97 keeps the commit, and Aryan Sharma is credited with aCo-authored-byline on the merge. Full CI runs on the result before merge.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T13:22:07Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.