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

modified PingPong / RemotePingPong benchmarks to display threadcount #4947

Merged
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
20 changes: 10 additions & 10 deletions src/benchmark/PingPong/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ private static async void Start(uint timesToRun, bool testAsync)
return;
}

#if THREADS
int workerThreads;
int completionPortThreads;
ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
Console.WriteLine("Warming up...");
//Warm up
await ActorSystem.Create("WarmupSystem").Terminate();

Console.WriteLine("Worker threads: {0}", workerThreads);
// print statistics AFTER warm up to observe ActorSystem impact on ThreadCount


Console.WriteLine("OSVersion: {0}", Environment.OSVersion);
#endif
Console.WriteLine("ProcessorCount: {0}", processorCount);
Console.WriteLine("ClockSpeed: {0} MHZ", CpuSpeed());
Console.WriteLine("Actor Count: {0}", processorCount * 2);
Console.WriteLine("Messages sent/received: {0} ({0:0e0})", GetTotalMessagesReceived(repeat));
Console.WriteLine("Is Server GC: {0}", GCSettings.IsServerGC);
Console.WriteLine("Thread count: {0}", Process.GetCurrentProcess().Threads.Count);
Console.WriteLine();

//Warm up
ActorSystem.Create("WarmupSystem").Terminate();

Console.Write("ActorBase first start time: ");
await Benchmark<ClientActorBase>(1, 1, 1, PrintStats.StartTimeOnly, -1, -1);
Console.WriteLine(" ms");
Expand Down Expand Up @@ -206,9 +206,9 @@ public static IEnumerable<int> GetThroughputSettings()

await Task.WhenAll(tasks.ToArray());
sw.Stop();

system.Terminate();
totalWatch.Stop();
await system.Terminate(); // force full ActorSystem termination


var elapsedMilliseconds = sw.ElapsedMilliseconds;
long throughput = elapsedMilliseconds == 0 ? -1 : totalMessagesReceived / elapsedMilliseconds * 1000;
Expand Down
33 changes: 19 additions & 14 deletions src/benchmark/RemotePingPong/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static Config CreateActorSystemConfig(string actorSystemName, string ipOr
return bindingConfig.WithFallback(baseConfig);
}

private static void Main(params string[] args)
private static async Task Main(params string[] args)
{
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
uint timesToRun;
Expand All @@ -76,14 +76,12 @@ private static void Main(params string[] args)
timesToRun = 1u;
}

Start(timesToRun);
Console.ReadKey();
await Start(timesToRun);
}

private static async void Start(uint timesToRun)
{
const long repeat = 100000L;
private static bool _firstRun = true;

private static void PrintSysInfo(){
var processorCount = Environment.ProcessorCount;
if (processorCount == 0)
{
Expand All @@ -92,24 +90,25 @@ private static async void Start(uint timesToRun)
return;
}

#if THREADS
int workerThreads;
int completionPortThreads;
ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);

Console.WriteLine("Worker threads: {0}", workerThreads);
Console.WriteLine("OSVersion: {0}", Environment.OSVersion);
#endif
Console.WriteLine("ProcessorCount: {0}", processorCount);
Console.WriteLine("ClockSpeed: {0} MHZ", CpuSpeed());
Console.WriteLine("Actor Count: {0}", processorCount * 2);
Console.WriteLine("Messages sent/received per client: {0} ({0:0e0})", repeat*2);
Console.WriteLine("Is Server GC: {0}", GCSettings.IsServerGC);
Console.WriteLine("Thread count: {0}", Process.GetCurrentProcess().Threads.Count);
Console.WriteLine();

//Print tables
Console.WriteLine("Num clients, Total [msg], Msgs/sec, Total [ms]");

_firstRun = false;
}

const long repeat = 100000L;

private static async Task Start(uint timesToRun)
{
for (var i = 0; i < timesToRun; i++)
{
var redCount = 0;
Expand Down Expand Up @@ -182,6 +181,12 @@ private static long GetTotalMessagesReceived(int numberOfClients, long numberOfR
throw new Exception("Received report that 1 or more remote actor is unable to begin the test. Aborting run.");
}

// now that the dispatchers in both ActorSystems are started, we want to measure thread count and other system
// metrics here - but only the very first benchmark
if(_firstRun){
PrintSysInfo();
}

var sw = Stopwatch.StartNew();
receivers.ForEach(c =>
{
Expand All @@ -193,7 +198,7 @@ private static long GetTotalMessagesReceived(int numberOfClients, long numberOfR
sw.Stop();

// force clean termination
var termination = Task.WhenAll(new[] { system1.Terminate(), system2.Terminate() }).Wait(TimeSpan.FromSeconds(10));
await Task.WhenAll(new[] { system1.Terminate(), system2.Terminate() });

var elapsedMilliseconds = sw.ElapsedMilliseconds;
long throughput = elapsedMilliseconds == 0 ? -1 : (long)Math.Ceiling((double)totalMessagesReceived / elapsedMilliseconds * 1000);
Expand Down