Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Akka.Remote: ensure RemoteActorRef are serialized with correct Address when using multiple transports #7393

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Nov 18, 2024

Changes

Fixes #7378

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Need to ensure we use `RemoteActorRef` instead of `ActorSelection` in order to properly reproduce bug
var actor = await selection.ResolveOne(TimeSpan.FromSeconds(1));

// assert that the remote actor is using the correct transport
Assert.Contains(scheme, actor.Path.Address.Protocol);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently fails here - the IActorRef returned to the ResolveOne method belongs to transport 1 rather than transport 2.

@Aaronontheweb
Copy link
Member Author

From the perspective of node 2, the Sender from node 1 has the correct address (given that it's using an ActorSelection to deliver the Identify here)

image

@Aaronontheweb
Copy link
Member Author

So I thought this might be the culprit

private static ActorRefData SerializeActorRef(Address defaultAddress, IActorRef actorRef)
{
return new ActorRefData()
{
Path = (!string.IsNullOrEmpty(actorRef.Path.Address.Host))
? actorRef.Path.ToSerializationFormat()
: actorRef.Path.ToSerializationFormatWithAddress(defaultAddress)
};
}

But no, that code correctly serializes the Sender from node2 using Transport2's address - so this means the problem is likely on the read-side instead.

@Aaronontheweb Aaronontheweb changed the title [WIP] ensure RemoteActorRef are serialized with correct Address when using multiple transports Akka.Remote: ensure RemoteActorRef are serialized with correct Address when using multiple transports Nov 18, 2024
Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed my changes - I believe we have fixed the issue (but we'll need to check the results of the full Akka.Remote and up test suite first to confirm)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some minor formatting changes here - nothing substantial

@@ -1357,7 +1359,7 @@ private SerializedMessage SerializeMessage(object msg)
{
throw new EndpointException("Internal error: No handle was present during serialization of outbound message.");
}
return MessageSerializer.Serialize(_system, _handle.LocalAddress, msg);
return MessageSerializer.Serialize(_system, _transportInformation, msg);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the real fix - make sure we're always setting the current transport information to our transport before we perform outbound serialization. That way, any messages included inside the payloads get serialized onto the correct transport when we have multiple running.

if (oldInfo == null)
Akka.Serialization.Serialization.CurrentTransportInformation =
system.Provider.SerializationInformation;
Akka.Serialization.Serialization.CurrentTransportInformation = transportInformation;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other part of the real fix - make sure we explicitly set the CurrentTransportInformation to whatever was passed in by the EndpointReader before we get going

@Aaronontheweb
Copy link
Member Author

Performance Numbers

Running on .NET 8

dev

Run 1

Attempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      43

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    106383,    1880.72,            43,              68
         5, 1000000,    374392,    2671.14,            76,              85
        10, 2000000,    701755,    2850.07,            93,              93
        15, 3000000,    732601,    4095.40,           101,             101
        20, 4000000,    747524,    5351.44,           109,             102
        25, 5000000,    780397,    6407.86,           110,              94
        30, 6000000,    805045,    7453.31,           102,              93

Run 2

Attempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      42

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    119403,    1675.34,            42,              69
         5, 1000000,    316056,    3164.79,            77,              82
        10, 2000000,    752729,    2657.33,            90,              91
        15, 3000000,    772997,    3881.94,            99,             103
        20, 4000000,    789422,    5067.17,           111,             111
        25, 5000000,    823859,    6069.37,           119,              95
        30, 6000000,    815661,    7356.32,           103,              95

Run 3

Attempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      42

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    114614,    1745.04,            42,              70
         5, 1000000,    418061,    2392.65,            78,              83
        10, 2000000,    752729,    2657.07,            91,              91
        15, 3000000,    783700,    3828.12,            99,              99
        20, 4000000,    785238,    5094.91,           107,             107
        25, 5000000,    801283,    6240.87,           115,              92
        30, 6000000,    795545,    7542.17,           100,              92
Done..

This PR

Run 1

Attempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      42

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    108933,    1836.03,            42,              68
         5, 1000000,    392619,    2547.06,            76,              80
        10, 2000000,    722544,    2768.23,            88,              89
        15, 3000000,    739828,    4055.51,            97,             101
        20, 4000000,    756144,    5290.07,           109,             109
        25, 5000000,    758266,    6594.39,           117,              94
        30, 6000000,    763748,    7856.72,           102,              94

Run 2

ttempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      42

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    111112,    1800.84,            42,              69
         5, 1000000,    381389,    2622.41,            77,              82
        10, 2000000,    734485,    2723.75,            90,              91
        15, 3000000,    762583,    3934.46,            99,              99
        20, 4000000,    766284,    5220.71,           107,             108
        25, 5000000,    787774,    6347.51,           116,              98
        30, 6000000,    775294,    7739.02,           106,              98

Run 3

Attempted to elevate process priority, but failed due to Permission denied - carrying on at normal process priority.
OSVersion:                         Unix 6.9.3.76060903
ProcessorCount:                    16
ClockSpeed:                        0 MHZ
Actor Count:                       32
Messages sent/received per client: 200000  (2e5)
Is Server GC:                      True
Thread count:                      43

Num clients, Total [msg], Msgs/sec, Total [ms], Start Threads, End Threads
         1,  200000,    112740,    1774.65,            43,              70
         5, 1000000,    385357,    2595.37,            78,              83
        10, 2000000,    738826,    2707.74,            91,              91
        15, 3000000,    758342,    3956.67,            99,             100
        20, 4000000,    759302,    5268.95,           108,             108
        25, 5000000,    785300,    6367.31,           116,              92
        30, 6000000,    786164,    7632.28,           100,              92

No real performance impact, which is good 👍

Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Arkatufus Arkatufus enabled auto-merge (squash) November 19, 2024 15:24
@Arkatufus Arkatufus merged commit 4ae4792 into akkadotnet:dev Nov 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The first of multiple enabled Transports is used
2 participants