Skip to content

Automatic passivation for sharding #3718

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

Merged
merged 1 commit into from
Feb 10, 2019

Conversation

ismaelhamed
Copy link
Member

Port #25765

settings,
_extractEntityId,
_extractShard,
new LeastShardAllocationStrategy(10, 3),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClusterSharding.DefaultShardAllocationStrategy() seems to be accessible from here in the JVM (see #L69)

@@ -617,14 +624,28 @@ internal static class Shards
}
}

public static void PassivateCompleted<TShard>(this TShard shard, Shard.EntityStopped evt) where TShard: IShard
private static void PassivateIdleEntities<TShard>(this TShard shard) where TShard : IShard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first implementation was easier to the eye and more in line with the JVM, but probably less performant:

var deadline = DateTime.Now.Ticks - shard.Settings.PassivateIdleEntityAfter.Ticks;
var refsToPassivate = shard.LastMessageTimestamp.Where(s => s.Value < deadline).Select(s => shard.RefById[s.Key]).ToArray();
if (refsToPassivate.Any())
{
    shard.Log.Debug($"Passivating [{refsToPassivate.Length}] idle entities");
    refsToPassivate.ForEach(entity => Passivate(shard, entity, shard.HandOffStopMessage));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@Horusiath Horusiath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, it's good to go - nice that you've optimized this LINQ part to something that actually has sense in .NET :)

@@ -617,14 +624,28 @@ internal static class Shards
}
}

public static void PassivateCompleted<TShard>(this TShard shard, Shard.EntityStopped evt) where TShard: IShard
private static void PassivateIdleEntities<TShard>(this TShard shard) where TShard : IShard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -660,26 +681,61 @@ internal static class Shards
}
else
{
if (shard.MessageBuffers.TryGetValue(id, out var buffer))
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO what?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nada. Missed this one before pushing...

@Aaronontheweb Aaronontheweb merged commit 010dfd6 into akkadotnet:dev Feb 10, 2019
@Aaronontheweb Aaronontheweb added this to the 1.3.12 milestone Feb 10, 2019
@Aaronontheweb
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants