He-Pin opened a new pull request, #3092:
URL: https://github.com/apache/pekko/pull/3092
### Motivation
The "must be able to send messages with actorSelection concurrently
preserving order" test flakes on CI: 4 sender actors each drive 1000
round-trips via `ActorSelection` (4004 messages total). With multi-lane artery
config (`outbound-lanes > 1`), **all ActorSelection messages are routed to the
same outbound queue** because `selectQueue` uses the anchor's UID as the
distribution key:
```scala
OrdinaryQueueIndex + (math.abs(r.path.uid % outboundLanes))
```
The anchor for `ActorSelection` is the root guardian (`RootActorPath`),
whose UID is always `0` (`ActorCell.undefinedUid`). So `math.abs(0 % N) = 0`
for any N — all ActorSelection traffic concentrates on lane 0 while other lanes
sit idle.
In contrast, the ActorRef variant distributes across lanes because each echo
actor has a distinct non-zero UID.
This is **not a recent regression** — the `selectQueue` logic has been
unchanged since the Pekko fork from Akka. PR #3090 (timeout widening) masks the
symptom but doesn't fix the structural bottleneck.
### Modification
Add a dedicated `case sel: ActorSelectionMessage` (non-PriorityMessage) in
`Association.send` that computes the queue index from the selection's **target
path elements hash** instead of the anchor's UID:
```scala
case sel: ActorSelectionMessage =>
val queueIndex =
if (outboundLanes == 1) OrdinaryQueueIndex
else OrdinaryQueueIndex + (math.abs(sel.elements.hashCode()) %
outboundLanes)
val queue = queues(queueIndex)
if (!queue.offer(outboundEnvelope))
dropped(queueIndex, queueSize, outboundEnvelope)
```
This distributes ActorSelection messages across lanes by their target path
while preserving **per-path message ordering** (same target path → same hash →
same lane).
PriorityMessage ActorSelection (used by cluster heartbeats) continues to go
through the control queue unchanged.
### Result
ActorSelection messages are now distributed across all outbound lanes based
on target path, eliminating the single-lane throughput bottleneck. The existing
ActorRef-based test and PriorityMessage routing are unaffected.
### Tests
- `sbt "remote / Test / compile"` — compile check
- CI will exercise the artery variants (1-lane and 3-lane configs)
### References
Refs #3041 (previous timeout widening), supersedes #3090
--
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]