From 3be652976d576a1110377e02a85e2c1c5e0ebbd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Oct 2021 09:43:58 +0000 Subject: [PATCH 01/22] Bump AkkaVersion from 1.4.21 to 1.4.27 (#225) Bumps `AkkaVersion` from 1.4.21 to 1.4.27. Updates `Akka.TestKit.XUnit2` from 1.4.21 to 1.4.27 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.21...1.4.27) Updates `Akka.Cluster` from 1.4.21 to 1.4.27 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.21...1.4.27) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index b5e398b2..69bd9f93 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.21 + 1.4.27 0.8.5 From 6a275fda1a2226a21d0b1f0bbb365ecdf238f38f Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Wed, 27 Oct 2021 04:50:55 -0500 Subject: [PATCH 02/22] updated Linux build to use 20.04 (#227) --- build-system/linux-pr-validation.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/linux-pr-validation.yaml b/build-system/linux-pr-validation.yaml index d1ec21ec..cd42e67f 100644 --- a/build-system/linux-pr-validation.yaml +++ b/build-system/linux-pr-validation.yaml @@ -17,6 +17,6 @@ jobs: - template: azure-pipeline.template.yaml parameters: name: Ubuntu - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-20.04' scriptFileName: ./build.sh - scriptArgs: all \ No newline at end of file + scriptArgs: all From c4a89ea90b3cefbcd3fab085493f28875ac6060a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Oct 2021 10:01:47 +0000 Subject: [PATCH 03/22] Bump Microsoft.NET.Test.Sdk from 16.10.0 to 16.11.0 (#220) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.10.0 to 16.11.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.10.0...v16.11.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Aaron Stannard --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 69bd9f93..e18654ff 100644 --- a/src/common.props +++ b/src/common.props @@ -16,7 +16,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 - 16.10.0 + 16.11.0 5.10.3 netcoreapp3.1 netstandard1.6 From fb4563c0969086f04ed144ba8057e8079efa72f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:51:38 +0000 Subject: [PATCH 04/22] Bump AkkaVersion from 1.4.27 to 1.4.28 (#230) Bumps `AkkaVersion` from 1.4.27 to 1.4.28. Updates `Akka.TestKit.XUnit2` from 1.4.27 to 1.4.28 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.27...1.4.28) Updates `Akka.Cluster` from 1.4.27 to 1.4.28 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.27...1.4.28) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index e18654ff..2b3583ff 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.27 + 1.4.28 0.8.5 From 2bbc3a11de154562caea3076fd57dd0e749e4ac1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:56:47 +0000 Subject: [PATCH 05/22] Bump Microsoft.NET.Test.Sdk from 16.11.0 to 17.0.0 (#228) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.11.0 to 17.0.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.11.0...v17.0.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 2b3583ff..a7b5dbd6 100644 --- a/src/common.props +++ b/src/common.props @@ -16,7 +16,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 - 16.11.0 + 17.0.0 5.10.3 netcoreapp3.1 netstandard1.6 From 58abf8fa10f196731ea971261ff06fa3d9fd36f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Dec 2021 13:46:18 +0000 Subject: [PATCH 06/22] Bump AkkaVersion from 1.4.28 to 1.4.29 (#233) Bumps `AkkaVersion` from 1.4.28 to 1.4.29. Updates `Akka.TestKit.XUnit2` from 1.4.28 to 1.4.29 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.28...1.4.29) Updates `Akka.Cluster` from 1.4.28 to 1.4.29 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.28...1.4.29) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index a7b5dbd6..b85359e6 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.28 + 1.4.29 0.8.5 From 9a9b9370171b7ad4e66e67b028688038de577c6b Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Fri, 21 Jan 2022 08:56:36 +0700 Subject: [PATCH 07/22] Implement CPU benchmark project (#237) --- Lighthouse.sln | 6 + .../Lighthouse.Tests.Benchmark.csproj | 23 +++ src/Lighthouse.Tests.Benchmark/Program.cs | 164 ++++++++++++++++++ src/Lighthouse.Tests.Benchmark/akka.hocon | 38 ++++ src/Lighthouse/LighthouseHostFactory.cs | 17 +- 5 files changed, 241 insertions(+), 7 deletions(-) create mode 100644 src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj create mode 100644 src/Lighthouse.Tests.Benchmark/Program.cs create mode 100644 src/Lighthouse.Tests.Benchmark/akka.hocon diff --git a/Lighthouse.sln b/Lighthouse.sln index f1f9f3cf..6d4ef30b 100644 --- a/Lighthouse.sln +++ b/Lighthouse.sln @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{183986D1 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lighthouse", "src\Lighthouse\Lighthouse.csproj", "{5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lighthouse.Tests.Benchmark", "src\Lighthouse.Tests.Benchmark\Lighthouse.Tests.Benchmark.csproj", "{652331F0-292D-4EDF-B1A0-D8F6DC486DCE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,6 +31,10 @@ Global {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Release|Any CPU.Build.0 = Release|Any CPU + {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj b/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj new file mode 100644 index 00000000..8c1ece88 --- /dev/null +++ b/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj @@ -0,0 +1,23 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/src/Lighthouse.Tests.Benchmark/Program.cs b/src/Lighthouse.Tests.Benchmark/Program.cs new file mode 100644 index 00000000..87e6e014 --- /dev/null +++ b/src/Lighthouse.Tests.Benchmark/Program.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Akka.Actor; +using Akka.Configuration; +using Tmds.Utils; +using Universe.CpuUsage; + +namespace Lighthouse.Tests.Benchmark +{ + public static class Program + { + private const int TestLength = 30; // in seconds + private const int TestDelay = 5; // in seconds + private const int TestRepeat = 20; + private const int TestClusterSize = 10; + + private const string ActorSystemName = "CpuTest"; + private const string LighthouseAddress = "127.0.0.1"; + private const int LighthousePort = 54053; + + private static readonly List Usages = new List(); + private static readonly List Processes = new List(); + + public static async Task Main(string[] args) + { + // ExecFunction hook + if (ExecFunction.IsExecFunctionCommand(args)) + return ExecFunction.Program.Main(args); + + // Start lighthouse + var service = new LighthouseService(LighthouseAddress, LighthousePort, ActorSystemName); + service.Start(); + + var executor = new FunctionExecutor(o => + { + o.StartInfo.RedirectStandardError = true; + o.OnExit = p => + { + if (p.ExitCode != 0) + { + var message = + "Function execution failed with exit code: " + + $"{p.ExitCode}{Environment.NewLine}{p.StandardError.ReadToEnd()}"; + throw new Exception(message); + } + }; + }); + + // Spin up cluster nodes + for (var port = LighthousePort + 1; port < LighthousePort + 1 + TestClusterSize; ++port) + { + Processes.Add(executor.Start(LaunchNode, new [] + { + LighthouseAddress, + LighthousePort.ToString(), + ActorSystemName, + port.ToString() + })); + } + + // Wait until things settles down + await Task.Delay(TimeSpan.FromSeconds(TestDelay)); + + // Warm up + foreach (var _ in Enumerable.Range(0, 5)) + { + CpuUsage.GetByProcess(); + } + + // Start benchmark + foreach (var i in Enumerable.Range(1, TestRepeat)) + { + var start = CpuUsage.GetByProcess(); + await Task.Delay(TimeSpan.FromSeconds(TestLength)); + var end = CpuUsage.GetByProcess(); + var final = end - start; + + Console.WriteLine($"{i}. Cpu Usage: {final}"); + Usages.Add(final.Value); + } + + // Kill cluster node processes + foreach (var process in Processes) + { + process.Kill(); + process.Dispose(); + } + + // Stop lighthouse + await service.StopAsync(); + + // Generate report + var sb = new StringBuilder(); + sb.AppendLine("CPU Benchmark complete."); + sb.AppendLine(); + + var num = 1; + foreach (var usage in Usages) + { + sb.AppendLine($"{num++}. CPU usage: user: {usage.UserUsage.TotalMicroSeconds / 1000.0} ms, " + + $"kernel: {usage.KernelUsage.TotalMicroSeconds / 1000.0} ms, " + + $"total: {usage.TotalMicroSeconds / 1000.0} ms"); + } + + sb.AppendLine() + .AppendLine(" CPU | Mean | StdErr | StdDev | Median |") + .AppendLine("---- |----- |------- |------- |------- |") + .AppendLine(CalculateResult(Usages + .Select(u => u.UserUsage.TotalMicroSeconds) + .OrderBy(i => i).ToArray(), "User")) + .AppendLine(CalculateResult(Usages + .Select(u => u.KernelUsage.TotalMicroSeconds) + .OrderBy(i => i).ToArray(), "Kernel")); + + Console.WriteLine(sb.ToString()); + + return 0; + } + + private static string CalculateResult(long[] times, string name) + { + var medianIndex = times.Length / 2; + + var mean = times.Average(); + var stdDev = Math.Sqrt(times.Average(v => Math.Pow(v - mean, 2))); + var stdErr = stdDev / Math.Sqrt(times.Length); + double median; + if (times.Length % 2 == 0) + median = (times[medianIndex - 1] + times[medianIndex]) / 2.0; + else + median = times[medianIndex]; + + return $" {name} | {(mean / 1000.0):N3} ms | {(stdErr / 1000.0):N3} ms | {(stdDev / 1000.0):N3} ms | {(median / 1000.0):N3} ms |"; + } + + // Function will be deployed in separate processes as Main() + private static async Task LaunchNode(string[] args) + { + var seedAddress = args[1]; + var seedPort = int.Parse(args[2]); + var systemName = args[3]; + var port = int.Parse(args[4]); + + var config = ConfigurationFactory.ParseString($@" + akka.actor.provider = cluster + akka.cluster.seed-nodes = [""{new Address("akka.tcp", systemName, seedAddress.Trim(), seedPort)}""] + akka.remote.dot-netty.tcp {{ + public-hostname=""{seedAddress}"" + port={port} + }}"); + + var system = ActorSystem.Create(systemName, config); + + // wait forever until we get killed + await Task.Delay(TimeSpan.FromDays(1)); + + return 0; + } + } +} diff --git a/src/Lighthouse.Tests.Benchmark/akka.hocon b/src/Lighthouse.Tests.Benchmark/akka.hocon new file mode 100644 index 00000000..c5f51514 --- /dev/null +++ b/src/Lighthouse.Tests.Benchmark/akka.hocon @@ -0,0 +1,38 @@ +lighthouse{ + actorsystem: "actor-system" #POPULATE NAME OF YOUR ACTOR SYSTEM HERE +} + +# See petabridge.cmd configuration options here: https://cmd.petabridge.com/articles/install/host-configuration.html +petabridge.cmd{ + # default IP address used to listen for incoming petabridge.cmd client connections + # should be a safe default as it listens on "all network interfaces". + host = "0.0.0.0" + + # default port number used to listen for incoming petabridge.cmd client connections + port = 9110 +} + +akka { + actor { + provider = cluster + } + + remote { + log-remote-lifecycle-events = DEBUG + dot-netty.tcp { + transport-class = "Akka.Remote.Transport.DotNetty.TcpTransport, Akka.Remote" + applied-adapters = [] + transport-protocol = tcp + #will be populated with a dynamic host-name at runtime if left uncommented + # public-hostname = "127.0.0.1" + # hostname = "0.0.0.0" + # port = 4053 + } + } + + cluster { + #will inject this node as a self-seed node at run-time + seed-nodes = [] + roles = [lighthouse] + } +} \ No newline at end of file diff --git a/src/Lighthouse/LighthouseHostFactory.cs b/src/Lighthouse/LighthouseHostFactory.cs index c3fb11ad..ddcbc11e 100755 --- a/src/Lighthouse/LighthouseHostFactory.cs +++ b/src/Lighthouse/LighthouseHostFactory.cs @@ -24,13 +24,11 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi { systemName = systemName ?? Environment.GetEnvironmentVariable("ACTORSYSTEM")?.Trim(); - - // Set environment variables for use inside Akka.Bootstrap.Docker - // If overrides were provided to this method. - //if (!string.IsNullOrEmpty(ipAddress)) Environment.SetEnvironmentVariable("CLUSTER_IP", ipAddress); - - //if (specifiedPort != null) - // Environment.SetEnvironmentVariable("CLUSTER_PORT", specifiedPort.Value.ToString()); + var argConfig = ""; + if (ipAddress != null) + argConfig += $"akka.remote.dot-netty.tcp.public-hostname = {ipAddress}\n"; + if (specifiedPort != null) + argConfig += $"akka.remote.dot-netty.tcp.port = {specifiedPort}"; var useDocker = !(IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_IP")?.Trim()) || IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_SEEDS")?.Trim())); @@ -41,6 +39,11 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi if (useDocker) clusterConfig = clusterConfig.BootstrapFromDocker(); + // Values from method arguments should always win + if (!IsNullOrEmpty(argConfig)) + clusterConfig = ConfigurationFactory.ParseString(argConfig) + .WithFallback(clusterConfig); + var lighthouseConfig = clusterConfig.GetConfig("lighthouse"); if (lighthouseConfig != null && IsNullOrEmpty(systemName)) systemName = lighthouseConfig.GetString("actorsystem", systemName); From 3d41037c50395347a3773a4564c985420600d873 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Tue, 25 Jan 2022 03:18:14 +0700 Subject: [PATCH 08/22] Change CPU benchmark to time domain analysis instead of values (#239) --- src/Lighthouse.Tests.Benchmark/Program.cs | 46 ++++++++++++++++------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Lighthouse.Tests.Benchmark/Program.cs b/src/Lighthouse.Tests.Benchmark/Program.cs index 87e6e014..c1afdcae 100644 --- a/src/Lighthouse.Tests.Benchmark/Program.cs +++ b/src/Lighthouse.Tests.Benchmark/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,10 +14,12 @@ namespace Lighthouse.Tests.Benchmark { public static class Program { - private const int TestLength = 30; // in seconds + private const int TestLength = 5; // in seconds private const int TestDelay = 5; // in seconds - private const int TestRepeat = 20; + private const int TestRepeat = 60; private const int TestClusterSize = 10; + + private const int WarmUpRepeat = 5; private const string ActorSystemName = "CpuTest"; private const string LighthouseAddress = "127.0.0.1"; @@ -66,10 +69,16 @@ public static async Task Main(string[] args) await Task.Delay(TimeSpan.FromSeconds(TestDelay)); // Warm up - foreach (var _ in Enumerable.Range(0, 5)) + foreach (var i in Enumerable.Range(1, WarmUpRepeat)) { - CpuUsage.GetByProcess(); + var start = CpuUsage.GetByProcess(); + await Task.Delay(TimeSpan.FromSeconds(TestLength)); + var end = CpuUsage.GetByProcess(); + var final = end - start; + + Console.WriteLine($"{i}. [Warmup] {final}"); } + Console.WriteLine(); // Start benchmark foreach (var i in Enumerable.Range(1, TestRepeat)) @@ -93,18 +102,29 @@ public static async Task Main(string[] args) // Stop lighthouse await service.StopAsync(); - // Generate report + // Generate csv report + var now = DateTime.Now; var sb = new StringBuilder(); - sb.AppendLine("CPU Benchmark complete."); - sb.AppendLine(); - - var num = 1; - foreach (var usage in Usages) + sb.AppendLine($"CPU Benchmark {now}"); + sb.AppendLine($"Sample Time,{TestLength},second(s)"); + sb.AppendLine($"Sample points,{TestRepeat}"); + sb.AppendLine($"Cluster size,{TestClusterSize},node(s)"); + sb.AppendLine("Sample time,User usage,User percent,Kernel usage,Kernel percent,Total usage,Total percent"); + foreach (var iter in Enumerable.Range(1, TestRepeat)) { - sb.AppendLine($"{num++}. CPU usage: user: {usage.UserUsage.TotalMicroSeconds / 1000.0} ms, " + - $"kernel: {usage.KernelUsage.TotalMicroSeconds / 1000.0} ms, " + - $"total: {usage.TotalMicroSeconds / 1000.0} ms"); + var usage = Usages[iter - 1]; + var user = usage.UserUsage.TotalSeconds; + var kernel = usage.KernelUsage.TotalSeconds; + var total = usage.TotalMicroSeconds / 1000000.0; + sb.AppendLine($"{iter * TestLength},{user},{(user/TestLength)*100},{kernel},{(kernel/TestLength)*100},{total},{(total/TestLength)*100}"); } + + await File.WriteAllTextAsync($"CpuBenchmark_{now.ToFileTime()}.csv", sb.ToString()); + + // Generate console report + sb.Clear(); + sb.AppendLine("CPU Benchmark complete."); + sb.AppendLine(); sb.AppendLine() .AppendLine(" CPU | Mean | StdErr | StdDev | Median |") From 3ccb1bf6340aa2e00f4bb9ddb7c8d3c5d2b26876 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 20:24:27 +0000 Subject: [PATCH 09/22] Bump AkkaVersion from 1.4.29 to 1.4.32 (#236) Bumps `AkkaVersion` from 1.4.29 to 1.4.32. Updates `Akka.TestKit.XUnit2` from 1.4.29 to 1.4.32 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.29...1.4.32) Updates `Akka.Cluster` from 1.4.29 to 1.4.32 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.29...1.4.32) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index b85359e6..c0f472a6 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.29 + 1.4.32 0.8.5 From c8763a75c6298686f2882219b304f419b39a4103 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 20:31:07 +0000 Subject: [PATCH 10/22] Bump FluentAssertions from 5.10.3 to 6.4.0 (#238) Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 5.10.3 to 6.4.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/master/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/5.10.3...6.4.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index c0f472a6..67a265b2 100644 --- a/src/common.props +++ b/src/common.props @@ -17,7 +17,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 17.0.0 - 5.10.3 + 6.4.0 netcoreapp3.1 netstandard1.6 net461 From 6b3a47c998537b9c81920730c719c4d8428a83a4 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Tue, 25 Jan 2022 09:20:34 -0600 Subject: [PATCH 11/22] Revert "Change CPU benchmark to time domain analysis instead of values (#239)" This reverts commit 3d41037c50395347a3773a4564c985420600d873. --- src/Lighthouse.Tests.Benchmark/Program.cs | 46 +++++++---------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/src/Lighthouse.Tests.Benchmark/Program.cs b/src/Lighthouse.Tests.Benchmark/Program.cs index c1afdcae..87e6e014 100644 --- a/src/Lighthouse.Tests.Benchmark/Program.cs +++ b/src/Lighthouse.Tests.Benchmark/Program.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,12 +13,10 @@ namespace Lighthouse.Tests.Benchmark { public static class Program { - private const int TestLength = 5; // in seconds + private const int TestLength = 30; // in seconds private const int TestDelay = 5; // in seconds - private const int TestRepeat = 60; + private const int TestRepeat = 20; private const int TestClusterSize = 10; - - private const int WarmUpRepeat = 5; private const string ActorSystemName = "CpuTest"; private const string LighthouseAddress = "127.0.0.1"; @@ -69,16 +66,10 @@ public static async Task Main(string[] args) await Task.Delay(TimeSpan.FromSeconds(TestDelay)); // Warm up - foreach (var i in Enumerable.Range(1, WarmUpRepeat)) + foreach (var _ in Enumerable.Range(0, 5)) { - var start = CpuUsage.GetByProcess(); - await Task.Delay(TimeSpan.FromSeconds(TestLength)); - var end = CpuUsage.GetByProcess(); - var final = end - start; - - Console.WriteLine($"{i}. [Warmup] {final}"); + CpuUsage.GetByProcess(); } - Console.WriteLine(); // Start benchmark foreach (var i in Enumerable.Range(1, TestRepeat)) @@ -102,30 +93,19 @@ public static async Task Main(string[] args) // Stop lighthouse await service.StopAsync(); - // Generate csv report - var now = DateTime.Now; + // Generate report var sb = new StringBuilder(); - sb.AppendLine($"CPU Benchmark {now}"); - sb.AppendLine($"Sample Time,{TestLength},second(s)"); - sb.AppendLine($"Sample points,{TestRepeat}"); - sb.AppendLine($"Cluster size,{TestClusterSize},node(s)"); - sb.AppendLine("Sample time,User usage,User percent,Kernel usage,Kernel percent,Total usage,Total percent"); - foreach (var iter in Enumerable.Range(1, TestRepeat)) - { - var usage = Usages[iter - 1]; - var user = usage.UserUsage.TotalSeconds; - var kernel = usage.KernelUsage.TotalSeconds; - var total = usage.TotalMicroSeconds / 1000000.0; - sb.AppendLine($"{iter * TestLength},{user},{(user/TestLength)*100},{kernel},{(kernel/TestLength)*100},{total},{(total/TestLength)*100}"); - } - - await File.WriteAllTextAsync($"CpuBenchmark_{now.ToFileTime()}.csv", sb.ToString()); - - // Generate console report - sb.Clear(); sb.AppendLine("CPU Benchmark complete."); sb.AppendLine(); + var num = 1; + foreach (var usage in Usages) + { + sb.AppendLine($"{num++}. CPU usage: user: {usage.UserUsage.TotalMicroSeconds / 1000.0} ms, " + + $"kernel: {usage.KernelUsage.TotalMicroSeconds / 1000.0} ms, " + + $"total: {usage.TotalMicroSeconds / 1000.0} ms"); + } + sb.AppendLine() .AppendLine(" CPU | Mean | StdErr | StdDev | Median |") .AppendLine("---- |----- |------- |------- |------- |") From aa246dd92256a7f70dd54bdbee6be7c52ae53e4b Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Tue, 25 Jan 2022 22:38:03 +0700 Subject: [PATCH 12/22] Revert "Implement CPU benchmark project (#237)" This reverts commit 9a9b9370171b7ad4e66e67b028688038de577c6b. --- Lighthouse.sln | 6 - .../Lighthouse.Tests.Benchmark.csproj | 23 --- src/Lighthouse.Tests.Benchmark/Program.cs | 164 ------------------ src/Lighthouse.Tests.Benchmark/akka.hocon | 38 ---- src/Lighthouse/LighthouseHostFactory.cs | 17 +- 5 files changed, 7 insertions(+), 241 deletions(-) delete mode 100644 src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj delete mode 100644 src/Lighthouse.Tests.Benchmark/Program.cs delete mode 100644 src/Lighthouse.Tests.Benchmark/akka.hocon diff --git a/Lighthouse.sln b/Lighthouse.sln index 6d4ef30b..f1f9f3cf 100644 --- a/Lighthouse.sln +++ b/Lighthouse.sln @@ -15,8 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{183986D1 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lighthouse", "src\Lighthouse\Lighthouse.csproj", "{5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lighthouse.Tests.Benchmark", "src\Lighthouse.Tests.Benchmark\Lighthouse.Tests.Benchmark.csproj", "{652331F0-292D-4EDF-B1A0-D8F6DC486DCE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,10 +29,6 @@ Global {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5CA6B9E7-DAF2-47BD-9C91-7E979B4935A1}.Release|Any CPU.Build.0 = Release|Any CPU - {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {652331F0-292D-4EDF-B1A0-D8F6DC486DCE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj b/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj deleted file mode 100644 index 8c1ece88..00000000 --- a/src/Lighthouse.Tests.Benchmark/Lighthouse.Tests.Benchmark.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - - - - - - - - - - PreserveNewest - - - - diff --git a/src/Lighthouse.Tests.Benchmark/Program.cs b/src/Lighthouse.Tests.Benchmark/Program.cs deleted file mode 100644 index 87e6e014..00000000 --- a/src/Lighthouse.Tests.Benchmark/Program.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Akka.Actor; -using Akka.Configuration; -using Tmds.Utils; -using Universe.CpuUsage; - -namespace Lighthouse.Tests.Benchmark -{ - public static class Program - { - private const int TestLength = 30; // in seconds - private const int TestDelay = 5; // in seconds - private const int TestRepeat = 20; - private const int TestClusterSize = 10; - - private const string ActorSystemName = "CpuTest"; - private const string LighthouseAddress = "127.0.0.1"; - private const int LighthousePort = 54053; - - private static readonly List Usages = new List(); - private static readonly List Processes = new List(); - - public static async Task Main(string[] args) - { - // ExecFunction hook - if (ExecFunction.IsExecFunctionCommand(args)) - return ExecFunction.Program.Main(args); - - // Start lighthouse - var service = new LighthouseService(LighthouseAddress, LighthousePort, ActorSystemName); - service.Start(); - - var executor = new FunctionExecutor(o => - { - o.StartInfo.RedirectStandardError = true; - o.OnExit = p => - { - if (p.ExitCode != 0) - { - var message = - "Function execution failed with exit code: " + - $"{p.ExitCode}{Environment.NewLine}{p.StandardError.ReadToEnd()}"; - throw new Exception(message); - } - }; - }); - - // Spin up cluster nodes - for (var port = LighthousePort + 1; port < LighthousePort + 1 + TestClusterSize; ++port) - { - Processes.Add(executor.Start(LaunchNode, new [] - { - LighthouseAddress, - LighthousePort.ToString(), - ActorSystemName, - port.ToString() - })); - } - - // Wait until things settles down - await Task.Delay(TimeSpan.FromSeconds(TestDelay)); - - // Warm up - foreach (var _ in Enumerable.Range(0, 5)) - { - CpuUsage.GetByProcess(); - } - - // Start benchmark - foreach (var i in Enumerable.Range(1, TestRepeat)) - { - var start = CpuUsage.GetByProcess(); - await Task.Delay(TimeSpan.FromSeconds(TestLength)); - var end = CpuUsage.GetByProcess(); - var final = end - start; - - Console.WriteLine($"{i}. Cpu Usage: {final}"); - Usages.Add(final.Value); - } - - // Kill cluster node processes - foreach (var process in Processes) - { - process.Kill(); - process.Dispose(); - } - - // Stop lighthouse - await service.StopAsync(); - - // Generate report - var sb = new StringBuilder(); - sb.AppendLine("CPU Benchmark complete."); - sb.AppendLine(); - - var num = 1; - foreach (var usage in Usages) - { - sb.AppendLine($"{num++}. CPU usage: user: {usage.UserUsage.TotalMicroSeconds / 1000.0} ms, " + - $"kernel: {usage.KernelUsage.TotalMicroSeconds / 1000.0} ms, " + - $"total: {usage.TotalMicroSeconds / 1000.0} ms"); - } - - sb.AppendLine() - .AppendLine(" CPU | Mean | StdErr | StdDev | Median |") - .AppendLine("---- |----- |------- |------- |------- |") - .AppendLine(CalculateResult(Usages - .Select(u => u.UserUsage.TotalMicroSeconds) - .OrderBy(i => i).ToArray(), "User")) - .AppendLine(CalculateResult(Usages - .Select(u => u.KernelUsage.TotalMicroSeconds) - .OrderBy(i => i).ToArray(), "Kernel")); - - Console.WriteLine(sb.ToString()); - - return 0; - } - - private static string CalculateResult(long[] times, string name) - { - var medianIndex = times.Length / 2; - - var mean = times.Average(); - var stdDev = Math.Sqrt(times.Average(v => Math.Pow(v - mean, 2))); - var stdErr = stdDev / Math.Sqrt(times.Length); - double median; - if (times.Length % 2 == 0) - median = (times[medianIndex - 1] + times[medianIndex]) / 2.0; - else - median = times[medianIndex]; - - return $" {name} | {(mean / 1000.0):N3} ms | {(stdErr / 1000.0):N3} ms | {(stdDev / 1000.0):N3} ms | {(median / 1000.0):N3} ms |"; - } - - // Function will be deployed in separate processes as Main() - private static async Task LaunchNode(string[] args) - { - var seedAddress = args[1]; - var seedPort = int.Parse(args[2]); - var systemName = args[3]; - var port = int.Parse(args[4]); - - var config = ConfigurationFactory.ParseString($@" - akka.actor.provider = cluster - akka.cluster.seed-nodes = [""{new Address("akka.tcp", systemName, seedAddress.Trim(), seedPort)}""] - akka.remote.dot-netty.tcp {{ - public-hostname=""{seedAddress}"" - port={port} - }}"); - - var system = ActorSystem.Create(systemName, config); - - // wait forever until we get killed - await Task.Delay(TimeSpan.FromDays(1)); - - return 0; - } - } -} diff --git a/src/Lighthouse.Tests.Benchmark/akka.hocon b/src/Lighthouse.Tests.Benchmark/akka.hocon deleted file mode 100644 index c5f51514..00000000 --- a/src/Lighthouse.Tests.Benchmark/akka.hocon +++ /dev/null @@ -1,38 +0,0 @@ -lighthouse{ - actorsystem: "actor-system" #POPULATE NAME OF YOUR ACTOR SYSTEM HERE -} - -# See petabridge.cmd configuration options here: https://cmd.petabridge.com/articles/install/host-configuration.html -petabridge.cmd{ - # default IP address used to listen for incoming petabridge.cmd client connections - # should be a safe default as it listens on "all network interfaces". - host = "0.0.0.0" - - # default port number used to listen for incoming petabridge.cmd client connections - port = 9110 -} - -akka { - actor { - provider = cluster - } - - remote { - log-remote-lifecycle-events = DEBUG - dot-netty.tcp { - transport-class = "Akka.Remote.Transport.DotNetty.TcpTransport, Akka.Remote" - applied-adapters = [] - transport-protocol = tcp - #will be populated with a dynamic host-name at runtime if left uncommented - # public-hostname = "127.0.0.1" - # hostname = "0.0.0.0" - # port = 4053 - } - } - - cluster { - #will inject this node as a self-seed node at run-time - seed-nodes = [] - roles = [lighthouse] - } -} \ No newline at end of file diff --git a/src/Lighthouse/LighthouseHostFactory.cs b/src/Lighthouse/LighthouseHostFactory.cs index ddcbc11e..c3fb11ad 100755 --- a/src/Lighthouse/LighthouseHostFactory.cs +++ b/src/Lighthouse/LighthouseHostFactory.cs @@ -24,11 +24,13 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi { systemName = systemName ?? Environment.GetEnvironmentVariable("ACTORSYSTEM")?.Trim(); - var argConfig = ""; - if (ipAddress != null) - argConfig += $"akka.remote.dot-netty.tcp.public-hostname = {ipAddress}\n"; - if (specifiedPort != null) - argConfig += $"akka.remote.dot-netty.tcp.port = {specifiedPort}"; + + // Set environment variables for use inside Akka.Bootstrap.Docker + // If overrides were provided to this method. + //if (!string.IsNullOrEmpty(ipAddress)) Environment.SetEnvironmentVariable("CLUSTER_IP", ipAddress); + + //if (specifiedPort != null) + // Environment.SetEnvironmentVariable("CLUSTER_PORT", specifiedPort.Value.ToString()); var useDocker = !(IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_IP")?.Trim()) || IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_SEEDS")?.Trim())); @@ -39,11 +41,6 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi if (useDocker) clusterConfig = clusterConfig.BootstrapFromDocker(); - // Values from method arguments should always win - if (!IsNullOrEmpty(argConfig)) - clusterConfig = ConfigurationFactory.ParseString(argConfig) - .WithFallback(clusterConfig); - var lighthouseConfig = clusterConfig.GetConfig("lighthouse"); if (lighthouseConfig != null && IsNullOrEmpty(systemName)) systemName = lighthouseConfig.GetString("actorsystem", systemName); From 46defefa9e5e6e7372b1e35341e1d50014c51c06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:10:41 +0000 Subject: [PATCH 13/22] Bump AkkaVersion from 1.4.32 to 1.4.35 (#250) Bumps `AkkaVersion` from 1.4.32 to 1.4.35. Updates `Akka.TestKit.XUnit2` from 1.4.32 to 1.4.35 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.32...1.4.35) Updates `Akka.Cluster` from 1.4.32 to 1.4.35 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.32...1.4.35) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 67a265b2..f552ea4c 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.32 + 1.4.35 0.8.5 From ae224b3bfb1e60dfb6d1507bbe963c046fd142fa Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Mon, 21 Mar 2022 19:15:46 +0700 Subject: [PATCH 14/22] Fix LighthouseHostFactory argument are being ignored (#243) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/Lighthouse/LighthouseHostFactory.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Lighthouse/LighthouseHostFactory.cs b/src/Lighthouse/LighthouseHostFactory.cs index c3fb11ad..ddcbc11e 100755 --- a/src/Lighthouse/LighthouseHostFactory.cs +++ b/src/Lighthouse/LighthouseHostFactory.cs @@ -24,13 +24,11 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi { systemName = systemName ?? Environment.GetEnvironmentVariable("ACTORSYSTEM")?.Trim(); - - // Set environment variables for use inside Akka.Bootstrap.Docker - // If overrides were provided to this method. - //if (!string.IsNullOrEmpty(ipAddress)) Environment.SetEnvironmentVariable("CLUSTER_IP", ipAddress); - - //if (specifiedPort != null) - // Environment.SetEnvironmentVariable("CLUSTER_PORT", specifiedPort.Value.ToString()); + var argConfig = ""; + if (ipAddress != null) + argConfig += $"akka.remote.dot-netty.tcp.public-hostname = {ipAddress}\n"; + if (specifiedPort != null) + argConfig += $"akka.remote.dot-netty.tcp.port = {specifiedPort}"; var useDocker = !(IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_IP")?.Trim()) || IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_SEEDS")?.Trim())); @@ -41,6 +39,11 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi if (useDocker) clusterConfig = clusterConfig.BootstrapFromDocker(); + // Values from method arguments should always win + if (!IsNullOrEmpty(argConfig)) + clusterConfig = ConfigurationFactory.ParseString(argConfig) + .WithFallback(clusterConfig); + var lighthouseConfig = clusterConfig.GetConfig("lighthouse"); if (lighthouseConfig != null && IsNullOrEmpty(systemName)) systemName = lighthouseConfig.GetString("actorsystem", systemName); From 3c6c17a4e67531e80b7dbe1da9695a6997203662 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:21:37 +0000 Subject: [PATCH 15/22] Bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.1.0 (#247) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.0.0 to 17.1.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.0.0...v17.1.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index f552ea4c..14484eb4 100644 --- a/src/common.props +++ b/src/common.props @@ -16,7 +16,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 - 17.0.0 + 17.1.0 6.4.0 netcoreapp3.1 netstandard1.6 From 0f46ec3364aac7f07ccf5ba99d01599783891e1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:39:54 +0000 Subject: [PATCH 16/22] Bump FluentAssertions from 6.4.0 to 6.5.1 (#245) Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.4.0 to 6.5.1. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.4.0...6.5.1) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Aaron Stannard --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 14484eb4..142cdee8 100644 --- a/src/common.props +++ b/src/common.props @@ -17,7 +17,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 17.1.0 - 6.4.0 + 6.5.1 netcoreapp3.1 netstandard1.6 net461 From 1fcb3bc802a0a3f7fc63248607791482695073de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:59:45 +0000 Subject: [PATCH 17/22] Bump AkkaVersion from 1.4.35 to 1.4.36 (#252) Bumps `AkkaVersion` from 1.4.35 to 1.4.36. Updates `Akka.TestKit.XUnit2` from 1.4.35 to 1.4.36 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.35...1.4.36) Updates `Akka.Cluster` from 1.4.35 to 1.4.36 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.35...1.4.36) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 142cdee8..df83ace8 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.35 + 1.4.36 0.8.5 From efd403319610e41773e56edd8e8f680b9e5b0c28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 21:04:18 +0000 Subject: [PATCH 18/22] Bump FluentAssertions from 6.5.1 to 6.6.0 (#251) Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.5.1 to 6.6.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.5.1...6.6.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index df83ace8..6f4e08c3 100644 --- a/src/common.props +++ b/src/common.props @@ -17,7 +17,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ 2.4.1 17.1.0 - 6.5.1 + 6.6.0 netcoreapp3.1 netstandard1.6 net461 From 707f110265cd27302f2b26c36b2716fa8fa11d4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 21:54:12 +0000 Subject: [PATCH 19/22] Bump AkkaVersion from 1.4.36 to 1.4.37 (#253) Bumps `AkkaVersion` from 1.4.36 to 1.4.37. Updates `Akka.TestKit.XUnit2` from 1.4.36 to 1.4.37 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.36...1.4.37) Updates `Akka.Cluster` from 1.4.36 to 1.4.37 - [Release notes](https://github.com/akkadotnet/akka.net/releases) - [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md) - [Commits](https://github.com/akkadotnet/akka.net/compare/1.4.36...1.4.37) --- updated-dependencies: - dependency-name: Akka.TestKit.XUnit2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: Akka.Cluster dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.props b/src/common.props index 6f4e08c3..f1044bb1 100644 --- a/src/common.props +++ b/src/common.props @@ -22,7 +22,7 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netstandard1.6 net461 net461 - 1.4.36 + 1.4.37 0.8.5 From 3fcd4599637feb8b0b18ab8fd17de2168cb2bcd9 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Mon, 18 Apr 2022 18:09:04 -0500 Subject: [PATCH 20/22] migrate to `ChannelExecutor` (#254) * migrate to `ChannelExecutor` * updated release notes * switch to .NET Core 3.1 for testing * Drop 4.6.1 support --- RELEASE_NOTES.md | 12 ++-- src/Lighthouse/Lighthouse.csproj | 14 +---- ...stFactory.cs => LighthouseConfigurator.cs} | 10 ++-- src/Lighthouse/LighthouseService.cs | 56 ------------------- src/Lighthouse/Program.NetCore.cs | 24 -------- src/Lighthouse/Program.NetFramework.cs | 42 -------------- src/Lighthouse/Program.cs | 42 ++++++++++++++ src/Lighthouse/akka.hocon | 38 +++++++++++++ src/common.props | 11 ++-- 9 files changed, 97 insertions(+), 152 deletions(-) rename src/Lighthouse/{LighthouseHostFactory.cs => LighthouseConfigurator.cs} (89%) mode change 100755 => 100644 delete mode 100755 src/Lighthouse/LighthouseService.cs delete mode 100644 src/Lighthouse/Program.NetCore.cs delete mode 100644 src/Lighthouse/Program.NetFramework.cs create mode 100644 src/Lighthouse/Program.cs diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 796bdcf5..bd8598c9 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,9 +1,5 @@ -#### 1.5.5 June 16 2021 #### -* Upgrade [Akka.Bootstrap.Docker to 0.5.3](https://github.com/petabridge/akkadotnet-bootstrap/releases/tag/0.5.3) +#### 1.6.0 April 18 2022 #### -#### 1.5.4 June 16 2021 #### -* Upgraded to [Akka.NET v1.4.21](https://github.com/akkadotnet/akka.net/releases/tag/1.4.21) - -#### 1.5.3 May 10 2021 #### -* Upgraded to [Akka.NET v1.4.19](https://github.com/akkadotnet/akka.net/releases/tag/1.4.19) -* Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_NOTES.html#085-may-03-2021) +* Dropped Topshelf support +* Migrated to [Akka.Hosting](https://github.com/akkadotnet/Akka.Hosting) and `IHostedService` +* Significantly reduced idle CPU consumption by migrating to [`channel-executor` for dispatching](https://getakka.net/articles/actors/dispatchers.html#channelexecutor). \ No newline at end of file diff --git a/src/Lighthouse/Lighthouse.csproj b/src/Lighthouse/Lighthouse.csproj index 2e3f570f..f9dc0178 100644 --- a/src/Lighthouse/Lighthouse.csproj +++ b/src/Lighthouse/Lighthouse.csproj @@ -2,10 +2,10 @@ Exe - $(NetCoreVersion);$(NetFrameworkLibVersion) + $(NetCoreVersion) - + @@ -14,17 +14,9 @@ - - - - - - $(DefineConstants);CORECLR - - PreserveNewest - \ No newline at end of file + diff --git a/src/Lighthouse/LighthouseHostFactory.cs b/src/Lighthouse/LighthouseConfigurator.cs old mode 100755 new mode 100644 similarity index 89% rename from src/Lighthouse/LighthouseHostFactory.cs rename to src/Lighthouse/LighthouseConfigurator.cs index ddcbc11e..7687475f --- a/src/Lighthouse/LighthouseHostFactory.cs +++ b/src/Lighthouse/LighthouseConfigurator.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright (C) 2015 - 2019 Petabridge, LLC // // ----------------------------------------------------------------------- @@ -15,11 +15,11 @@ namespace Lighthouse { /// - /// Launcher for the Lighthouse + /// Configurator for Lighthouse /// - public static class LighthouseHostFactory + public static class LighthouseConfigurator { - public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifiedPort = null, + public static (Config config, string actorSystemName) LaunchLighthouse(string ipAddress = null, int? specifiedPort = null, string systemName = null) { systemName = systemName ?? Environment.GetEnvironmentVariable("ACTORSYSTEM")?.Trim(); @@ -91,7 +91,7 @@ public static ActorSystem LaunchLighthouse(string ipAddress = null, int? specifi .WithFallback(clusterConfig) : clusterConfig; - return ActorSystem.Create(systemName, finalConfig); + return (finalConfig, systemName); } } } \ No newline at end of file diff --git a/src/Lighthouse/LighthouseService.cs b/src/Lighthouse/LighthouseService.cs deleted file mode 100755 index c00ae40c..00000000 --- a/src/Lighthouse/LighthouseService.cs +++ /dev/null @@ -1,56 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015 - 2019 Petabridge, LLC -// -// ----------------------------------------------------------------------- - -using System.Threading.Tasks; -using Akka.Actor; -using Petabridge.Cmd.Cluster; -using Petabridge.Cmd.Host; -using Petabridge.Cmd.Remote; - -namespace Lighthouse -{ - public class LighthouseService - { - private readonly string _actorSystemName; - private readonly string _ipAddress; - private readonly int? _port; - - private ActorSystem _lighthouseSystem; - - public LighthouseService() : this(null, null, null) - { - } - - public LighthouseService(string ipAddress, int? port, string actorSystemName) - { - _ipAddress = ipAddress; - _port = port; - _actorSystemName = actorSystemName; - } - - /// - /// Task completes once the Lighthouse has terminated. - /// - /// - /// Doesn't actually invoke termination. Need to call for that. - /// - public Task TerminationHandle => _lighthouseSystem.WhenTerminated; - - public void Start() - { - _lighthouseSystem = LighthouseHostFactory.LaunchLighthouse(_ipAddress, _port, _actorSystemName); - var pbm = PetabridgeCmd.Get(_lighthouseSystem); - pbm.RegisterCommandPalette(ClusterCommands.Instance); // enable Akka.Cluster management commands - pbm.RegisterCommandPalette(RemoteCommands.Instance); // enable Akka.Remote management commands - pbm.Start(); - } - - public async Task StopAsync() - { - await CoordinatedShutdown.Get(_lighthouseSystem).Run(CoordinatedShutdown.ClrExitReason.Instance); - } - } -} \ No newline at end of file diff --git a/src/Lighthouse/Program.NetCore.cs b/src/Lighthouse/Program.NetCore.cs deleted file mode 100644 index 59a4dd93..00000000 --- a/src/Lighthouse/Program.NetCore.cs +++ /dev/null @@ -1,24 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015 - 2019 Petabridge, LLC -// -// ----------------------------------------------------------------------- - -using System; - -namespace Lighthouse -{ - public partial class Program - { -#if CORECLR - public static void Main(string[] args) - { - var lighthouseService = new LighthouseService(); - lighthouseService.Start(); - Console.WriteLine("Press Control + C to terminate."); - Console.CancelKeyPress += async (sender, eventArgs) => { await lighthouseService.StopAsync(); }; - lighthouseService.TerminationHandle.Wait(); - } -#endif - } -} \ No newline at end of file diff --git a/src/Lighthouse/Program.NetFramework.cs b/src/Lighthouse/Program.NetFramework.cs deleted file mode 100644 index 4da4f98c..00000000 --- a/src/Lighthouse/Program.NetFramework.cs +++ /dev/null @@ -1,42 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015 - 2019 Petabridge, LLC -// -// ----------------------------------------------------------------------- - -#if !CORECLR -using Topshelf; -#endif - -namespace Lighthouse -{ - public partial class Program - { -#if !CORECLR - public static void Main(string[] args) - { - HostFactory.Run(x => - { - x.SetServiceName("Lighthouse"); - x.SetDisplayName("Lighthouse"); - x.SetDescription("Seed node for the Akka Cluster"); - - x.UseAssemblyInfoForServiceInfo(); - x.RunAsLocalSystem(); - x.StartAutomatically(); - - x.Service(sc => - { - sc.ConstructUsing(() => new LighthouseService()); - - // the start and stop methods for the service - sc.WhenStarted(s => s.Start()); - sc.WhenStopped(s => s.StopAsync().Wait()); - }); - - x.EnableServiceRecovery(r => r.RestartService(1)); - }); - } -#endif - } -} \ No newline at end of file diff --git a/src/Lighthouse/Program.cs b/src/Lighthouse/Program.cs new file mode 100644 index 00000000..0d35cb06 --- /dev/null +++ b/src/Lighthouse/Program.cs @@ -0,0 +1,42 @@ +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015 - 2019 Petabridge, LLC +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; +using Akka.Hosting; +using Microsoft.Extensions.Hosting; +using Petabridge.Cmd.Cluster; +using Petabridge.Cmd.Host; +using Petabridge.Cmd.Remote; + +namespace Lighthouse +{ + public class Program + { + public static async Task Main(string[] args) + { + var (config, actorSystemName) = LighthouseConfigurator.LaunchLighthouse(); + var hostBuilder = new HostBuilder(); + hostBuilder.ConfigureServices(services => + { + services.AddAkka(actorSystemName, builder => + { + builder.AddHocon(config) // clustering / remoting automatically configured here + .StartActors((system, registry) => + { + var pbm = PetabridgeCmd.Get(system); + pbm.RegisterCommandPalette(ClusterCommands.Instance); // enable Akka.Cluster management commands + pbm.RegisterCommandPalette(RemoteCommands.Instance); // enable Akka.Remote management commands + pbm.Start(); + }); + }); + }); + + var host = hostBuilder.Build(); + await host.RunAsync(); + } + } +} \ No newline at end of file diff --git a/src/Lighthouse/akka.hocon b/src/Lighthouse/akka.hocon index 68eb4a39..7b9a2b87 100644 --- a/src/Lighthouse/akka.hocon +++ b/src/Lighthouse/akka.hocon @@ -15,10 +15,48 @@ petabridge.cmd{ akka { actor { provider = cluster + + default-dispatcher = { + executor = channel-executor + fork-join-executor { #channelexecutor will re-use these settings + parallelism-min = 2 + parallelism-factor = 1 + parallelism-max = 64 + } + } + + internal-dispatcher = { + executor = channel-executor + throughput = 5 + fork-join-executor { + parallelism-min = 4 + parallelism-factor = 1.0 + parallelism-max = 64 + } + } } remote { log-remote-lifecycle-events = DEBUG + + default-remote-dispatcher { + type = Dispatcher + executor = channel-executor + fork-join-executor { + parallelism-min = 2 + parallelism-factor = 0.5 + parallelism-max = 16 + } + } + + backoff-remote-dispatcher { + executor = channel-executor + fork-join-executor { + parallelism-min = 2 + parallelism-max = 2 + } + } + dot-netty.tcp { transport-class = "Akka.Remote.Transport.DotNetty.TcpTransport, Akka.Remote" applied-adapters = [] diff --git a/src/common.props b/src/common.props index f1044bb1..063c0b2b 100644 --- a/src/common.props +++ b/src/common.props @@ -1,10 +1,9 @@ - Copyright © 2015-2021 Petabridge, LLC + Copyright © 2015-2022 Petabridge, LLC Petabridge - 1.5.3 - Upgraded to [Akka.NET v1.4.19](https://github.com/akkadotnet/akka.net/releases/tag/1.4.19) -Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_NOTES.html#085-may-03-2021) + 1.5.5 + Upgrade [Akka.Bootstrap.Docker to 0.5.3](https://github.com/petabridge/akkadotnet-bootstrap/releases/tag/0.5.3) https://petabridge.com/images/logo.png https://github.com/petabridge/lighthouse @@ -21,8 +20,8 @@ Upgraded to [Petabridge.Cmd v0.8.5](https://cmd.petabridge.com/articles/RELEASE_ netcoreapp3.1 netstandard1.6 net461 - net461 + netcoreapp3.1 1.4.37 0.8.5 - + \ No newline at end of file From 826d6ba8d7d66b7f282403b5831934f7c835c692 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 23:44:29 +0000 Subject: [PATCH 21/22] Bump Microsoft.Extensions.Configuration.Xml from 5.0.0 to 6.0.0 (#229) Bumps [Microsoft.Extensions.Configuration.Xml](https://github.com/dotnet/runtime) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Configuration.Xml dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Lighthouse/Lighthouse.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Lighthouse/Lighthouse.csproj b/src/Lighthouse/Lighthouse.csproj index f9dc0178..5a9cf362 100644 --- a/src/Lighthouse/Lighthouse.csproj +++ b/src/Lighthouse/Lighthouse.csproj @@ -6,7 +6,7 @@ - + From d9c4067b89b318c6aa616e39eb16582a3f907fc6 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Mon, 18 Apr 2022 18:45:06 -0500 Subject: [PATCH 22/22] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index c7d0f88f..c656cf41 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,6 @@ services: AKKA__CLUSTER__SPLIT_BRAIN_RESOLVER__ACTIVE_STRATEGY: "keep-majority" ``` -### Running in .NET Framework -You can still run Lighthouse under .NET Framework 4.6.1 if you wish. Clone this repository and build the project. Lighthouse will run as a [Topshelf Windows Service](http://topshelf-project.com/) and can be installed as such. - ### Examples of Lighthouse in the Wild Looking for some complete examples of how to use Lighthouse? Here's some: