From 3bd219e69f7871cefbd458e50288b848e0c957b4 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Mon, 10 Jun 2024 16:48:37 -0500 Subject: [PATCH] [Benchmarks] Add `Ask` vs. `Tell` memory pressure baseline (#7244) * added baseline for measuring Ask vs. Tell memory pressure * remove unnecessary cleanup * made it easier to understand requests / second --- .../ActorMessagingMemoryPressureBenchmark.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs b/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs index c98487a8021..09d6bf63cfa 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs @@ -14,7 +14,7 @@ namespace Akka.Benchmarks.Actor { - [Config(typeof(MicroBenchmarkConfig))] + [Config(typeof(MonitoringConfig))] public class ActorMessagingMemoryPressureBenchmark { #region Classes @@ -46,12 +46,13 @@ public MyActor() private IActorRef _actorEntryPoint; private const string Msg = "hit"; - - [Params(100_000)] - public int MsgCount { get; set; } + + public const int MsgCount = 100_000; [Params(10, 100)] public int ActorCount { get; set; } + + private Task[] _askTasks; [GlobalSetup] public void Setup() @@ -75,9 +76,10 @@ public void PerInvokeCleanup() public void PerInvokeSetup() { _actorEntryPoint = _sys.ActorOf(Props.Create().WithRouter(new BroadcastPool(ActorCount))); + _askTasks = new Task[MsgCount]; } - [Benchmark] + [Benchmark(Baseline = true, OperationsPerInvoke = MsgCount)] public Task PushMsgs() { for (var i = 0; i < MsgCount; i++) @@ -87,5 +89,16 @@ public Task PushMsgs() return Task.CompletedTask; } + + [Benchmark(OperationsPerInvoke = MsgCount)] + public Task AskMsgs() + { + for (var i = 0; i < MsgCount; i++) + { + _askTasks[i] = _actorEntryPoint.Ask(Msg); + } + + return Task.WhenAll(_askTasks); + } } }