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

Optimize cluster message serializer benchmarks #7282

Merged

Conversation

Arkatufus
Copy link
Contributor

Changes

  • Cache message serialized byte array and manifest before performing deserialization benchmark

@Arkatufus
Copy link
Contributor Author

Arkatufus commented Jul 11, 2024

Benchmark after changes:

BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4598/22H2/2022Update)
AMD Ryzen 9 3900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK 8.0.302
  [Host]     : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
Method Mean Error StdDev Gen0 Gen1 Allocated
Serialize_Heartbeat 147.1 ns 1.09 ns 1.21 ns 0.0267 - 224 B
Deserialize_Heartbeat 214.7 ns 1.33 ns 1.24 ns 0.0553 - 464 B
Serialize_HeartbeatRsp 192.7 ns 1.06 ns 0.94 ns 0.0315 - 264 B
Deserialize_HeartbeatRsp 247.8 ns 2.58 ns 2.42 ns 0.0639 - 536 B
Serialize_GossipEnvelope 9,650.0 ns 54.45 ns 45.47 ns 0.8850 - 7496 B
Deserialize_GossipEnvelope 5,422.8 ns 41.31 ns 36.62 ns 1.0910 0.0076 9136 B
Serialize_GossipStatus 1,215.2 ns 11.14 ns 10.42 ns 0.1965 - 1648 B
Deserialize_GossipStatus 1,705.8 ns 11.37 ns 10.64 ns 0.2918 - 2448 B
Serialize_Welcome 15,206.0 ns 67.58 ns 59.91 ns 1.1292 0.0153 9536 B
Deserialize_Welcome 7,324.3 ns 44.45 ns 41.58 ns 1.2970 0.0229 10888 B

@Arkatufus
Copy link
Contributor Author

Arkatufus commented Jul 11, 2024

dev branch benchmark:

BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4598/22H2/2022Update)
AMD Ryzen 9 3900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK 8.0.302
  [Host]     : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
Method Mean Error StdDev Median Gen0 Gen1 Allocated
Serialize_Heartbeat 167.7 ns 3.40 ns 8.64 ns 164.7 ns 0.0267 - 224 B
Deserialize_Heartbeat 405.0 ns 2.92 ns 2.44 ns 404.9 ns 0.0820 - 688 B
Serialize_HeartbeatRsp 214.1 ns 1.19 ns 1.05 ns 213.8 ns 0.0315 - 264 B
Deserialize_HeartbeatRsp 497.1 ns 4.86 ns 4.55 ns 497.2 ns 0.0954 - 800 B
Serialize_GossipEnvelope 10,107.7 ns 97.73 ns 91.42 ns 10,093.0 ns 0.8850 - 7488 B
Deserialize_GossipEnvelope 17,696.7 ns 223.64 ns 209.19 ns 17,734.7 ns 1.9531 - 16624 B
Serialize_GossipStatus 1,235.7 ns 8.72 ns 8.15 ns 1,236.3 ns 0.1965 - 1648 B
Deserialize_GossipStatus 3,261.7 ns 44.35 ns 39.32 ns 3,255.7 ns 0.4883 - 4096 B
Serialize_Welcome 15,396.4 ns 117.58 ns 109.98 ns 15,404.9 ns 1.1292 - 9536 B
Deserialize_Welcome 26,611.8 ns 157.65 ns 139.75 ns 26,632.6 ns 2.4414 0.0305 20480 B

@Aaronontheweb
Copy link
Member

Much better, thank you - this is one of the rare cases where serialization is more expensive than deserialization, which is odd.

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) July 11, 2024 17:14
@Aaronontheweb Aaronontheweb merged commit 7947c1f into akkadotnet:dev Jul 11, 2024
11 of 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.

2 participants