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

Fix cluster sharding benchmark #7061

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both report and statistics can be null if a benchmark case failed to run.

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>(_ =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the cause for the bug.

ShardingEnvelope does not get passed to the shard entity anymore, it is automatically unwrapped by the new extractor.

Copy link
Member

Choose a reason for hiding this comment

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

BITTEN BY MY OWN BUG FIX

Copy link
Member

Choose a reason for hiding this comment

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

Thank you @Arkatufus

{
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());
}
}
}
Loading