Skip to content

Commit

Permalink
removed boxing allocations inside FSM (#6183)
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.
  • Loading branch information
Aaronontheweb authored Oct 17, 2022
1 parent cc3a361 commit 183ec5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/Akka/Actor/FSM.cs
Original file line number Diff line number Diff line change
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 183ec5a

Please sign in to comment.