Skip to content

Commit

Permalink
removed boxing allocations inside FSM (#6183) (#6196)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arkatufus and Aaronontheweb committed Oct 17, 2022
1 parent 65f392a commit c78cec6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/Akka/Actor/FSM.cs
Expand Up @@ -1262,12 +1262,14 @@ private void MakeTransition(State<TState, TData> nextState)
{
Sender.Tell(nextState.Replies[i]);
}
if (!_currentState.StateName.Equals(nextState.StateName) || nextState.Notifies)

// avoid boxing
if (!EqualityComparer<TState>.Default.Equals(_currentState.StateName, nextState.StateName) || nextState.Notifies)
{
_nextState = nextState;
HandleTransition(_currentState.StateName, nextState.StateName);
Listeners.Gossip(new Transition<TState>(Self, _currentState.StateName, nextState.StateName));
_nextState = default(State<TState, TData>);
_nextState = default;
}
_currentState = nextState;

Expand Down

0 comments on commit c78cec6

Please sign in to comment.