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

State container #783

Merged
merged 1 commit into from
Apr 16, 2015
Merged

State container #783

merged 1 commit into from
Apr 16, 2015

Conversation

rogeralsing
Copy link
Contributor

This PR is much like @HCanber's #766

It's for review and memory footprint optimization.

In this PR, the state found in ActorCell.DeathWatch.cs + the _behaviorStack has been abstracted out to a state container that by default only holds a WatchedBy, that is, it's parent.
All other state is lazily allocated if the actor needs more than that initial state.

The actor size have now gone from 1334 bytes to 1144, which is about 16% less memory per actor.

Thoughts on this?

@HCanber HCanber changed the title State container For Review only - State container Apr 2, 2015
@stefansedich
Copy link
Contributor

@rogeralsing I like this, nice and simple and easy to follow.

@rogeralsing
Copy link
Contributor Author

So, anyone else had a look at this?

@Aaronontheweb
Copy link
Member

I have not - will take a look after .NET Fringe craziness settles down on Tuesday

@Aaronontheweb
Copy link
Member

So if I understand this correctly... IActorState encapsulates the BehaviorStack, deathwatch, and child containers and lazily builds it out. One thing I don't quite understand yet (I had some trouble reading the diffs for some reason - Github issue) though is does each piece of the actor state build lazily? I.E. if I subscribe to deathwatch do I automatically get a ChildContainer too?

@rogeralsing
Copy link
Contributor Author

The ChildContainer stuff is separate from this PR.
But child container starts out in a "empty container" state, very similar to what I do with the other state in this PR.

Anyway, the DefaultActorState here is the minimal startup state.
It can handle one WatchedBy and one Receive behavior.
That is, what all actors have at start up, they have a default behavior and they are watched by their parent.

Many actors never leave this state, they might be workers that never use BecomeStacked and are never watched by anyone else than the direct parent.

But if they are, they will transition to use the FullActorState transparently, which enables having multiple watchedby, watching and a full behavior stack.
Once in this state, the actor will never revert to the DefaultActor state.
We are just trying to optimize memory footprint for the default case.

Does that make sense?

@Aaronontheweb
Copy link
Member

Ok, in that case then I think we should merge it in and get the memory footprint down.

@rogeralsing rogeralsing changed the title For Review only - State container State container Apr 16, 2015
Implemented Default State container for smaller memory footprint
Added support for receive in the state containers.
Updated actor state support with documentation and separate file
@Aaronontheweb
Copy link
Member

@rogeralsing merge when you're set

rogeralsing added a commit that referenced this pull request Apr 16, 2015
@rogeralsing rogeralsing merged commit c60ffb8 into akkadotnet:dev Apr 16, 2015
@rogeralsing rogeralsing deleted the state-container branch April 19, 2015 16:18
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.

3 participants