From 6711eca5b2586dcd36c377d8523bf317ec5851c9 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 10 Oct 2019 17:30:59 -0500 Subject: [PATCH 01/55] Update TargetFrameworks and PackageReferences --- Source/ACE.Adapter/ACE.Adapter.csproj | 2 +- Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj | 6 +++--- Source/ACE.DatLoader/ACE.DatLoader.csproj | 4 ++-- Source/ACE.Database.Tests/ACE.Database.Tests.csproj | 8 ++++---- Source/ACE.Database/ACE.Database.csproj | 8 ++++---- Source/ACE.Server.Tests/ACE.Server.Tests.csproj | 8 ++++---- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Source/ACE.Adapter/ACE.Adapter.csproj b/Source/ACE.Adapter/ACE.Adapter.csproj index 8560463e7a..a9e13feb1a 100644 --- a/Source/ACE.Adapter/ACE.Adapter.csproj +++ b/Source/ACE.Adapter/ACE.Adapter.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.1 AnyCPU diff --git a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj index f293416a15..5966a7dd09 100644 --- a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj +++ b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/Source/ACE.DatLoader/ACE.DatLoader.csproj b/Source/ACE.DatLoader/ACE.DatLoader.csproj index c1aafb3029..45d4331ad8 100644 --- a/Source/ACE.DatLoader/ACE.DatLoader.csproj +++ b/Source/ACE.DatLoader/ACE.DatLoader.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj index b00eb9c7a8..7599dc667e 100644 --- a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj +++ b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.2 + netcoreapp3.0 false @@ -10,9 +10,9 @@ - - - + + + diff --git a/Source/ACE.Database/ACE.Database.csproj b/Source/ACE.Database/ACE.Database.csproj index b59cd8384e..4bcbc48c16 100644 --- a/Source/ACE.Database/ACE.Database.csproj +++ b/Source/ACE.Database/ACE.Database.csproj @@ -1,18 +1,18 @@ - netstandard2.0 + netstandard2.1 AnyCPU - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj index 3828a15519..c8f568056a 100644 --- a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj +++ b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.2 + netcoreapp3.0 false @@ -10,9 +10,9 @@ - - - + + + diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 155cc2a043..a1dc515b8e 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.2 + netcoreapp3.0 x64 @@ -23,7 +23,7 @@ - + From fd9827691875f5ff5cc0a52862073bb275221187 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 10 Oct 2019 17:31:36 -0500 Subject: [PATCH 02/55] FromSql -> FromSqlRaw, ExecuteSqlCommand -> ExecuteSqlRaw --- .../ACE.Server/Command/Handlers/DeveloperContentCommands.cs | 2 +- .../ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs index 0b2c660d04..ad4b7edebc 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs @@ -258,7 +258,7 @@ public static void ImportSQL(string sqlFile) var sqlCommands = File.ReadAllText(sqlFile); using (var ctx = new WorldDbContext()) - ctx.Database.ExecuteSqlCommand(sqlCommands); + ctx.Database.ExecuteSqlRaw(sqlCommands); } [CommandHandler("createinst", AccessLevel.Developer, CommandHandlerFlag.RequiresWorld, 1, "Spawns a new wcid or classname as a landblock instance", "")] diff --git a/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs index 4c023143cf..a43d3ac5b2 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs @@ -60,7 +60,7 @@ public static void HandleFixShortcutBars(Session session, params string[] parame using (var ctx = new ShardDbContext()) { var results = ctx.CharacterPropertiesShortcutBar - .FromSql("SELECT * FROM character_properties_shortcut_bar ORDER BY character_Id, shortcut_Bar_Index, id") + .FromSqlRaw("SELECT * FROM character_properties_shortcut_bar ORDER BY character_Id, shortcut_Bar_Index, id") .ToList(); var sqlCommands = new List(); @@ -121,7 +121,7 @@ public static void HandleFixShortcutBars(Session session, params string[] parame Console.WriteLine("Executing changes..."); foreach (var cmd in sqlCommands) - ctx.Database.ExecuteSqlCommand(cmd); + ctx.Database.ExecuteSqlRaw(cmd); } else Console.WriteLine("dry run completed. Use fix-shortcut-bars execute to actually run command"); From 1dfca525ab4da12a7a717138c7c448a2996e246a Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 10 Oct 2019 17:52:44 -0500 Subject: [PATCH 03/55] Client side GroupBy is not supported in EF 3.0 --- Source/ACE.Database/WorldDatabase.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/ACE.Database/WorldDatabase.cs b/Source/ACE.Database/WorldDatabase.cs index 33f49d5427..d3d25e8e68 100644 --- a/Source/ACE.Database/WorldDatabase.cs +++ b/Source/ACE.Database/WorldDatabase.cs @@ -541,8 +541,8 @@ public void CacheAllHousePortals() { var results = context.HousePortal .AsNoTracking() - .GroupBy(r => r.HouseId) - .ToList(); + .AsEnumerable() + .GroupBy(r => r.HouseId); foreach (var result in results) cachedHousePortals[result.Key] = result.ToList(); @@ -945,8 +945,8 @@ public void CacheAllWieldedTreasuresInParallel() { var results = context.TreasureWielded .AsNoTracking() - .GroupBy(r => r.TreasureType) - .ToList(); + .AsEnumerable() + .GroupBy(r => r.TreasureType); foreach (var result in results) cachedWieldedTreasure[result.Key] = result.ToList(); @@ -984,8 +984,8 @@ public void CacheAllTreasuresMaterialColorInParallel() { var results = context.TreasureMaterialColor .AsNoTracking() - .GroupBy(r => r.MaterialId) - .ToList(); + .AsEnumerable() + .GroupBy(r => r.MaterialId); foreach (var result in results) cachedTreasureMaterialColor[(int)result.Key] = result.ToList(); @@ -1018,8 +1018,8 @@ public void CacheAllTreasuresMaterialBaseInParallel() { var results = context.TreasureMaterialBase .AsNoTracking() - .GroupBy(r => r.MaterialCode) - .ToList(); + .AsEnumerable() + .GroupBy(r => r.MaterialCode); foreach (var result in results) cachedTreasureMaterialBase[(int)result.Key] = result.ToList(); @@ -1064,8 +1064,8 @@ public void CacheAllTreasuresMaterialGroupsInParallel() { var results = context.TreasureMaterialGroups .AsNoTracking() - .GroupBy(r => r.MaterialGroup) - .ToList(); + .AsEnumerable() + .GroupBy(r => r.MaterialGroup); foreach (var result in results) cachedTreasureMaterialGroups[(int)result.Key] = result.ToList(); From 7f56d9a74777b9cacdfd6d733b9ed20d4d077458 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 10 Oct 2019 17:57:14 -0500 Subject: [PATCH 04/55] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index cb781b44be..8a82c71d8e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ version: 0.0.{build} pull_requests: do_not_increment_build_number: true -image: Visual Studio 2017 +image: Visual Studio 2019 platform: x64 services: mysql before_build: From 230dcf6a5d1c8396ab099ac2c8719f5a2e2c7b3d Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Mon, 21 Oct 2019 09:41:42 -0500 Subject: [PATCH 05/55] readme updates --- README.md | 11 +++++------ README_linux.md | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 10c727885f..3437a37188 100644 --- a/README.md +++ b/README.md @@ -45,17 +45,16 @@ The following three sections (Database, Code, and Starting the Server) contain a ### Code -1. Install Visual Studio 2017 - * [Visual Studio minimum required version - VS Community 2017 15.7.0](https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15) - * [.NET Core 2.2 x64 SDK (Visual Studio 2017) Required](https://www.microsoft.com/net/download/visual-studio-sdks) +1. Install Visual Studio 2019 + * [Visual Studio Community 2019](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16) * If using Visual Studio Community Edition, make sure the following two workloads are installed: .NET Core cross-platform development and .NET Desktop Development 2. Copy `ACE.Server\Config.js.example` to `ACE.Server\Config.js` and modify settings, such as passwords, database connections, file paths, and other server settings. 3. Open ACE.sln with Visual Studio and build the solution. Your modified `Config.js` file will be copied to the output folder during the build process. -4. Download and install [Microsoft .NET Core Runtime - 2.2](https://www.microsoft.com/net/download) if you don't already have it. +4. Download and install [Microsoft .NET Core Runtime - 3.0](https://www.microsoft.com/net/download) if you don't already have it. ### Starting the Server -1. Start the server by running the batch file located in the netcoreapp2.2 output directory: `start_server.bat` - * ex. ACE\Source\ACE.Server\bin\x64\Debug\netcoreapp2.2\start_server.bat +1. Start the server by running the batch file located in the netcoreapp3.0 output directory: `start_server.bat` + * ex. ACE\Source\ACE.Server\bin\x64\Debug\netcoreapp3.0\start_server.bat 2. Create your first account as an admin at the ACE prompt - `accountcreate testaccount testpassword 5` 3. Launch ACClient directly with this command: `acclient.exe -a testaccount -v testpassword -h 127.0.0.1:9000` diff --git a/README_linux.md b/README_linux.md index 22d373b63a..cae0daece8 100644 --- a/README_linux.md +++ b/README_linux.md @@ -39,7 +39,7 @@ The following three sections (Database, Code, and Starting the Server) contain a ### Code 1. Install .NET Core SDK - * https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-2.2.104 + * https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-current 2. Clone the project with git: * git clone https://github.com/ACEmulator/ACE.git 3. Copy `ACE.Server\Config.js.example` to `ACE.Server\Config.js` and modify settings, such as DAT folder, passwords and other server settings. @@ -47,7 +47,7 @@ The following three sections (Database, Code, and Starting the Server) contain a ### Starting the Server -1. In ACE/Source/ACE.Server/bin/x64/Debug/netcoreapp2.1, run the server with `dotnet ACE.Server.dll` +1. In ACE/Source/ACE.Server/bin/x64/Debug/netcoreapp3.0, run the server with `dotnet ACE.Server.dll` 2. Create your first account as an admin at the ACE prompt: `accountcreate testaccount testpassword 5` 3. Launch acclient directly with this command: `acclient.exe -a testaccount -v testpassword -h your-server-address:9000` From 493f5871ed02200ee7435474cefb6a7d0c081268 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 22 Oct 2019 04:08:05 -0500 Subject: [PATCH 06/55] Add NoTracking --- Source/ACE.Database/WorldDatabase.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/ACE.Database/WorldDatabase.cs b/Source/ACE.Database/WorldDatabase.cs index d3d25e8e68..41d1405881 100644 --- a/Source/ACE.Database/WorldDatabase.cs +++ b/Source/ACE.Database/WorldDatabase.cs @@ -131,7 +131,11 @@ public Weenie GetWeenie(WorldDbContext context, uint weenieClassId) public Weenie GetWeenie(uint weenieClassId) { using (var context = new WorldDbContext()) + { + context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; + return GetWeenie(context, weenieClassId); + } } /// From e562939bd852d4e289158eab8f33a9f6c1e790a5 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 22 Oct 2019 04:50:35 -0500 Subject: [PATCH 07/55] scaffolding notes update --- Source/ACE.Database/Scaffolding Notes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Database/Scaffolding Notes.txt b/Source/ACE.Database/Scaffolding Notes.txt index 28d2bb3bc1..278dfd1690 100644 --- a/Source/ACE.Database/Scaffolding Notes.txt +++ b/Source/ACE.Database/Scaffolding Notes.txt @@ -23,7 +23,7 @@ Your startup project 'ACE.Server' doesn't reference Microsoft.EntityFrameworkCor Run this command from Package Manager Console on ACE.Server project: -Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.2.0 +Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.0.0 If any changes were detected, C# classes will have been added or modified. Leave the auto generated classes alone. Do not try to optimize them, or clean them up cosmetically. They are partial classes, so you can create a partial class if you want to add methods, or, you can create extension methods as well in a separate file. From 01c41efbf162281173d06cdd2ee5b82cea9585e2 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 22 Oct 2019 05:19:11 -0500 Subject: [PATCH 08/55] Revert back to EF Core 2.2 --- Source/ACE.Database/ACE.Database.csproj | 6 +++--- Source/ACE.Database/Scaffolding Notes.txt | 2 +- .../ACE.Server/Command/Handlers/DeveloperContentCommands.cs | 2 +- .../Command/Handlers/DeveloperDatabaseCommands.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/ACE.Database/ACE.Database.csproj b/Source/ACE.Database/ACE.Database.csproj index 4bcbc48c16..273cea98be 100644 --- a/Source/ACE.Database/ACE.Database.csproj +++ b/Source/ACE.Database/ACE.Database.csproj @@ -7,12 +7,12 @@ - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/Source/ACE.Database/Scaffolding Notes.txt b/Source/ACE.Database/Scaffolding Notes.txt index 278dfd1690..28d2bb3bc1 100644 --- a/Source/ACE.Database/Scaffolding Notes.txt +++ b/Source/ACE.Database/Scaffolding Notes.txt @@ -23,7 +23,7 @@ Your startup project 'ACE.Server' doesn't reference Microsoft.EntityFrameworkCor Run this command from Package Manager Console on ACE.Server project: -Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.0.0 +Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.2.0 If any changes were detected, C# classes will have been added or modified. Leave the auto generated classes alone. Do not try to optimize them, or clean them up cosmetically. They are partial classes, so you can create a partial class if you want to add methods, or, you can create extension methods as well in a separate file. diff --git a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs index ad4b7edebc..0b2c660d04 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperContentCommands.cs @@ -258,7 +258,7 @@ public static void ImportSQL(string sqlFile) var sqlCommands = File.ReadAllText(sqlFile); using (var ctx = new WorldDbContext()) - ctx.Database.ExecuteSqlRaw(sqlCommands); + ctx.Database.ExecuteSqlCommand(sqlCommands); } [CommandHandler("createinst", AccessLevel.Developer, CommandHandlerFlag.RequiresWorld, 1, "Spawns a new wcid or classname as a landblock instance", "")] diff --git a/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs index a43d3ac5b2..4c023143cf 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperDatabaseCommands.cs @@ -60,7 +60,7 @@ public static void HandleFixShortcutBars(Session session, params string[] parame using (var ctx = new ShardDbContext()) { var results = ctx.CharacterPropertiesShortcutBar - .FromSqlRaw("SELECT * FROM character_properties_shortcut_bar ORDER BY character_Id, shortcut_Bar_Index, id") + .FromSql("SELECT * FROM character_properties_shortcut_bar ORDER BY character_Id, shortcut_Bar_Index, id") .ToList(); var sqlCommands = new List(); @@ -121,7 +121,7 @@ public static void HandleFixShortcutBars(Session session, params string[] parame Console.WriteLine("Executing changes..."); foreach (var cmd in sqlCommands) - ctx.Database.ExecuteSqlRaw(cmd); + ctx.Database.ExecuteSqlCommand(cmd); } else Console.WriteLine("dry run completed. Use fix-shortcut-bars execute to actually run command"); From fed06491f8ad4a56f6cfcb61769325c8d26c8a32 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 22 Oct 2019 05:28:03 -0500 Subject: [PATCH 09/55] EF Core 2.2.0 -> 2.2.6 --- Source/ACE.Database/ACE.Database.csproj | 6 +++--- Source/ACE.Database/Scaffolding Notes.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Database/ACE.Database.csproj b/Source/ACE.Database/ACE.Database.csproj index 273cea98be..3821f369e3 100644 --- a/Source/ACE.Database/ACE.Database.csproj +++ b/Source/ACE.Database/ACE.Database.csproj @@ -7,12 +7,12 @@ - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/Source/ACE.Database/Scaffolding Notes.txt b/Source/ACE.Database/Scaffolding Notes.txt index 28d2bb3bc1..10e5bc98da 100644 --- a/Source/ACE.Database/Scaffolding Notes.txt +++ b/Source/ACE.Database/Scaffolding Notes.txt @@ -23,7 +23,7 @@ Your startup project 'ACE.Server' doesn't reference Microsoft.EntityFrameworkCor Run this command from Package Manager Console on ACE.Server project: -Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.2.0 +Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.2.6 If any changes were detected, C# classes will have been added or modified. Leave the auto generated classes alone. Do not try to optimize them, or clean them up cosmetically. They are partial classes, so you can create a partial class if you want to add methods, or, you can create extension methods as well in a separate file. From 8dff9c90e8d94df76f79ccaea6daac163ead9c01 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Mon, 11 Nov 2019 08:49:34 -0600 Subject: [PATCH 10/55] prometheus standalone --- Source/ACE.Server/ACE.Server.csproj | 3 +++ Source/ACE.Server/Program.cs | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 155cc2a043..e103b4ee3e 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -24,6 +24,9 @@ + + + diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index 9ee698b52b..8fd54df6f4 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -1,7 +1,8 @@ using System; using System.IO; using System.Runtime.InteropServices; - +using System.Threading; +using System.Threading.Tasks; using log4net; using log4net.Config; @@ -11,6 +12,8 @@ using ACE.Server.Command; using ACE.Server.Managers; using ACE.Server.Network.Managers; +using Prometheus; +using Prometheus.DotNetRuntime; namespace ACE.Server { @@ -33,6 +36,9 @@ class Program private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static KestrelMetricServer metricServer; + private static IDisposable collector; + public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; @@ -61,6 +67,11 @@ public static void Main(string[] args) log.Error(ex.ToString()); } + metricServer = new KestrelMetricServer(port: 9090); + metricServer.Start(); + + collector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); + log.Info("Starting ACEmulator..."); Console.Title = @"ACEmulator"; @@ -178,6 +189,9 @@ private static void OnProcessExit(object sender, EventArgs e) { log.Error(ex.ToString()); } + + collector.Dispose(); + metricServer.Stop(); } } } From eee4d52611f6400012544761dd10dce0c1df7aca Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Fri, 22 Nov 2019 08:42:38 -0600 Subject: [PATCH 11/55] Update packages (Except EF Core) --- Source/ACE.Adapter/ACE.Adapter.csproj | 2 +- Source/ACE.Common/ACE.Common.csproj | 4 ++-- Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj | 2 +- Source/ACE.DatLoader/ACE.DatLoader.csproj | 2 +- Source/ACE.Database.Tests/ACE.Database.Tests.csproj | 2 +- Source/ACE.Server.Tests/ACE.Server.Tests.csproj | 4 ++-- Source/ACE.Server/ACE.Server.csproj | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/ACE.Adapter/ACE.Adapter.csproj b/Source/ACE.Adapter/ACE.Adapter.csproj index a9e13feb1a..77780f49c5 100644 --- a/Source/ACE.Adapter/ACE.Adapter.csproj +++ b/Source/ACE.Adapter/ACE.Adapter.csproj @@ -6,7 +6,7 @@ - + diff --git a/Source/ACE.Common/ACE.Common.csproj b/Source/ACE.Common/ACE.Common.csproj index 216ecdbde9..67aa8e9e74 100644 --- a/Source/ACE.Common/ACE.Common.csproj +++ b/Source/ACE.Common/ACE.Common.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj index 5966a7dd09..05217c2cf0 100644 --- a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj +++ b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/Source/ACE.DatLoader/ACE.DatLoader.csproj b/Source/ACE.DatLoader/ACE.DatLoader.csproj index 45d4331ad8..4cebe644b8 100644 --- a/Source/ACE.DatLoader/ACE.DatLoader.csproj +++ b/Source/ACE.DatLoader/ACE.DatLoader.csproj @@ -7,7 +7,7 @@ - + diff --git a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj index 7599dc667e..455779072e 100644 --- a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj +++ b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj index c8f568056a..9136c6d1ee 100644 --- a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj +++ b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj @@ -10,10 +10,10 @@ - + - + diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index a1dc515b8e..d8002fa55b 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -22,7 +22,7 @@ - + From 5e506305da721bd633a82893645955d0773e1a0d Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 3 Dec 2019 21:06:03 -0600 Subject: [PATCH 12/55] .net core 3.0 -> 3.1 (LTS) --- Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj | 2 +- Source/ACE.Database.Tests/ACE.Database.Tests.csproj | 2 +- Source/ACE.Server.Tests/ACE.Server.Tests.csproj | 2 +- Source/ACE.Server/ACE.Server.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj index 05217c2cf0..9641e15580 100644 --- a/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj +++ b/Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.2 + netcoreapp3.1 false diff --git a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj index 455779072e..2946aea8d8 100644 --- a/Source/ACE.Database.Tests/ACE.Database.Tests.csproj +++ b/Source/ACE.Database.Tests/ACE.Database.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 false diff --git a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj index 9136c6d1ee..36247d36ed 100644 --- a/Source/ACE.Server.Tests/ACE.Server.Tests.csproj +++ b/Source/ACE.Server.Tests/ACE.Server.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 false diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index d8002fa55b..3fe053d8fd 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + netcoreapp3.1 x64 From ba1097b5bbaf42523685d4c54666e65b41eb490a Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Tue, 3 Dec 2019 21:07:08 -0600 Subject: [PATCH 13/55] Update NuGet packages --- Source/ACE.DatLoader/ACE.DatLoader.csproj | 4 ++-- Source/ACE.Server/ACE.Server.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/ACE.DatLoader/ACE.DatLoader.csproj b/Source/ACE.DatLoader/ACE.DatLoader.csproj index 4cebe644b8..19878b19cf 100644 --- a/Source/ACE.DatLoader/ACE.DatLoader.csproj +++ b/Source/ACE.DatLoader/ACE.DatLoader.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 3fe053d8fd..d14565d207 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -23,7 +23,7 @@ - + From 27d8643eaaee946e4f75ac52bb5c4ae4876b9326 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sun, 8 Dec 2019 10:07:09 -0600 Subject: [PATCH 14/55] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d951851adf..3a2832be35 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,11 @@ The following three sections (Database, Code, and Starting the Server) contain a * If using Visual Studio Community Edition, make sure the following two workloads are installed: .NET Core cross-platform development and .NET Desktop Development 2. Copy `ACE.Server\Config.js.example` to `ACE.Server\Config.js` and modify settings, such as passwords, database connections, file paths, and other server settings. 3. Open ACE.sln with Visual Studio and build the solution. Your modified `Config.js` file will be copied to the output folder during the build process. -4. Download and install [Microsoft .NET Core Runtime - 3.0](https://www.microsoft.com/net/download) if you don't already have it. +4. Download and install [.NET Core Runtime 3.1.0, Windows x64](https://dotnet.microsoft.com/download/dotnet-core/3.1) if you don't already have it. ### Starting the Server -1. Start the server by running the batch file located in the netcoreapp3.0 output directory: `start_server.bat` - * ex. ACE\Source\ACE.Server\bin\x64\Debug\netcoreapp3.0\start_server.bat +1. Start the server by running the batch file located in the netcoreapp3.1 output directory: `start_server.bat` + * ex. ACE\Source\ACE.Server\bin\x64\Debug\netcoreapp3.1\start_server.bat 2. Create your first account as an admin at the ACE prompt - `accountcreate testaccount testpassword 5` 3. Launch ACClient directly with this command: `acclient.exe -a testaccount -v testpassword -h 127.0.0.1:9000` From e420b18a5e783aaaac4742caa3a4d078acb2a054 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Mon, 9 Dec 2019 08:10:56 -0600 Subject: [PATCH 15/55] Update appveyor.yml to use VS Preview --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 8a82c71d8e..aa051a8d25 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,9 @@ version: 0.0.{build} pull_requests: do_not_increment_build_number: true -image: Visual Studio 2019 +# The Preview image sould not be used in the future +# It's only used now because Appveyor hasn't updated their 2019 image to one that supports .net core 3.1 yet +image: Visual Studio 2019 Preview platform: x64 services: mysql before_build: From 644c353b7d4b9a4246081716a554e326504c31fe Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Mon, 16 Dec 2019 08:19:53 -0600 Subject: [PATCH 16/55] merge in 3.1 branch --- Source/ACE.Server/ACE.Server.csproj | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index da57b41421..dd6034773d 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -22,13 +22,10 @@ - - - - - + + From c94323a937aca391c7ba97ce7181ae0d4c458dc7 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Fri, 3 Apr 2020 09:59:09 -0500 Subject: [PATCH 17/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 488dea91db..f6b21d6e24 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -41,8 +41,8 @@ - - + + From 5ef31a2be311e453d8dc03350f4ee9199317e94b Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Fri, 3 Apr 2020 14:17:23 -0500 Subject: [PATCH 18/55] Revert "Update ACE.Server.csproj" This reverts commit c94323a937aca391c7ba97ce7181ae0d4c458dc7. --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index f6b21d6e24..488dea91db 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -41,8 +41,8 @@ - - + + From 4b1ae6df9a096d2c4c8e9775058d72496dc61446 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Wed, 22 Sep 2021 19:29:23 -0500 Subject: [PATCH 19/55] update metrics collecting --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- Source/ACE.Server/Program.cs | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index e7bc625d2f..8b3f82cfc4 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -228,9 +228,9 @@ + - - + diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index a0c7b16bf9..ab7bc76a35 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -39,7 +39,8 @@ partial class Program private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static KestrelMetricServer metricServer; + //private static KestrelMetricServer metricServer; + private static MetricServer metricServer; private static IDisposable collector; public static readonly bool IsRunningInContainer = Convert.ToBoolean(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")); @@ -127,9 +128,10 @@ public static void Main(string[] args) log.Error(ex.ToString()); } - metricServer = new KestrelMetricServer(port: 9090); + //metricServer = new KestrelMetricServer(port: 9090); + //metricServer.Start(); + metricServer = new MetricServer(hostname: "localhost", port: 1234); metricServer.Start(); - collector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); log.Info("Starting ACEmulator..."); From e5a725e807274b786c9b1502e7fec3cbc8f50ed0 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Wed, 22 Sep 2021 21:22:06 -0500 Subject: [PATCH 20/55] more metrics for ACE --- Source/ACE.Server/Program.cs | 18 +--- Source/ACE.Server/Program_Metrics.cs | 149 +++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 14 deletions(-) create mode 100644 Source/ACE.Server/Program_Metrics.cs diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index ab7bc76a35..91c0c17508 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -15,9 +15,6 @@ using ACE.Server.Managers; using ACE.Server.Network.Managers; -using Prometheus; -using Prometheus.DotNetRuntime; - namespace ACE.Server { partial class Program @@ -39,10 +36,6 @@ partial class Program private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - //private static KestrelMetricServer metricServer; - private static MetricServer metricServer; - private static IDisposable collector; - public static readonly bool IsRunningInContainer = Convert.ToBoolean(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")); public static void Main(string[] args) @@ -128,12 +121,6 @@ public static void Main(string[] args) log.Error(ex.ToString()); } - //metricServer = new KestrelMetricServer(port: 9090); - //metricServer.Start(); - metricServer = new MetricServer(hostname: "localhost", port: 1234); - metricServer.Start(); - collector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); - log.Info("Starting ACEmulator..."); if (IsRunningInContainer) @@ -315,6 +302,9 @@ public static void Main(string[] args) { WorldManager.Open(null); } + + log.Info("Initializing Metrics..."); + InitMetrics(); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -351,7 +341,7 @@ private static void OnProcessExit(object sender, EventArgs e) DatabaseManager.Stop(); } - collector.Dispose(); + dotNetMetricsCollector.Dispose(); metricServer.Stop(); } } diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs new file mode 100644 index 0000000000..145eeee90c --- /dev/null +++ b/Source/ACE.Server/Program_Metrics.cs @@ -0,0 +1,149 @@ +using System; +using System.Diagnostics; + +using ACE.Database; +using ACE.Server.Managers; +using ACE.Server.Network.Managers; +using ACE.Server.WorldObjects; + +using Prometheus; +using Prometheus.DotNetRuntime; + +namespace ACE.Server +{ + partial class Program + { + private static MetricServer metricServer; + + private static IDisposable dotNetMetricsCollector; + + private static readonly Gauge ace_Process_TotalRunTime = Metrics.CreateGauge("ace_Process_TotalRunTime", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_Process_TotalProcessorTime = Metrics.CreateGauge("ace_Process_TotalProcessorTime", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_Process_Threads = Metrics.CreateGauge("ace_Process_Threads", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_Process_PrivateMemorySize64 = Metrics.CreateGauge("ace_Process_PrivateMemorySize64", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_NetworkManager_SessionCount = Metrics.CreateGauge("ace_NetworkManager_SessionCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_NetworkManager_AuthenticatedSessionCount = Metrics.CreateGauge("ace_NetworkManager_AuthenticatedSessionCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_NetworkManager_UniqueSessionEndpointCount = Metrics.CreateGauge("ace_NetworkManager_UniqueSessionEndpointCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_PlayerManager_OnlineCount = Metrics.CreateGauge("ace_PlayerManager_OnlineCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_PlayerManager_TotalCount = Metrics.CreateGauge("ace_PlayerManager_TotalCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_DatabaseManager_AccountCount = Metrics.CreateGauge("ace_DatabaseManager_AccountCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_LandblockManager_ActiveLandblocks = Metrics.CreateGauge("ace_LandblockManager_ActiveLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_DormantLandblocks = Metrics.CreateGauge("ace_LandblockManager_DormantLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_ActiveDungeons = Metrics.CreateGauge("ace_LandblockManager_ActiveDungeons", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_DormantDungeons = Metrics.CreateGauge("ace_LandblockManager_DormantDungeons", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_LandblockGroups = Metrics.CreateGauge("ace_LandblockManager_LandblockGroups", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_Objects_Players = Metrics.CreateGauge("ace_LandblockManager_Objects_Players", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_Objects_Creatures = Metrics.CreateGauge("ace_LandblockManager_Objects_Creatures", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_Objects_Missiles = Metrics.CreateGauge("ace_LandblockManager_Objects_Missiles", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_Objects_Other = Metrics.CreateGauge("ace_LandblockManager_Objects_Other", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_LandblockManager_Objects_Total = Metrics.CreateGauge("ace_LandblockManager_Objects_Total", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire = Metrics.CreateGauge("ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire", null, new GaugeConfiguration { SuppressInitialValue = true }); + + static void InitMetrics() + { + // https://github.com/prometheus-net/prometheus-net + Metrics.DefaultRegistry.AddBeforeCollectCallback(MetricsAddBeforeCollectCallback); + + metricServer = new MetricServer(hostname: "localhost", port: 1234); + metricServer.Start(); + + // https://github.com/djluck/prometheus-net.DotNetRuntime + dotNetMetricsCollector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); + } + + static void MetricsAddBeforeCollectCallback() + { + var proc = Process.GetCurrentProcess(); + + ace_Process_TotalRunTime.Set((DateTime.Now - proc.StartTime).TotalSeconds); + ace_Process_TotalProcessorTime.Set(proc.TotalProcessorTime.TotalSeconds); + ace_Process_Threads.Set(proc.Threads.Count); + ace_Process_PrivateMemorySize64.Set(proc.PrivateMemorySize64); + + ace_NetworkManager_SessionCount.Set(NetworkManager.GetSessionCount()); + ace_NetworkManager_AuthenticatedSessionCount.Set(NetworkManager.GetAuthenticatedSessionCount()); + ace_NetworkManager_UniqueSessionEndpointCount.Set(NetworkManager.GetUniqueSessionEndpointCount()); + + ace_PlayerManager_OnlineCount.Set(PlayerManager.GetOnlineCount()); + ace_PlayerManager_TotalCount.Set(PlayerManager.GetOfflineCount() + PlayerManager.GetOnlineCount()); + + ace_DatabaseManager_AccountCount.Set(DatabaseManager.Authentication.GetAccountCount()); + + var loadedLandblocks = LandblockManager.GetLoadedLandblocks(); + int dormantLandblocks = 0, activeDungeonLandblocks = 0, dormantDungeonLandblocks = 0; + int players = 0, creatures = 0, missiles = 0, other = 0, total = 0; + foreach (var landblock in loadedLandblocks) + { + if (landblock.IsDormant) + dormantLandblocks++; + + if (landblock.IsDungeon) + { + if (landblock.IsDormant) + dormantDungeonLandblocks++; + else + activeDungeonLandblocks++; + } + + foreach (var worldObject in landblock.GetAllWorldObjectsForDiagnostics()) + { + if (worldObject is Player) + players++; + else if (worldObject is Creature) + creatures++; + else if (worldObject.Missile ?? false) + missiles++; + else + other++; + + total++; + } + } + ace_LandblockManager_ActiveLandblocks.Set(loadedLandblocks.Count - dormantLandblocks); + ace_LandblockManager_DormantLandblocks.Set(activeDungeonLandblocks); + ace_LandblockManager_ActiveDungeons.Set(dormantLandblocks); + ace_LandblockManager_DormantDungeons.Set(dormantDungeonLandblocks); + ace_LandblockManager_LandblockGroups.Set(LandblockManager.LandblockGroupsCount); + ace_LandblockManager_Objects_Players.Set(players); + ace_LandblockManager_Objects_Creatures.Set(creatures); + ace_LandblockManager_Objects_Missiles.Set(missiles); + ace_LandblockManager_Objects_Other.Set(other); + ace_LandblockManager_Objects_Total.Set(total); + + if (ServerPerformanceMonitor.IsRunning) + { + ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire.Set(ServerPerformanceMonitor.GetEventHistory1h(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + } + + /* + sb.Append($"Threading - WorldThreadCount: {ConfigManager.Config.Server.Threading.LandblockManagerParallelOptions.MaxDegreeOfParallelism}, Multithread Physics: {ConfigManager.Config.Server.Threading.MultiThreadedLandblockGroupPhysicsTicking}, Multithread Non-Physics: {ConfigManager.Config.Server.Threading.MultiThreadedLandblockGroupTicking}, DatabaseThreadCount: {ConfigManager.Config.Server.Threading.DatabaseParallelOptions.MaxDegreeOfParallelism}{'\n'}"); + + sb.Append($"Physics Cache Counts - BSPCache: {BSPCache.Count:N0}, GfxObjCache: {GfxObjCache.Count:N0}, PolygonCache: {PolygonCache.Count:N0}, VertexCache: {VertexCache.Count:N0}{'\n'}"); + + sb.Append($"Total Server Objects: {ServerObjectManager.ServerObjects.Count:N0}{'\n'}"); + + sb.Append($"World DB Cache Counts - Weenies: {DatabaseManager.World.GetWeenieCacheCount():N0}, LandblockInstances: {DatabaseManager.World.GetLandblockInstancesCacheCount():N0}, PointsOfInterest: {DatabaseManager.World.GetPointsOfInterestCacheCount():N0}, Cookbooks: {DatabaseManager.World.GetCookbookCacheCount():N0}, Spells: {DatabaseManager.World.GetSpellCacheCount():N0}, Encounters: {DatabaseManager.World.GetEncounterCacheCount():N0}, Events: {DatabaseManager.World.GetEventsCacheCount():N0}{'\n'}"); + sb.Append($"Shard DB Counts - Biotas: {DatabaseManager.Shard.BaseDatabase.GetBiotaCount():N0}{'\n'}"); + if (DatabaseManager.Shard.BaseDatabase is ShardDatabaseWithCaching shardDatabaseWithCaching) + { + var biotaIds = shardDatabaseWithCaching.GetBiotaCacheKeys(); + var playerBiotaIds = biotaIds.Count(id => ObjectGuid.IsPlayer(id)); + var nonPlayerBiotaIds = biotaIds.Count - playerBiotaIds; + sb.Append($"Shard DB Cache Counts - Player Biotas: {playerBiotaIds} ~ {shardDatabaseWithCaching.PlayerBiotaRetentionTime.TotalMinutes:N0} m, Non Players {nonPlayerBiotaIds} ~ {shardDatabaseWithCaching.NonPlayerBiotaRetentionTime.TotalMinutes:N0} m{'\n'}"); + } + + sb.Append(GuidManager.GetDynamicGuidDebugInfo() + '\n'); + + sb.Append($"Portal.dat has {DatManager.PortalDat.FileCache.Count:N0} files cached of {DatManager.PortalDat.AllFiles.Count:N0} total{'\n'}"); + sb.Append($"Cell.dat has {DatManager.CellDat.FileCache.Count:N0} files cached of {DatManager.CellDat.AllFiles.Count:N0} total{'\n'}"); + */ + } + } +} From e2330af9afa049229959ce218def05f590c85cab Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 23 Sep 2021 07:50:10 -0500 Subject: [PATCH 21/55] more progress --- Source/ACE.Server/Program.cs | 5 ++- Source/ACE.Server/Program_Metrics.cs | 52 ++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index 91c0c17508..f69651e14c 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -314,6 +314,8 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc private static void OnProcessExit(object sender, EventArgs e) { + ShutdownMetrics(); + if (!IsRunningInContainer) { if (!ServerManager.ShutdownInitiated) @@ -340,9 +342,6 @@ private static void OnProcessExit(object sender, EventArgs e) ServerManager.DoShutdownNow(); DatabaseManager.Stop(); } - - dotNetMetricsCollector.Dispose(); - metricServer.Stop(); } } } diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 145eeee90c..83cc0536df 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -1,9 +1,12 @@ using System; using System.Diagnostics; +using System.Linq; using ACE.Database; +using ACE.Entity; using ACE.Server.Managers; using ACE.Server.Network.Managers; +using ACE.Server.Physics.Managers; using ACE.Server.WorldObjects; using Prometheus; @@ -30,6 +33,8 @@ partial class Program private static readonly Gauge ace_PlayerManager_TotalCount = Metrics.CreateGauge("ace_PlayerManager_TotalCount", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_DatabaseManager_AccountCount = Metrics.CreateGauge("ace_DatabaseManager_AccountCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_DatabaseManager_Shard_CachedPlayerBiotas = Metrics.CreateGauge("ace_DatabaseManager_Shard_CachedPlayerBiotas", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_DatabaseManager_Shard_CachedNonPlayerBiotas = Metrics.CreateGauge("ace_DatabaseManager_Shard_CachedNonPlayerBiotas", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_ActiveLandblocks = Metrics.CreateGauge("ace_LandblockManager_ActiveLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_DormantLandblocks = Metrics.CreateGauge("ace_LandblockManager_DormantLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -42,21 +47,31 @@ partial class Program private static readonly Gauge ace_LandblockManager_Objects_Other = Metrics.CreateGauge("ace_LandblockManager_Objects_Other", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_Objects_Total = Metrics.CreateGauge("ace_LandblockManager_Objects_Total", null, new GaugeConfiguration { SuppressInitialValue = true }); - private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire", null, new GaugeConfiguration { SuppressInitialValue = true }); - private static readonly Gauge ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire = Metrics.CreateGauge("ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_ServerObjectManager_ServerObjects = Metrics.CreateGauge("ace_ServerObjectManager_ServerObjects", null, new GaugeConfiguration { SuppressInitialValue = true }); static void InitMetrics() { // https://github.com/prometheus-net/prometheus-net Metrics.DefaultRegistry.AddBeforeCollectCallback(MetricsAddBeforeCollectCallback); - metricServer = new MetricServer(hostname: "localhost", port: 1234); + metricServer = new MetricServer(hostname: "127.0.0.1", port: 1234); metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime dotNetMetricsCollector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); } + static void ShutdownMetrics() + { + dotNetMetricsCollector.Dispose(); + + metricServer.Stop(); + } + static void MetricsAddBeforeCollectCallback() { var proc = Process.GetCurrentProcess(); @@ -74,6 +89,15 @@ static void MetricsAddBeforeCollectCallback() ace_PlayerManager_TotalCount.Set(PlayerManager.GetOfflineCount() + PlayerManager.GetOnlineCount()); ace_DatabaseManager_AccountCount.Set(DatabaseManager.Authentication.GetAccountCount()); + if (DatabaseManager.Shard.BaseDatabase is ShardDatabaseWithCaching shardDatabaseWithCaching) + { + var biotaIds = shardDatabaseWithCaching.GetBiotaCacheKeys(); + var playerBiotaIds = biotaIds.Count(id => ObjectGuid.IsPlayer(id)); + var nonPlayerBiotaIds = biotaIds.Count - playerBiotaIds; + + ace_DatabaseManager_Shard_CachedPlayerBiotas.Set(playerBiotaIds); + ace_DatabaseManager_Shard_CachedNonPlayerBiotas.Set(nonPlayerBiotaIds); + } var loadedLandblocks = LandblockManager.GetLoadedLandblocks(); int dormantLandblocks = 0, activeDungeonLandblocks = 0, dormantDungeonLandblocks = 0; @@ -106,8 +130,8 @@ static void MetricsAddBeforeCollectCallback() } } ace_LandblockManager_ActiveLandblocks.Set(loadedLandblocks.Count - dormantLandblocks); - ace_LandblockManager_DormantLandblocks.Set(activeDungeonLandblocks); - ace_LandblockManager_ActiveDungeons.Set(dormantLandblocks); + ace_LandblockManager_DormantLandblocks.Set(dormantLandblocks); + ace_LandblockManager_ActiveDungeons.Set(activeDungeonLandblocks); ace_LandblockManager_DormantDungeons.Set(dormantDungeonLandblocks); ace_LandblockManager_LandblockGroups.Set(LandblockManager.LandblockGroupsCount); ace_LandblockManager_Objects_Players.Set(players); @@ -118,27 +142,25 @@ static void MetricsAddBeforeCollectCallback() if (ServerPerformanceMonitor.IsRunning) { - ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); - ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire.Set(ServerPerformanceMonitor.GetEventHistory1h(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).LongestEvent); + ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory1h(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); } /* sb.Append($"Threading - WorldThreadCount: {ConfigManager.Config.Server.Threading.LandblockManagerParallelOptions.MaxDegreeOfParallelism}, Multithread Physics: {ConfigManager.Config.Server.Threading.MultiThreadedLandblockGroupPhysicsTicking}, Multithread Non-Physics: {ConfigManager.Config.Server.Threading.MultiThreadedLandblockGroupTicking}, DatabaseThreadCount: {ConfigManager.Config.Server.Threading.DatabaseParallelOptions.MaxDegreeOfParallelism}{'\n'}"); sb.Append($"Physics Cache Counts - BSPCache: {BSPCache.Count:N0}, GfxObjCache: {GfxObjCache.Count:N0}, PolygonCache: {PolygonCache.Count:N0}, VertexCache: {VertexCache.Count:N0}{'\n'}"); + */ - sb.Append($"Total Server Objects: {ServerObjectManager.ServerObjects.Count:N0}{'\n'}"); + ace_ServerObjectManager_ServerObjects.Set(ServerObjectManager.ServerObjects.Count); + /* sb.Append($"World DB Cache Counts - Weenies: {DatabaseManager.World.GetWeenieCacheCount():N0}, LandblockInstances: {DatabaseManager.World.GetLandblockInstancesCacheCount():N0}, PointsOfInterest: {DatabaseManager.World.GetPointsOfInterestCacheCount():N0}, Cookbooks: {DatabaseManager.World.GetCookbookCacheCount():N0}, Spells: {DatabaseManager.World.GetSpellCacheCount():N0}, Encounters: {DatabaseManager.World.GetEncounterCacheCount():N0}, Events: {DatabaseManager.World.GetEventsCacheCount():N0}{'\n'}"); sb.Append($"Shard DB Counts - Biotas: {DatabaseManager.Shard.BaseDatabase.GetBiotaCount():N0}{'\n'}"); - if (DatabaseManager.Shard.BaseDatabase is ShardDatabaseWithCaching shardDatabaseWithCaching) - { - var biotaIds = shardDatabaseWithCaching.GetBiotaCacheKeys(); - var playerBiotaIds = biotaIds.Count(id => ObjectGuid.IsPlayer(id)); - var nonPlayerBiotaIds = biotaIds.Count - playerBiotaIds; - sb.Append($"Shard DB Cache Counts - Player Biotas: {playerBiotaIds} ~ {shardDatabaseWithCaching.PlayerBiotaRetentionTime.TotalMinutes:N0} m, Non Players {nonPlayerBiotaIds} ~ {shardDatabaseWithCaching.NonPlayerBiotaRetentionTime.TotalMinutes:N0} m{'\n'}"); - } + */ + /* sb.Append(GuidManager.GetDynamicGuidDebugInfo() + '\n'); sb.Append($"Portal.dat has {DatManager.PortalDat.FileCache.Count:N0} files cached of {DatManager.PortalDat.AllFiles.Count:N0} total{'\n'}"); From f9904f8ca5c2f9a8e808b0c69aa9fb3c27425910 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Thu, 23 Sep 2021 08:44:12 -0500 Subject: [PATCH 22/55] add gc stats --- Source/ACE.Server/Program_Metrics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 83cc0536df..09595c03a6 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -62,7 +62,7 @@ static void InitMetrics() metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime - dotNetMetricsCollector = DotNetRuntimeStatsBuilder.Default().StartCollecting(); + dotNetMetricsCollector = DotNetRuntimeStatsBuilder.Default().WithGcStats(CaptureLevel.Informational).StartCollecting(); } static void ShutdownMetrics() From 922a1d30c9bff8d2656c14148fd56f006b2ee362 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sat, 9 Oct 2021 09:03:15 -0500 Subject: [PATCH 23/55] scope collection --- Source/ACE.Server/Program_Metrics.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 09595c03a6..e3aa1bdda4 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -62,7 +62,14 @@ static void InitMetrics() metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime - dotNetMetricsCollector = DotNetRuntimeStatsBuilder.Default().WithGcStats(CaptureLevel.Informational).StartCollecting(); + dotNetMetricsCollector = DotNetRuntimeStatsBuilder + .Customize() + .WithGcStats(CaptureLevel.Informational) + //.WithContentionStats() + //.WithThreadPoolStats() + //.WithExceptionStats() + .WithSocketStats() + .StartCollecting(); } static void ShutdownMetrics() From d65e06f60845ace9730241916990a742464c4f1b Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sat, 20 Nov 2021 20:49:43 -0600 Subject: [PATCH 24/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index e3aa1bdda4..3596470392 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -47,10 +47,27 @@ partial class Program private static readonly Gauge ace_LandblockManager_Objects_Other = Metrics.CreateGauge("ace_LandblockManager_Objects_Other", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_Objects_Total = Metrics.CreateGauge("ace_LandblockManager_Objects_Total", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_DelayManager_RunActions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DelayManager_RunActions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerObjectManager_ServerObjects = Metrics.CreateGauge("ace_ServerObjectManager_ServerObjects", null, new GaugeConfiguration { SuppressInitialValue = true }); static void InitMetrics() @@ -74,6 +91,7 @@ static void InitMetrics() static void ShutdownMetrics() { + // todo this throws exception dotNetMetricsCollector.Dispose(); metricServer.Stop(); @@ -149,9 +167,26 @@ static void MetricsAddBeforeCollectCallback() if (ServerPerformanceMonitor.IsRunning) { + ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.PlayerManager_Tick).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.NetworkManager_InboundClientMessageQueueRun).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.actionQueue_RunActions).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_DelayManager_RunActions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DelayManager_RunActions).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.NetworkManager_DoSessionWork).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).LongestEvent); ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory1h(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + + ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickPhysics).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickMultiThreadedWork).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickSingleThreadedWork).AverageEventDuration); + + ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DoSessionWork_TickOutbound).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DoSessionWork_RemoveSessions).AverageEventDuration); + + ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_0).AverageEventDuration); + ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_1).AverageEventDuration); } /* From 1ba7aad0147b29f2b230f75e724e769bdaf237a8 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sun, 28 Nov 2021 11:36:17 -0600 Subject: [PATCH 25/55] update nuget packages --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index d094f8ae4d..64a6292a41 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -226,9 +226,9 @@ - + - + From 7848ea76d435abbfd6e860bec411b3cf900bca68 Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sun, 28 Nov 2021 11:43:13 -0600 Subject: [PATCH 26/55] stub code --- Source/ACE.Server/Program_Metrics.cs | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 3596470392..7fa2991888 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -47,6 +47,7 @@ partial class Program private static readonly Gauge ace_LandblockManager_Objects_Other = Metrics.CreateGauge("ace_LandblockManager_Objects_Other", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_Objects_Total = Metrics.CreateGauge("ace_LandblockManager_Objects_Total", null, new GaugeConfiguration { SuppressInitialValue = true }); + // Calls from WorldManager.UpdateWorld() private static readonly Gauge ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -54,17 +55,42 @@ partial class Program private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + // WorldManager.UpdateGameWorld() time not including throttled returns private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + // Calls from WorldManager.UpdateGameWorld() private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); - + /* + // Calls from Landblock.TickPhysics() - Cumulative over a single UpdateGameWorld Tick + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Player_Tick_UpdateObjectPhysics_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Player_Tick_UpdateObjectPhysics_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_WorldObject_Tick_UpdateObjectPhysics_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_WorldObject_Tick_UpdateObjectPhysics_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + // Calls from Landblock.TickLandblockGroupThreadSafeWork() - Cumulative over a single UpdateGameWorld Tick + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_RunActions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_RunActions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_Monster_Tick_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_Monster_Tick_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_GeneratorUpdate_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_GeneratorUpdate_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_GeneratorRegeneration_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_GeneratorRegeneration_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_Heartbeat_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_Heartbeat_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_Database_Save_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_Database_Save_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + // Calls from Landblock.TickLandblockGroupThreadSafeWork() - Misc - Cumulative over a single UpdateGameWorld Tick + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Monster_Awareness_FindNextTarget_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Monster_Awareness_FindNextTarget_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Monster_Navigation_UpdatePosition_PUO_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Monster_Navigation_UpdatePosition_PUO_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_LootGenerationFactory_CreateRandomLootObjects_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_LootGenerationFactory_CreateRandomLootObjects_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + + // Calls from Landblock.TickSingleThreadedWork() - Cumulative over a single UpdateGameWorld Tick + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_Player_Tick_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_Player_Tick_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_ServerPerformanceMonitor_5m_Landblock_Tick_WorldObject_Heartbeat_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_Landblock_Tick_WorldObject_Heartbeat_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + */ + // Calls from NetworkManager.DoSessionWork() private static readonly Gauge ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + // Calls from NetworkManager.ProcessPacket() private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -75,7 +101,7 @@ static void InitMetrics() // https://github.com/prometheus-net/prometheus-net Metrics.DefaultRegistry.AddBeforeCollectCallback(MetricsAddBeforeCollectCallback); - metricServer = new MetricServer(hostname: "127.0.0.1", port: 1234); + metricServer = new MetricServer(hostname: "127.0.0.1", port: 1234); // todo make this configurable metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime @@ -167,6 +193,7 @@ static void MetricsAddBeforeCollectCallback() if (ServerPerformanceMonitor.IsRunning) { + // Calls from WorldManager.UpdateWorld() ace_ServerPerformanceMonitor_5m_PlayerManager_Tick_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.PlayerManager_Tick).AverageEventDuration); ace_ServerPerformanceMonitor_5m_NetworkManager_InboundClientMessageQueueRun_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.NetworkManager_InboundClientMessageQueueRun).AverageEventDuration); ace_ServerPerformanceMonitor_5m_actionQueue_RunActions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.actionQueue_RunActions).AverageEventDuration); @@ -174,17 +201,21 @@ static void MetricsAddBeforeCollectCallback() ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld).AverageEventDuration); ace_ServerPerformanceMonitor_5m_NetworkManager_DoSessionWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.NetworkManager_DoSessionWork).AverageEventDuration); + // WorldManager.UpdateGameWorld() time not including throttled returns ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); ace_ServerPerformanceMonitor_5m_UpdateGameWorld_Entire_Longest.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).LongestEvent); ace_ServerPerformanceMonitor_1h_UpdateGameWorld_Entire_Average.Set(ServerPerformanceMonitor.GetEventHistory1h(ServerPerformanceMonitor.MonitorType.UpdateGameWorld_Entire).AverageEventDuration); + // Calls from WorldManager.UpdateGameWorld() ace_ServerPerformanceMonitor_5m_LandblockManager_TickPhysics_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickPhysics).AverageEventDuration); ace_ServerPerformanceMonitor_5m_LandblockManager_TickMultiThreadedWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickMultiThreadedWork).AverageEventDuration); ace_ServerPerformanceMonitor_5m_LandblockManager_TickSingleThreadedWork_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.LandblockManager_TickSingleThreadedWork).AverageEventDuration); + // Calls from NetworkManager.DoSessionWork() ace_ServerPerformanceMonitor_5m_DoSessionWork_TickOutbound_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DoSessionWork_TickOutbound).AverageEventDuration); ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DoSessionWork_RemoveSessions).AverageEventDuration); + // Calls from NetworkManager.ProcessPacket() ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_0).AverageEventDuration); ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_1).AverageEventDuration); } From b7acde219efdd1447a64da9dc6fd795d8aadb29d Mon Sep 17 00:00:00 2001 From: Mag-nus Date: Sun, 26 Dec 2021 12:53:36 -0600 Subject: [PATCH 27/55] compile fix --- Source/ACE.Server/Program_Metrics.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 7fa2991888..17abc1e747 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -91,8 +91,8 @@ partial class Program private static readonly Gauge ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); // Calls from NetworkManager.ProcessPacket() - private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); - private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + //private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); + //private static readonly Gauge ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average = Metrics.CreateGauge("ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_ServerObjectManager_ServerObjects = Metrics.CreateGauge("ace_ServerObjectManager_ServerObjects", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -216,8 +216,8 @@ static void MetricsAddBeforeCollectCallback() ace_ServerPerformanceMonitor_5m_DoSessionWork_RemoveSessions_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.DoSessionWork_RemoveSessions).AverageEventDuration); // Calls from NetworkManager.ProcessPacket() - ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_0).AverageEventDuration); - ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_1).AverageEventDuration); + //ace_ServerPerformanceMonitor_5m_ProcessPacket_0_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_0).AverageEventDuration); + //ace_ServerPerformanceMonitor_5m_ProcessPacket_1_Average.Set(ServerPerformanceMonitor.GetEventHistory5m(ServerPerformanceMonitor.MonitorType.ProcessPacket_1).AverageEventDuration); } /* From 9d7e03652973988254fe2ffff9d887261ad8ca2a Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Tue, 29 Mar 2022 14:18:13 -0400 Subject: [PATCH 28/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index c0e5781491..114ce77913 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -226,14 +226,11 @@ - - - - - + + From 449e382974baddd5b2877118ad689bbfa1fcf7c0 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 31 Mar 2022 00:09:20 -0400 Subject: [PATCH 29/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 17abc1e747..747431b51c 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -101,7 +101,7 @@ static void InitMetrics() // https://github.com/prometheus-net/prometheus-net Metrics.DefaultRegistry.AddBeforeCollectCallback(MetricsAddBeforeCollectCallback); - metricServer = new MetricServer(hostname: "127.0.0.1", port: 1234); // todo make this configurable + metricServer = new MetricServer(hostname: "127.0.0.1", port: 9200); // todo make this configurable metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime From dd4ad9090f7691a77a10a60fda7a8784aca6f9b7 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 1 Apr 2022 12:39:07 -0400 Subject: [PATCH 30/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 747431b51c..e37c830e99 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -118,7 +118,7 @@ static void InitMetrics() static void ShutdownMetrics() { // todo this throws exception - dotNetMetricsCollector.Dispose(); + //dotNetMetricsCollector.Dispose(); metricServer.Stop(); } @@ -140,7 +140,7 @@ static void MetricsAddBeforeCollectCallback() ace_PlayerManager_TotalCount.Set(PlayerManager.GetOfflineCount() + PlayerManager.GetOnlineCount()); ace_DatabaseManager_AccountCount.Set(DatabaseManager.Authentication.GetAccountCount()); - if (DatabaseManager.Shard.BaseDatabase is ShardDatabaseWithCaching shardDatabaseWithCaching) + if (DatabaseManager.Shard?.BaseDatabase is ShardDatabaseWithCaching shardDatabaseWithCaching) { var biotaIds = shardDatabaseWithCaching.GetBiotaCacheKeys(); var playerBiotaIds = biotaIds.Count(id => ObjectGuid.IsPlayer(id)); From 0d99d19f38cca51236008aba00e5f4288842bf7e Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 1 Apr 2022 12:39:11 -0400 Subject: [PATCH 31/55] Update Program.cs --- Source/ACE.Server/Program.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index 3a430bc7d0..776a3090be 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -221,6 +221,9 @@ public static void Main(string[] args) Environment.Exit(0); } + log.Info("Initializing Metrics..."); + InitMetrics(); + log.Info("Initializing ServerManager..."); ServerManager.Initialize(); @@ -312,8 +315,8 @@ public static void Main(string[] args) WorldManager.Open(null); } - log.Info("Initializing Metrics..."); - InitMetrics(); + //log.Info("Initializing Metrics..."); + //InitMetrics(); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) From 618b50bcab49b0205657e1a9f54b784f85940435 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 1 Apr 2022 14:12:15 -0400 Subject: [PATCH 32/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index e37c830e99..372939709c 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -35,6 +35,8 @@ partial class Program private static readonly Gauge ace_DatabaseManager_AccountCount = Metrics.CreateGauge("ace_DatabaseManager_AccountCount", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_DatabaseManager_Shard_CachedPlayerBiotas = Metrics.CreateGauge("ace_DatabaseManager_Shard_CachedPlayerBiotas", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_DatabaseManager_Shard_CachedNonPlayerBiotas = Metrics.CreateGauge("ace_DatabaseManager_Shard_CachedNonPlayerBiotas", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_DatabaseManager_Shard_QueueCount = Metrics.CreateGauge("ace_DatabaseManager_Shard_QueueCount", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_DatabaseManager_Shard_QueueWaitTime = Metrics.CreateGauge("ace_DatabaseManager_Shard_QueueWaitTime", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_ActiveLandblocks = Metrics.CreateGauge("ace_LandblockManager_ActiveLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_LandblockManager_DormantLandblocks = Metrics.CreateGauge("ace_LandblockManager_DormantLandblocks", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -149,6 +151,8 @@ static void MetricsAddBeforeCollectCallback() ace_DatabaseManager_Shard_CachedPlayerBiotas.Set(playerBiotaIds); ace_DatabaseManager_Shard_CachedNonPlayerBiotas.Set(nonPlayerBiotaIds); } + ace_DatabaseManager_Shard_QueueCount.Set(DatabaseManager.Shard?.QueueCount ?? 0); + DatabaseManager.Shard?.GetCurrentQueueWaitTime(result => ace_DatabaseManager_Shard_QueueWaitTime.Set(result.TotalMilliseconds)); var loadedLandblocks = LandblockManager.GetLoadedLandblocks(); int dormantLandblocks = 0, activeDungeonLandblocks = 0, dormantDungeonLandblocks = 0; From 23fd5e95c3f738bf29122dee335477deb575d235 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 2 Apr 2022 00:19:09 -0400 Subject: [PATCH 33/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 372939709c..24a55fc977 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -20,6 +20,8 @@ partial class Program private static IDisposable dotNetMetricsCollector; + private static readonly Gauge ace_Info = Metrics.CreateGauge("ace_Info", null, new GaugeConfiguration { SuppressInitialValue = true, LabelNames = new[] { "server_version", "database_version_base", "database_version_patch"} }); + private static readonly Gauge ace_Process_TotalRunTime = Metrics.CreateGauge("ace_Process_TotalRunTime", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_Process_TotalProcessorTime = Metrics.CreateGauge("ace_Process_TotalProcessorTime", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_Process_Threads = Metrics.CreateGauge("ace_Process_Threads", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -98,6 +100,9 @@ partial class Program private static readonly Gauge ace_ServerObjectManager_ServerObjects = Metrics.CreateGauge("ace_ServerObjectManager_ServerObjects", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static string database_Base_Version = null; + private static string database_Patch_Version = null; + static void InitMetrics() { // https://github.com/prometheus-net/prometheus-net @@ -129,6 +134,15 @@ static void MetricsAddBeforeCollectCallback() { var proc = Process.GetCurrentProcess(); + if (database_Base_Version is null && DatabaseManager.World is not null) + { + var dbVersion = DatabaseManager.World.GetVersion(); + database_Base_Version = dbVersion.BaseVersion; + database_Patch_Version = dbVersion.PatchVersion; + } + + ace_Info.WithLabels(ServerBuildInfo.FullVersion, database_Base_Version ?? "", database_Patch_Version ?? "").Set(1); + ace_Process_TotalRunTime.Set((DateTime.Now - proc.StartTime).TotalSeconds); ace_Process_TotalProcessorTime.Set(proc.TotalProcessorTime.TotalSeconds); ace_Process_Threads.Set(proc.Threads.Count); From 481b8cab0094bce297d05dfc6214c4cf94348ea1 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 7 Apr 2022 12:31:08 -0400 Subject: [PATCH 34/55] Update GuidManager.cs --- Source/ACE.Server/Managers/GuidManager.cs | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Source/ACE.Server/Managers/GuidManager.cs b/Source/ACE.Server/Managers/GuidManager.cs index acc3dfd680..68a359ed17 100644 --- a/Source/ACE.Server/Managers/GuidManager.cs +++ b/Source/ACE.Server/Managers/GuidManager.cs @@ -31,12 +31,14 @@ public static class GuidManager private class PlayerGuidAllocator { + private readonly uint min; private readonly uint max; private uint current; private readonly string name; public PlayerGuidAllocator(uint min, uint max, string name) { + this.min = min; this.max = max; // Read current value out of ShardDatabase @@ -99,6 +101,16 @@ public uint Current() { return current; } + + public uint Min() + { + return min; + } + + public uint Max() + { + return max; + } } /// @@ -106,6 +118,7 @@ public uint Current() /// private class DynamicGuidAllocator { + private readonly uint min; private readonly uint max; private uint current; private readonly string name; @@ -129,6 +142,7 @@ private class DynamicGuidAllocator public DynamicGuidAllocator(uint min, uint max, string name) { + this.min = min; this.max = max; // Read current value out of ShardDatabase @@ -249,6 +263,32 @@ public uint Current() return current; } + public uint Min() + { + return min; + } + + public uint Max() + { + return max; + } + + public int SequenceGapPairsTotal => availableIDs.Count; + + public uint SequenceGapTotalAvailable() + { + lock (this) + { + uint total = 0; + foreach (var (start, end) in availableIDs) + total += end - start + 1; + + return total; + } + } + + public int RecycledGuidsTotal => recycledGuids.Count; + public void Recycle(uint guid) { lock (this) @@ -352,5 +392,14 @@ public static string GetIdListCommandOutput() return message; } + + public static uint PlayerMin => playerAlloc?.Min() ?? 0; + public static uint PlayerCurrent => playerAlloc?.Current() ?? 0; + public static uint PlayerMax => playerAlloc?.Max() ?? 0; + public static uint DynamicMin => dynamicAlloc?.Min() ?? 0; + public static uint DynamicCurrent => dynamicAlloc?.Current() ?? 0; + public static uint DynamicMax => dynamicAlloc?.Max() ?? 0; + public static int SequenceGapPairsTotal => dynamicAlloc?.SequenceGapPairsTotal ?? 0; + public static int RecycledGuidsTotal => dynamicAlloc?.RecycledGuidsTotal ?? 0; } } From 17aceff0063bcb913c4c6fc3e9e05b9be09e3653 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 7 Apr 2022 12:31:11 -0400 Subject: [PATCH 35/55] Update HouseManager.cs --- Source/ACE.Server/Managers/HouseManager.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/ACE.Server/Managers/HouseManager.cs b/Source/ACE.Server/Managers/HouseManager.cs index 682779b8b8..81b8a94237 100644 --- a/Source/ACE.Server/Managers/HouseManager.cs +++ b/Source/ACE.Server/Managers/HouseManager.cs @@ -48,6 +48,11 @@ public static class HouseManager public static void Initialize() { + TotalOwnedHousingByType[HouseType.Apartment] = 0; + TotalOwnedHousingByType[HouseType.Cottage] = 0; + TotalOwnedHousingByType[HouseType.Villa] = 0; + TotalOwnedHousingByType[HouseType.Mansion] = 0; + BuildHouseIdToGuid(); BuildRentQueue(); @@ -198,6 +203,8 @@ private static void AddRentQueue(IPlayer player, House house) var playerHouse = new PlayerHouse(player, house); RentQueue.Add(playerHouse); + + TotalOwnedHousingByType[playerHouse.House.HouseType]++; } /// @@ -500,6 +507,7 @@ public static void HandleEviction(House house, uint playerGuid, bool multihouse if (multihouse) { RemoveRentQueue(house.Guid.Full); + DecrementOwnedHousingByTypeTotal(house.HouseType); player.SaveBiotaToDatabase(); @@ -613,7 +621,7 @@ private static HouseData GetHouseData(House house) } // This function is called from a database callback. - // We must add thread safety to prevent AllegianceManager corruption + // We must add thread safety to prevent HouseManager corruption public static void HandlePlayerDelete(uint playerGuid) { WorldManager.EnqueueAction(new ActionEventDelegate(() => DoHandlePlayerDelete(playerGuid))); @@ -646,6 +654,7 @@ private static void DoHandlePlayerDelete(uint playerGuid) HandleEviction(playerHouse, true); RemoveRentQueue(house.Guid.Full); + DecrementOwnedHousingByTypeTotal(house.HouseType); }); } @@ -913,5 +922,11 @@ public static void PayAllRent() PayRent(house); } } + + public static int TotalOwnedHousing => RentQueue.Count; + + public static Dictionary TotalOwnedHousingByType = new Dictionary(); + + public static void DecrementOwnedHousingByTypeTotal(HouseType houseType) => TotalOwnedHousingByType[houseType]--; } } From 8dc3dc0bd746ceff6b647cec48109625e970ba97 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 7 Apr 2022 12:31:15 -0400 Subject: [PATCH 36/55] Update Player_House.cs --- Source/ACE.Server/WorldObjects/Player_House.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/ACE.Server/WorldObjects/Player_House.cs b/Source/ACE.Server/WorldObjects/Player_House.cs index ac350c2aad..5c718f3b57 100644 --- a/Source/ACE.Server/WorldObjects/Player_House.cs +++ b/Source/ACE.Server/WorldObjects/Player_House.cs @@ -514,6 +514,7 @@ public void HandleActionAbandonHouse() Session.Network.EnqueueSend(new GameMessageSystemChat("You abandon your house!", ChatMessageType.Broadcast)); HouseManager.RemoveRentQueue(house.Guid.Full); + HouseManager.DecrementOwnedHousingByTypeTotal(house.HouseType); house.ClearRestrictions(); From 521369a8ae953984cb8b2985d7952f58983938fd Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 7 Apr 2022 12:31:18 -0400 Subject: [PATCH 37/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 24a55fc977..d29f8fe07e 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -100,6 +100,24 @@ partial class Program private static readonly Gauge ace_ServerObjectManager_ServerObjects = Metrics.CreateGauge("ace_ServerObjectManager_ServerObjects", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_PlayerGuidAllocator_Min = Metrics.CreateGauge("ace_GuidManager_PlayerGuidAllocator_Min", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_PlayerGuidAllocator_Current = Metrics.CreateGauge("ace_GuidManager_PlayerGuidAllocator_Current", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_PlayerGuidAllocator_Max = Metrics.CreateGauge("ace_GuidManager_PlayerGuidAllocator_Max", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_Min = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_Min", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_Current = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_Current", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_Max = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_Max", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_SequenceGapPairsTotal = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_SequenceGapPairsTotal", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_AllegianceManager_AllegiancesLoadedInMemory = Metrics.CreateGauge("ace_AllegianceManager_AllegiancesLoadedInMemory", null, new GaugeConfiguration { SuppressInitialValue = true }); + + private static readonly Gauge ace_HouseManager_TotalOwnedHousing = Metrics.CreateGauge("ace_HouseManager_TotalOwnedHousing", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_HouseManager_TotalOwnedApartments = Metrics.CreateGauge("ace_HouseManager_TotalOwnedApartments", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_HouseManager_TotalOwnedCottages = Metrics.CreateGauge("ace_HouseManager_TotalOwnedCottages", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_HouseManager_TotalOwnedVillas = Metrics.CreateGauge("ace_HouseManager_TotalOwnedVillas", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_HouseManager_TotalOwnedMansions = Metrics.CreateGauge("ace_HouseManager_TotalOwnedMansions", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static string database_Base_Version = null; private static string database_Patch_Version = null; @@ -257,6 +275,24 @@ static void MetricsAddBeforeCollectCallback() sb.Append($"Portal.dat has {DatManager.PortalDat.FileCache.Count:N0} files cached of {DatManager.PortalDat.AllFiles.Count:N0} total{'\n'}"); sb.Append($"Cell.dat has {DatManager.CellDat.FileCache.Count:N0} files cached of {DatManager.CellDat.AllFiles.Count:N0} total{'\n'}"); */ + + ace_GuidManager_PlayerGuidAllocator_Min.Set(GuidManager.PlayerMin); + ace_GuidManager_PlayerGuidAllocator_Current.Set(GuidManager.PlayerCurrent); + ace_GuidManager_PlayerGuidAllocator_Max.Set(GuidManager.PlayerMax); + + ace_GuidManager_DynamicGuidAllocator_Min.Set(GuidManager.DynamicMin); + ace_GuidManager_DynamicGuidAllocator_Current.Set(GuidManager.DynamicCurrent); + ace_GuidManager_DynamicGuidAllocator_Max.Set(GuidManager.DynamicMax); + ace_GuidManager_DynamicGuidAllocator_SequenceGapPairsTotal.Set(GuidManager.SequenceGapPairsTotal); + ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal.Set(GuidManager.RecycledGuidsTotal); + + ace_AllegianceManager_AllegiancesLoadedInMemory.Set(AllegianceManager.Allegiances.Count); + + ace_HouseManager_TotalOwnedHousing.Set(HouseManager.TotalOwnedHousing); + ace_HouseManager_TotalOwnedApartments.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Apartment]); + ace_HouseManager_TotalOwnedCottages.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Cottage]); + ace_HouseManager_TotalOwnedVillas.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Villa]); + ace_HouseManager_TotalOwnedMansions.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Mansion]); } } } From 122fe29a9c11136e42bf3480ca711734f380d6e8 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 7 Apr 2022 12:37:42 -0400 Subject: [PATCH 38/55] Update HouseManager.cs --- Source/ACE.Server/Managers/HouseManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Managers/HouseManager.cs b/Source/ACE.Server/Managers/HouseManager.cs index 81b8a94237..f5f04ad18c 100644 --- a/Source/ACE.Server/Managers/HouseManager.cs +++ b/Source/ACE.Server/Managers/HouseManager.cs @@ -923,7 +923,7 @@ public static void PayAllRent() } } - public static int TotalOwnedHousing => RentQueue.Count; + public static int TotalOwnedHousing => RentQueue?.Count ?? 0; public static Dictionary TotalOwnedHousingByType = new Dictionary(); From 74dc48f3176cf2cb65e290f4dab50d4ce1e20f5d Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 8 Apr 2022 18:42:04 -0400 Subject: [PATCH 39/55] Update HouseManager.cs --- Source/ACE.Server/Managers/HouseManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/ACE.Server/Managers/HouseManager.cs b/Source/ACE.Server/Managers/HouseManager.cs index f5f04ad18c..fd71ba0d5c 100644 --- a/Source/ACE.Server/Managers/HouseManager.cs +++ b/Source/ACE.Server/Managers/HouseManager.cs @@ -343,6 +343,7 @@ public static void Tick() while (currentTime > nextEntry.RentDue) { RentQueue.Remove(nextEntry); + DecrementTotalOwnedHousingByType(nextEntry.House.HouseType); ProcessRent(nextEntry); @@ -507,7 +508,7 @@ public static void HandleEviction(House house, uint playerGuid, bool multihouse if (multihouse) { RemoveRentQueue(house.Guid.Full); - DecrementOwnedHousingByTypeTotal(house.HouseType); + DecrementTotalOwnedHousingByType(house.HouseType); player.SaveBiotaToDatabase(); @@ -654,7 +655,7 @@ private static void DoHandlePlayerDelete(uint playerGuid) HandleEviction(playerHouse, true); RemoveRentQueue(house.Guid.Full); - DecrementOwnedHousingByTypeTotal(house.HouseType); + DecrementTotalOwnedHousingByType(house.HouseType); }); } @@ -927,6 +928,8 @@ public static void PayAllRent() public static Dictionary TotalOwnedHousingByType = new Dictionary(); - public static void DecrementOwnedHousingByTypeTotal(HouseType houseType) => TotalOwnedHousingByType[houseType]--; + public static void IncrementTotalOwnedHousingByType(HouseType houseType) => TotalOwnedHousingByType[houseType]++; + + public static void DecrementTotalOwnedHousingByType(HouseType houseType) => TotalOwnedHousingByType[houseType]--; } } From 6cbf654d32a8a2ddee142fff8efa8d1ee247d4c3 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 8 Apr 2022 18:42:10 -0400 Subject: [PATCH 40/55] Update Player_House.cs --- Source/ACE.Server/WorldObjects/Player_House.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/WorldObjects/Player_House.cs b/Source/ACE.Server/WorldObjects/Player_House.cs index 5c718f3b57..2c2f107a6f 100644 --- a/Source/ACE.Server/WorldObjects/Player_House.cs +++ b/Source/ACE.Server/WorldObjects/Player_House.cs @@ -514,7 +514,7 @@ public void HandleActionAbandonHouse() Session.Network.EnqueueSend(new GameMessageSystemChat("You abandon your house!", ChatMessageType.Broadcast)); HouseManager.RemoveRentQueue(house.Guid.Full); - HouseManager.DecrementOwnedHousingByTypeTotal(house.HouseType); + HouseManager.DecrementTotalOwnedHousingByType(house.HouseType); house.ClearRestrictions(); From 243560bd6ffc5e3531036f50184bd022af159139 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 8 Apr 2022 20:35:49 -0400 Subject: [PATCH 41/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index d29f8fe07e..7cfdae0042 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -111,6 +111,7 @@ partial class Program private static readonly Gauge ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal = Metrics.CreateGauge("ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_AllegianceManager_AllegiancesLoadedInMemory = Metrics.CreateGauge("ace_AllegianceManager_AllegiancesLoadedInMemory", null, new GaugeConfiguration { SuppressInitialValue = true }); + private static readonly Gauge ace_AllegianceManager_PlayersMappedInMemory = Metrics.CreateGauge("ace_AllegianceManager_PlayersMappedInMemory", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_HouseManager_TotalOwnedHousing = Metrics.CreateGauge("ace_HouseManager_TotalOwnedHousing", null, new GaugeConfiguration { SuppressInitialValue = true }); private static readonly Gauge ace_HouseManager_TotalOwnedApartments = Metrics.CreateGauge("ace_HouseManager_TotalOwnedApartments", null, new GaugeConfiguration { SuppressInitialValue = true }); @@ -287,6 +288,7 @@ static void MetricsAddBeforeCollectCallback() ace_GuidManager_DynamicGuidAllocator_RecycledGuidsTotal.Set(GuidManager.RecycledGuidsTotal); ace_AllegianceManager_AllegiancesLoadedInMemory.Set(AllegianceManager.Allegiances.Count); + ace_AllegianceManager_PlayersMappedInMemory.Set(AllegianceManager.Players.Count); ace_HouseManager_TotalOwnedHousing.Set(HouseManager.TotalOwnedHousing); ace_HouseManager_TotalOwnedApartments.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Apartment]); From f7d0d1810cfe43f5d0cc40ff6064be26241e4ed8 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 10 Aug 2023 13:19:01 -0400 Subject: [PATCH 42/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 20f66aba9b..74c0ce7ec1 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -237,16 +237,12 @@ - - - - - - + + From 1243d3c32717a6045b3f4d8c7a96b2babfa30348 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 10 Aug 2023 13:20:28 -0400 Subject: [PATCH 43/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 74c0ce7ec1..974ec87d10 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -237,9 +237,9 @@ - + From 8deb8f1c8cd8f443f76ce2e11e69941a31b4d2a0 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Mon, 5 Feb 2024 01:40:11 -0500 Subject: [PATCH 44/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 24910dca6c..bd5eac9b12 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -238,12 +238,9 @@ - - - + - From a15aad0de26395c38eda31c122c068f8ef55df3f Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Mon, 5 Feb 2024 01:49:32 -0500 Subject: [PATCH 45/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 7cfdae0042..54424157c2 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -291,10 +291,22 @@ static void MetricsAddBeforeCollectCallback() ace_AllegianceManager_PlayersMappedInMemory.Set(AllegianceManager.Players.Count); ace_HouseManager_TotalOwnedHousing.Set(HouseManager.TotalOwnedHousing); - ace_HouseManager_TotalOwnedApartments.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Apartment]); - ace_HouseManager_TotalOwnedCottages.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Cottage]); - ace_HouseManager_TotalOwnedVillas.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Villa]); - ace_HouseManager_TotalOwnedMansions.Set(HouseManager.TotalOwnedHousingByType[ACE.Entity.Enum.HouseType.Mansion]); + if (HouseManager.TotalOwnedHousingByType.TryGetValue(ACE.Entity.Enum.HouseType.Apartment, out var totalOwnedApartments)) + ace_HouseManager_TotalOwnedApartments.Set(totalOwnedApartments); + else + ace_HouseManager_TotalOwnedApartments.Set(0); + if (HouseManager.TotalOwnedHousingByType.TryGetValue(ACE.Entity.Enum.HouseType.Cottage, out var totalOwnedCottages)) + ace_HouseManager_TotalOwnedCottages.Set(totalOwnedCottages); + else + ace_HouseManager_TotalOwnedCottages.Set(0); + if (HouseManager.TotalOwnedHousingByType.TryGetValue(ACE.Entity.Enum.HouseType.Villa, out var totalOwnedVillas)) + ace_HouseManager_TotalOwnedVillas.Set(totalOwnedVillas); + else + ace_HouseManager_TotalOwnedVillas.Set(0); + if (HouseManager.TotalOwnedHousingByType.TryGetValue(ACE.Entity.Enum.HouseType.Mansion, out var totalOwnedMansions)) + ace_HouseManager_TotalOwnedMansions.Set(totalOwnedMansions); + else + ace_HouseManager_TotalOwnedMansions.Set(0); } } } From 133b000e106b19f38be792767207d39a753c67c9 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Wed, 7 Feb 2024 00:27:19 -0500 Subject: [PATCH 46/55] Add Metrics to Config.js --- Source/ACE.Common/MasterConfiguration.cs | 2 ++ Source/ACE.Common/MetricsConfiguration.cs | 19 ++++++++++++++ Source/ACE.Server/Config.js.docker | 31 +++++++++++++++++++++++ Source/ACE.Server/Config.js.example | 23 +++++++++++++++++ Source/ACE.Server/Program.cs | 9 +++++-- Source/ACE.Server/Program_Metrics.cs | 7 +++-- 6 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 Source/ACE.Common/MetricsConfiguration.cs diff --git a/Source/ACE.Common/MasterConfiguration.cs b/Source/ACE.Common/MasterConfiguration.cs index ac5b4a37a6..8159a50f4c 100644 --- a/Source/ACE.Common/MasterConfiguration.cs +++ b/Source/ACE.Common/MasterConfiguration.cs @@ -9,5 +9,7 @@ public class MasterConfiguration public OfflineConfiguration Offline { get; set; } = new OfflineConfiguration(); public DDDConfiguration DDD { get; set; } = new DDDConfiguration(); + + public MetricsConfiguration Metrics { get; set; } = new MetricsConfiguration(); } } diff --git a/Source/ACE.Common/MetricsConfiguration.cs b/Source/ACE.Common/MetricsConfiguration.cs new file mode 100644 index 0000000000..259bbe54cd --- /dev/null +++ b/Source/ACE.Common/MetricsConfiguration.cs @@ -0,0 +1,19 @@ + +namespace ACE.Common +{ + public class MetricsConfiguration + { + /// + /// Allow server to publish Prometheus metrics + /// + public bool EnableMetricsServer { get; set; } = false; + + public string Host { get; set; } = "127.0.0.1"; + + public int Port { get; set; } = 9200; + + public string Url { get; set; } = "metrics/"; + + public bool UseHTTPs { get; set; } = false; + } +} diff --git a/Source/ACE.Server/Config.js.docker b/Source/ACE.Server/Config.js.docker index ed0d55397b..90b0eadad4 100644 --- a/Source/ACE.Server/Config.js.docker +++ b/Source/ACE.Server/Config.js.docker @@ -221,5 +221,36 @@ // When retrieving a file list of .sql files in the AutoApplyWorldCustomizations process // this will cause the file search to retrieve all files recursively from each directory "RecurseWorldCustomizationPaths": true + }, + // This section configures handling of client DAT patching from server's DAT files + "DDD": { + // Allow server to patch client DAT files using server's DAT files via DDDManager + "EnableDATPatching": false, + + // Upon server startup, precache all DAT files that would be sent as compressed data + "PrecacheCompressedDATFiles": false + }, + // This section configures Prometheus metrics server + "Metrics": { + // Allow server to publish Prometheus metrics + "EnableMetricsServer": false, + + // Host, default: 127.0.0.1 + // Probably best to leave this as is, and use reverse proxy which can be secured better. + "Host": "127.0.0.1", + + // Port, default: 9200 + // Probably best to leave this as is, and use reverse proxy which can be secured better. + "Port": 9200, + + // Url, default: metrics/ + // Probably best to leave this as is, and use reverse proxy which can be secured better. + // If above is default, the full url becomes http://127.0.0.1:9200/metrics/ to access + "Url": "metrics/", + + // UseHTTPs, default: false + // Probably best to leave this as is, and use reverse proxy which can be secured better. + // If above is default, the full url becomes https://127.0.0.1:9200/metrics to access + "UseHTTPs": false } } diff --git a/Source/ACE.Server/Config.js.example b/Source/ACE.Server/Config.js.example index a8cdbb1a3f..708be3b3d5 100644 --- a/Source/ACE.Server/Config.js.example +++ b/Source/ACE.Server/Config.js.example @@ -230,5 +230,28 @@ // Upon server startup, precache all DAT files that would be sent as compressed data "PrecacheCompressedDATFiles": false + }, + // This section configures Prometheus metrics server + "Metrics": { + // Allow server to publish Prometheus metrics + "EnableMetricsServer": false, + + // Host, default: 127.0.0.1 + // Probably best to leave this as is, and use reverse proxy which can be secured better. + "Host": "127.0.0.1", + + // Port, default: 9200 + // Probably best to leave this as is, and use reverse proxy which can be secured better. + "Port": 9200, + + // Url, default: metrics/ + // Probably best to leave this as is, and use reverse proxy which can be secured better. + // If above is default, the full url becomes http://127.0.0.1:9200/metrics/ to access + "Url": "metrics/", + + // UseHTTPs, default: false + // Probably best to leave this as is, and use reverse proxy which can be secured better. + // If above is default, the full url becomes https://127.0.0.1:9200/metrics to access + "UseHTTPs": false } } diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index 6bcaa35bf7..b06ee0a983 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -228,8 +228,13 @@ public static void Main(string[] args) Environment.Exit(0); } - log.Info("Initializing Metrics..."); - InitMetrics(); + if (ConfigManager.Config.Metrics.EnableMetricsServer) + { + log.Info("Initializing Metrics Server..."); + InitMetrics(); + } + else + log.Info("Metrics Server Disabled..."); log.Info("Initializing ServerManager..."); ServerManager.Initialize(); diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 54424157c2..9a6d0de3d1 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -1,7 +1,7 @@ using System; using System.Diagnostics; using System.Linq; - +using ACE.Common; using ACE.Database; using ACE.Entity; using ACE.Server.Managers; @@ -127,7 +127,10 @@ static void InitMetrics() // https://github.com/prometheus-net/prometheus-net Metrics.DefaultRegistry.AddBeforeCollectCallback(MetricsAddBeforeCollectCallback); - metricServer = new MetricServer(hostname: "127.0.0.1", port: 9200); // todo make this configurable + metricServer = new MetricServer(hostname: ConfigManager.Config.Metrics.Host, + port: ConfigManager.Config.Metrics.Port, + url: ConfigManager.Config.Metrics.Host, + useHttps: ConfigManager.Config.Metrics.UseHTTPs); metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime From 9934f5e55f06dbb31b65f89a830d46f3ad2c2d9a Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Wed, 7 Feb 2024 00:29:15 -0500 Subject: [PATCH 47/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index bd5eac9b12..a031b73a67 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -239,8 +239,8 @@ - - + + From afee71fa66676cd18a44cbc2eca7c0ebeeea8932 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Wed, 7 Feb 2024 00:41:21 -0500 Subject: [PATCH 48/55] Update Program.cs --- Source/ACE.Server/Program.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/ACE.Server/Program.cs b/Source/ACE.Server/Program.cs index b06ee0a983..b468fdbc0f 100644 --- a/Source/ACE.Server/Program.cs +++ b/Source/ACE.Server/Program.cs @@ -343,9 +343,6 @@ public static void Main(string[] args) { WorldManager.Open(null); } - - //log.Info("Initializing Metrics..."); - //InitMetrics(); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) From 4996e4a01fc8008770725f0c81ce24b25c794e1d Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Mon, 12 Feb 2024 01:15:30 -0500 Subject: [PATCH 49/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 9a6d0de3d1..afdbea1777 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -129,7 +129,7 @@ static void InitMetrics() metricServer = new MetricServer(hostname: ConfigManager.Config.Metrics.Host, port: ConfigManager.Config.Metrics.Port, - url: ConfigManager.Config.Metrics.Host, + url: ConfigManager.Config.Metrics.Url, useHttps: ConfigManager.Config.Metrics.UseHTTPs); metricServer.Start(); From f0d1bf881f3e9262828bb75dd18b9a55263543a1 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Mon, 12 Feb 2024 03:34:24 -0500 Subject: [PATCH 50/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index a031b73a67..0b2fe4a708 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -239,7 +239,7 @@ - + From a26458698900fc84a7fbc262635fe7fc09b21296 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Thu, 25 Apr 2024 12:27:44 -0400 Subject: [PATCH 51/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index c34ebe6e45..d0dc75213e 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -238,12 +238,9 @@ - - - - - + + From 9d18614c8f53c6522223e9c634f814d37848a492 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Fri, 26 Apr 2024 12:02:33 -0400 Subject: [PATCH 52/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index afdbea1777..92e6244795 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -134,14 +134,22 @@ static void InitMetrics() metricServer.Start(); // https://github.com/djluck/prometheus-net.DotNetRuntime + dotNetMetricsCollector = DotNetRuntimeStatsBuilder .Customize() .WithGcStats(CaptureLevel.Informational) - //.WithContentionStats() - //.WithThreadPoolStats() - //.WithExceptionStats() .WithSocketStats() .StartCollecting(); + + //dotNetMetricsCollector = DotNetRuntimeStatsBuilder + // .Customize() + // .WithGcStats(CaptureLevel.Verbose) + // .WithJitStats(CaptureLevel.Verbose) + // .WithContentionStats(CaptureLevel.Informational) + // .WithThreadPoolStats(CaptureLevel.Informational) + // .WithExceptionStats(CaptureLevel.Errors) + // .WithSocketStats() + // .StartCollecting(); } static void ShutdownMetrics() From 99720f1115958c6e7dc39a3b7daf3bc15306b2b0 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Mon, 20 May 2024 23:53:26 -0400 Subject: [PATCH 53/55] Update Program_Metrics.cs --- Source/ACE.Server/Program_Metrics.cs | 65 ++++++++++++++++++---------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/Source/ACE.Server/Program_Metrics.cs b/Source/ACE.Server/Program_Metrics.cs index 92e6244795..fcaa11a5bc 100644 --- a/Source/ACE.Server/Program_Metrics.cs +++ b/Source/ACE.Server/Program_Metrics.cs @@ -201,32 +201,53 @@ static void MetricsAddBeforeCollectCallback() var loadedLandblocks = LandblockManager.GetLoadedLandblocks(); int dormantLandblocks = 0, activeDungeonLandblocks = 0, dormantDungeonLandblocks = 0; int players = 0, creatures = 0, missiles = 0, other = 0, total = 0; - foreach (var landblock in loadedLandblocks) + try { - if (landblock.IsDormant) - dormantLandblocks++; - - if (landblock.IsDungeon) + foreach (var landblock in loadedLandblocks) { - if (landblock.IsDormant) - dormantDungeonLandblocks++; - else - activeDungeonLandblocks++; + try + { + if (landblock.IsDormant) + dormantLandblocks++; + + if (landblock.IsDungeon) + { + if (landblock.IsDormant) + dormantDungeonLandblocks++; + else + activeDungeonLandblocks++; + } + + foreach (var worldObject in landblock.GetAllWorldObjectsForDiagnostics()) + { + try + { + if (worldObject is Player) + players++; + else if (worldObject is Creature) + creatures++; + else if (worldObject.Missile ?? false) + missiles++; + else + other++; + + total++; + } + catch (Exception) + { + + } + } + } + catch (Exception) + { + + } } + } + catch (Exception) + { - foreach (var worldObject in landblock.GetAllWorldObjectsForDiagnostics()) - { - if (worldObject is Player) - players++; - else if (worldObject is Creature) - creatures++; - else if (worldObject.Missile ?? false) - missiles++; - else - other++; - - total++; - } } ace_LandblockManager_ActiveLandblocks.Set(loadedLandblocks.Count - dormantLandblocks); ace_LandblockManager_DormantLandblocks.Set(dormantLandblocks); From 92f51bca64250c0761891d3b0eeb51ca81c4bd4a Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sat, 20 Jul 2024 17:07:24 -0400 Subject: [PATCH 54/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index f8a16a3609..3445db53d9 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -239,8 +239,8 @@ - - + + From a86492774806ceb146f136f6fbfd163a363a7a74 Mon Sep 17 00:00:00 2001 From: Ty Conner Date: Sun, 29 Sep 2024 22:01:54 -0400 Subject: [PATCH 55/55] Update ACE.Server.csproj --- Source/ACE.Server/ACE.Server.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ACE.Server/ACE.Server.csproj b/Source/ACE.Server/ACE.Server.csproj index 3445db53d9..bc5e991439 100644 --- a/Source/ACE.Server/ACE.Server.csproj +++ b/Source/ACE.Server/ACE.Server.csproj @@ -240,7 +240,7 @@ - +