Skip to content

Commit

Permalink
Fix cluster sharding benchmark (#7061)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Jan 12, 2024
1 parent 2035d9a commit 187caa9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
21 changes: 12 additions & 9 deletions src/benchmark/Akka.Benchmarks/Configurations/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyl
var benchmarkAttribute = benchmarkCase.Descriptor.WorkloadMethod.GetCustomAttribute<BenchmarkAttribute>();
var totalOperations = benchmarkAttribute?.OperationsPerInvoke ?? 1;

if (summary.HasReport(benchmarkCase))
{
var report = summary[benchmarkCase];
var nsPerOperation = report.ResultStatistics.Mean;
var operationsPerSecond = 1 / (nsPerOperation / 1e9);

return operationsPerSecond.ToString("N2"); // or format as you like
}
if (!summary.HasReport(benchmarkCase))
return "<not found>";

var report = summary[benchmarkCase];
var statistics = report?.ResultStatistics;
if(statistics is null)
return "<not found>";

return "<not found>";
var nsPerOperation = statistics.Mean;
var operationsPerSecond = 1 / (nsPerOperation / 1e9);

return operationsPerSecond.ToString("N2"); // or format as you like

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public ResolveResp(string entityId, Address addr)
public Address Addr { get; }
}

public ShardedEntityActor()
public ShardedEntityActor(string entityId)
{
Receive<ShardingEnvelope>(e =>
Receive<Resolve>(_ =>
{
Sender.Tell(new ResolveResp(e.EntityId, Cluster.Get(Context.System).SelfAddress));
Sender.Tell(new ResolveResp(entityId, Cluster.Get(Context.System).SelfAddress));
});

ReceiveAny(o => Sender.Tell(o));
Expand Down Expand Up @@ -248,10 +248,12 @@ public static Config CreateDDataConfig(bool rememberEntities = false)

public static IActorRef StartShardRegion(ActorSystem system, string entityName = "entities")
{
var props = Props.Create(() => new ShardedEntityActor());
var sharding = ClusterSharding.Get(system);
return sharding.Start(entityName, _ => props, ClusterShardingSettings.Create(system),
new ShardMessageExtractor());
return sharding.Start(
typeName: entityName,
entityPropsFactory: id => Props.Create(() => new ShardedEntityActor(id)),
settings: ClusterShardingSettings.Create(system),
messageExtractor: new ShardMessageExtractor());
}
}
}

0 comments on commit 187caa9

Please sign in to comment.