Improve Shard#entityCreated API performance #29520

Expose size of reachable actor count
This commit is contained in:
mgutmanis 2020-09-02 17:49:36 +03:00 committed by GitHub
parent 32ec0428d3
commit 33fda3ae6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -358,6 +358,8 @@ private[akka] object Shard {
// only called once during handoff
def activeEntities(): Set[ActorRef] = byRef.keySet.asScala.toSet
def nrActiveEntities: Int = byRef.size
// only called for getting shard stats
def activeEntityIds(): Set[EntityId] = byRef.values.asScala.toSet
@ -1059,7 +1061,7 @@ private[akka] class Shard(
* of active entities.
*/
@InternalStableApi
def entityCreated(@unused id: EntityId): Int = entities.activeEntities().size
def entityCreated(@unused id: EntityId): Int = entities.nrActiveEntities
// ===== buffering while busy saving a start or stop when remembering entities =====
def appendToMessageBuffer(id: EntityId, msg: Any, snd: ActorRef): Unit = {