You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the ActorCell contains these state containers:
HashSet<ActorRef> _watching = new HashSet<ActorRef>();
HashSet<ActorRef> _watchedBy = new HashSet<ActorRef>();
HashSet<ActorRef> _terminatedQueue = new HashSet<ActorRef>();
Stack<Receive> behaviorStack = new Stack<Receive>();
That's quite a bit of memory that are pre allocated for each actor, even if they never use behavior stacking or watches any other actors.
If we could actract this to a dedicated type.
e.g.
Don't read too much into the actual methods there, it's just to get an idea of the concept.
If we have this, we could have one implementation that is used for the default case, which don't hold a hashset for watchers, it could just be a simple ref to the parent.
And if AddWatchedBy is called and we now need to hold two watchers, then we create an instance of another implementation that do use HashSet and Stacks.
Something like:
class DefaultActorState : IActorState
{
private ActorRef _watchedBy;
private Receive _behavior;
..implementations of the interface
}
class FullActorState : IActorState
{
private HashSet<ActorRef> _watching = new HashSet<ActorRef>();
private HashSet<ActorRef> _watchedBy = new HashSet<ActorRef>();
private HashSet<ActorRef> _terminatedQueue = new HashSet<ActorRef>();
private Stack<Receive> behaviorStack = new Stack<Receive>();
..implementations of the interface
}
in the ActorCell we could then implement this along the lines of :
private IActorState _state = new DefaultActorState();
public void BecomeStacked(Receive behavior)
{
_state = _state.BecomeStacked(behavior);
}
This would cut down our memory footprint quite a bit.
Does this idea hold? any obvious drawbacks with it?
The text was updated successfully, but these errors were encountered:
Related to #766 #629 #249
Currently the
ActorCell
contains these state containers:That's quite a bit of memory that are pre allocated for each actor, even if they never use behavior stacking or watches any other actors.
If we could actract this to a dedicated type.
e.g.
Don't read too much into the actual methods there, it's just to get an idea of the concept.
If we have this, we could have one implementation that is used for the default case, which don't hold a hashset for watchers, it could just be a simple ref to the parent.
And if AddWatchedBy is called and we now need to hold two watchers, then we create an instance of another implementation that do use HashSet and Stacks.
Something like:
in the ActorCell we could then implement this along the lines of :
This would cut down our memory footprint quite a bit.
Does this idea hold? any obvious drawbacks with it?
The text was updated successfully, but these errors were encountered: