fix(artery): distribute ActorSelection messages across lanes by target path#3098
Closed
He-Pin wants to merge 1 commit into
Closed
fix(artery): distribute ActorSelection messages across lanes by target path#3098He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
…t path 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. 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. Similarly, inbound lane partitioning uses the wire recipient's UID (root guardian = 0), concentrating all inbound ActorSelection processing on a single inbound lane. Modification: Outbound: Add a dedicated case for ActorSelectionMessage in Association.send that computes the queue index from the selection's target path elements hash instead of the anchor's UID. PriorityMessage ActorSelection (cluster heartbeats) continues going through the control queue. Inbound: Update ArteryTransport.inboundLanePartitioner to parse the ActorSelectionMessage's target path from the envelope byte buffer and use it as the destination hash key, distributing inbound ActorSelection processing across all inbound lanes. Result: ActorSelection messages are distributed across all outbound and inbound lanes based on target path, eliminating the single-lane throughput bottleneck while preserving per-path message ordering. Tests: sbt -Dpekko.test.timefactor=2 "remote / Test / testOnly *SendConsistency*" — 24/24 passed (all 6 spec variants) sbt "remote / mimaReportBinaryIssues" — clean References: Fixes #3089
Member
Author
|
Superseded by #3092 which has a more optimized CodedInputStream-based protobuf parsing and includes test coverage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), allActorSelectionmessages are routed to the same outbound queue becauseselectQueueuses the anchor's UID as the distribution key:The anchor for
ActorSelectionis the root guardian (RootActorPath), whose UID is always0(ActorCell.undefinedUid). Somath.abs(0 % N) = 0for any N — allActorSelectiontraffic concentrates on lane 0 while other lanes sit idle.Similarly, inbound lane partitioning uses the wire recipient's UID (root guardian = 0), concentrating all inbound
ActorSelectionprocessing on a single inbound lane.This is not a recent regression — the
selectQueuelogic has been unchanged since the Pekko fork from Akka.Modification
Outbound (
Association.send): Add a dedicatedcase sel: ActorSelectionMessagethat computes the queue index from the selection's target path elements hash instead of the anchor's UID:Inbound (
ArteryTransport.inboundLanePartitioner): Parse theActorSelectionMessage's target path from the envelope byte buffer and use it as the destination hash key, distributing inbound ActorSelection processing across all inbound lanes.PriorityMessageActorSelection (used by cluster heartbeats) continues to go through the control queue unchanged.Result
ActorSelection messages are distributed across all outbound and inbound lanes based on target path, eliminating the single-lane throughput bottleneck while preserving per-path message ordering (same target path → same hash → same lane).
Tests
References
Fixes #3089