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

AkkaPduCodec serializer benchmark #6078

Merged

Conversation

Aaronontheweb
Copy link
Member

Changes

Measures the memory and throughput impact of the AkkaPduCodec - essentially simulates inbound read / write latency.

Remarks

Worth noting: understates the level of GC impact in the real Akka.Remote endpoint system - everything here gets GC0; in Akka.Remote it's GC1/2 since these messages also get delivered into the DotNetty across scope boundaries.

@Aaronontheweb
Copy link
Member Author

// * Summary *

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1889 (21H2)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=6.0.201
  [Host]     : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
  DefaultJob : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
Method Mean Error StdDev Gen 0 Gen 1 Allocated
WritePayloadPdu 2,206.3 ns 5.18 ns 4.85 ns 0.3969 0.0031 1,664 B
DecodePayloadPdu 2,730.5 ns 31.49 ns 26.30 ns 0.4063 - 1,704 B
DecodePduOnly 165.4 ns 0.59 ns 0.53 ns 0.1090 - 456 B
DecodeMessageOnly 2,172.3 ns 7.19 ns 6.37 ns 0.2563 - 1,080 B
DeserializePayloadOnly 214.8 ns 2.50 ns 2.21 ns 0.0398 - 168 B

@Aaronontheweb Aaronontheweb marked this pull request as ready for review August 29, 2022 12:33
@Aaronontheweb
Copy link
Member Author

Learnings here:

  1. DecodeMessageAndAck is the slow path - probably all of the ActorPath parsing. Still, what's weird is that we should be using caching aggressively here (unless I designed the benchmark such that the cache never gets hit.)
  2. Read-side is still ultimately the bottleneck;
  3. The write-side isn't that much faster than the read-side.

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) August 29, 2022 14:44
@Aaronontheweb
Copy link
Member Author

Think I have this fully working now.

@Aaronontheweb
Copy link
Member Author

// * Summary *

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1889 (21H2)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=6.0.201
  [Host]     : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
  DefaultJob : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
Method Mean Error StdDev Gen 0 Allocated
WritePayloadPdu 2,471.4 ns 16.62 ns 14.73 ns 0.4219 1,768 B
DecodePayloadPdu 3,033.6 ns 11.12 ns 9.86 ns 0.4375 1,832 B
DecodePduOnly 226.9 ns 1.83 ns 1.53 ns 0.1145 480 B
DecodeMessageOnly 2,323.9 ns 16.67 ns 14.78 ns 0.2813 1,184 B
DeserializePayloadOnly 225.5 ns 0.84 ns 0.75 ns 0.0398 168 B

Key cache statistics on the slow path:

[Addr1] ResolveCache entries: [1]
[Addr1] PathCache entries: [4]
[Addr1] AddressCache entries: [0]
[Addr2] ResolveCache entries: [0]
[Addr2] PathCache entries: [0]
[Addr2] AddressCache entries: [0]
[Addr1] Used ResolveCache for recipient? True
[Addr1] Used PathCache for recipient? True
[Addr1] Used ResolveCache for sender? False
[Addr1] Used PathCache for sender? True
[Addr2] Used ResolveCache for recipient? False
[Addr2] Used PathCache for recipient? False
[Addr2] Used ResolveCache for sender? False
[Addr2] Used PathCache for sender? False
[Addr1] Used AddressCache for sys1? False
[Addr2] Used AddressCache for sys2? False

@Aaronontheweb Aaronontheweb merged commit eee47ac into akkadotnet:dev Aug 29, 2022
@Aaronontheweb Aaronontheweb deleted the AkkaPduCodecSerializerBenchmark branch August 29, 2022 16:27
Arkatufus pushed a commit to Arkatufus/akka.net that referenced this pull request Aug 31, 2022
* added benchmark to measure `AkkaPduCodec` overhead

* completed `AkkaPduCodec` benchmarks

* broke down read-side deserialization

* added second ActorSystem

* added full cache debug logs

(cherry picked from commit eee47ac)
Aaronontheweb added a commit that referenced this pull request Aug 31, 2022
* added benchmark to measure `AkkaPduCodec` overhead

* completed `AkkaPduCodec` benchmarks

* broke down read-side deserialization

* added second ActorSystem

* added full cache debug logs

(cherry picked from commit eee47ac)

Co-authored-by: Aaron Stannard <[email protected]>
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.

1 participant