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

eliminate Lazy<string> from Address #5068

Merged
merged 1 commit into from Jun 3, 2021

Conversation

Aaronontheweb
Copy link
Member

This PR:

  1. Improves ActorPath.Parse performance
  2. Reduces Address memory allocation

@Aaronontheweb Aaronontheweb added this to the 1.4.21 milestone Jun 3, 2021
@Aaronontheweb Aaronontheweb changed the title eliminate Lazy<string> from Address eliminate Lazy<string> from Address Jun 3, 2021
@Aaronontheweb
Copy link
Member Author

ActorPath.Parse Performance

Before

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19041.985 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.203
  [Host]     : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT
  DefaultJob : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
ActorPath_Parse 583.49 ns 11.631 ns 16.305 ns 0.1392 - - 584 B
ActorPath_Concat 55.87 ns 1.142 ns 1.315 ns 0.0268 - - 112 B
ActorPath_Equals 20.35 ns 0.336 ns 0.314 ns - - - -
ActorPath_ToString 207.66 ns 4.186 ns 3.916 ns 0.0515 - - 216 B
ActorPath_ToSerializationFormat 225.86 ns 2.761 ns 2.583 ns 0.0515 - - 216 B
ActorPath_ToSerializationFormatWithAddress 244.88 ns 4.940 ns 4.379 ns 0.0515 - - 216 B

After

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19041.985 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.203
  [Host]     : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT
  DefaultJob : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
ActorPath_Parse 526.80 ns 8.282 ns 7.342 ns 0.1068 - - 448 B
ActorPath_Concat 58.06 ns 1.214 ns 1.399 ns 0.0267 - - 112 B
ActorPath_Equals 20.66 ns 0.400 ns 0.374 ns - - - -
ActorPath_ToString 210.67 ns 4.207 ns 5.616 ns 0.0515 - - 216 B
ActorPath_ToSerializationFormat 232.91 ns 4.497 ns 4.998 ns 0.0515 - - 216 B
ActorPath_ToSerializationFormatWithAddress 246.31 ns 4.979 ns 7.140 ns 0.0515 - - 216 B

Address Performance

Before

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19041.985 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.203
  [Host]     : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT
  DefaultJob : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Address_Parse 1,440.3613 ns 8.8500 ns 7.8453 ns 0.1354 - - 568 B
Address_CompareTo 16.5944 ns 0.1334 ns 0.1247 ns - - - -
Address_ToString 0.6547 ns 0.0500 ns 0.0443 ns - - - -
Address_Equals 7.9953 ns 0.1255 ns 0.1174 ns - - - -
Address_GetHashCode 34.5831 ns 0.3759 ns 0.3516 ns - - - -

After

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19041.985 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.203
  [Host]     : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT
  DefaultJob : .NET Core 3.1.15 (CoreCLR 4.700.21.21202, CoreFX 4.700.21.21402), X64 RyuJIT

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Address_Parse 1,368.8126 ns 9.9937 ns 8.8591 ns 0.1030 - - 432 B
Address_CompareTo 17.3290 ns 0.1720 ns 0.1609 ns - - - -
Address_ToString 0.6843 ns 0.0619 ns 0.0549 ns - - - -
Address_Equals 7.4430 ns 0.1869 ns 0.1836 ns - - - -
Address_GetHashCode 34.9871 ns 0.3221 ns 0.3013 ns - - - -

@Aaronontheweb Aaronontheweb marked this pull request as ready for review June 3, 2021 13:25
@Arkatufus
Copy link
Contributor

This optimization might actually hurt memory footprint in use cases where there are a lot of actors and address ToString() are never called.

@Arkatufus
Copy link
Contributor

Oh, I didn't notice the changes on the ToString() method, yes, this is good.

@Aaronontheweb Aaronontheweb merged commit b1a9aa6 into akkadotnet:dev Jun 3, 2021
@Aaronontheweb Aaronontheweb deleted the perf/Address-memory branch June 3, 2021 16:12
This was referenced Jun 16, 2021
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.

None yet

2 participants