He-Pin opened a new pull request, #3149:
URL: https://github.com/apache/pekko/pull/3149

   ### Motivation
   
   CAS retry loops in `AbstractDispatcher` and `Mailbox` spin without any CPU 
hint when contention causes `compareAndSet` to fail. JDK 9's 
`Thread.onSpinWait()` hints to the CPU that we're in a spin-wait loop, 
improving power efficiency and reducing context-switch latency.
   
   ### Modification
   
   - `AbstractDispatcher.scala`: Add `onSpinWait()` in shutdown schedule CAS 
retry loop body
   - `Mailbox.scala`: Convert `setAsScheduled()` and `setAsIdle()` from 
`@tailrec` recursive CAS loops to while loops with `onSpinWait()`, re-reading 
`currentStatus` on each retry
   
   ### Result
   
   Better CPU behavior under contention on the message dispatch hot path 
(`setAsScheduled` is called on every `registerForExecution`). The `onSpinWait` 
pattern is already established in the codebase (`AbstractNodeQueue`, 
`AbstractBoundedNodeQueue`, `AffinityPool`).
   
   ### Tests
   
   - `sbt "actor/compile"` — passed
   
   ### References
   
   Refs #3136


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to