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

removed boxing allocations inside FSM.State.Equals #6183

Merged

Conversation

Aaronontheweb
Copy link
Member

Changes

The object.Equals call here generated hundreds of mb in boxing allocations inside RemotePingPong - using the EqualityComparer<TState>.Default.Equals eliminates them.

Checklist

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

Latest dev Benchmarks

Used Rider's Dynamic Program Analysis to verify that the allocations were removed.

The `object.Equals` call here generated hundreds of mb in boxing allocations inside RemotePingPong - using the `EqualityComparer<TState>.Default.Equals` eliminates them.
@Aaronontheweb
Copy link
Member Author

Benchmarks

v1.4

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.2130 (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 MsgCount Mean Error StdDev Ratio RatioSD Gen 0 Gen 1 Gen 2 Allocated
BenchmarkFsm 1000000 741.2 ms 13.85 ms 12.95 ms 1.55 0.05 35000.0000 4000.0000 1000.0000 150 MB
BenchmarkUntyped 1000000 477.1 ms 9.52 ms 11.33 ms 1.00 0.00 12000.0000 4000.0000 1000.0000 56 MB

This PR

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.2130 (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 MsgCount Mean Error StdDev Ratio RatioSD Gen 0 Gen 1 Gen 2 Allocated
BenchmarkFsm 1000000 704.1 ms 12.67 ms 12.44 ms 1.43 0.05 24000.0000 4000.0000 1000.0000 104 MB
BenchmarkUntyped 1000000 494.4 ms 9.63 ms 13.50 ms 1.00 0.00 13000.0000 3000.0000 1000.0000 56 MB

Memory reduction of ~50mb and a throughput improvement of ~8% or so.

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) October 17, 2022 14:17
@Aaronontheweb Aaronontheweb merged commit 183ec5a into akkadotnet:v1.4 Oct 17, 2022
@Aaronontheweb Aaronontheweb deleted the akka-actor-boxing-allocation branch October 17, 2022 14:20
Arkatufus pushed a commit to Arkatufus/akka.net that referenced this pull request Oct 17, 2022
The `object.Equals` call here generated hundreds of mb in boxing allocations inside RemotePingPong - using the `EqualityComparer<TState>.Default.Equals` eliminates them.

(cherry picked from commit 183ec5a)
Aaronontheweb added a commit that referenced this pull request Oct 17, 2022
The `object.Equals` call here generated hundreds of mb in boxing allocations inside RemotePingPong - using the `EqualityComparer<TState>.Default.Equals` eliminates them.

(cherry picked from commit 183ec5a)

Co-authored-by: Aaron Stannard <aaron@petabridge.com>
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