clean up and various little improvements after search for static wasted memory objects (not found) At this point it appears I don't have any leaks and it's all pretty efficient.

This commit is contained in:
2020-06-05 23:36:44 +00:00
parent cbf65f9046
commit bbcbdd86d0
17 changed files with 56 additions and 409 deletions

View File

@@ -20,21 +20,20 @@ namespace AyaNova.Biz
private static Process _process = Process.GetCurrentProcess();
private static TimeSpan _oldCPUTime = TimeSpan.Zero;
private static DateTime _lastMMSnapshot = DateTime.UtcNow;
private static DateTime _lastMMSnapshot = DateTime.UtcNow;
private static DateTime _lastDDSnapshot = DateTime.UtcNow;
// private static DateTime _lastRpsTime = DateTime.UtcNow;
private static double _cpu = 0;
#if(DEBUG)
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
#if (DEBUG)
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
private static TimeSpan ts24Hours = new TimeSpan(24, 0, 0);
#else
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
private static TimeSpan ts24Hours = new TimeSpan(24, 0, 0);
#endif
////////////////////////////////////////////////////////////////////////////////////////////////
// DoAsync
//
//
public static void DoJob()
{
@@ -68,7 +67,7 @@ namespace AyaNova.Biz
// cannot be shared with other processes.
var PrivateBytes = _process.PrivateMemorySize64;//bigint
//NOTE: CPU percentage is *our* process cpu percentage over timeframe of last captured avg
//So it does *not* show the entire server cpu load, only for RAVEN.
//Overall, server stats need to be captured / viewed independently (digital ocean control panel for example or windows task manager)
@@ -76,8 +75,9 @@ namespace AyaNova.Biz
//In some cases the first snapshot taken after a reboot
//is a huge number way beyond 100 which fucks up the charts
//likely due to the algorithm above and new values but not worth looking into atm
if(CPU > 100){
CPU=0;
if (CPU > 100)
{
CPU = 0;
}
using (AyContext ct = ServiceProviderProvider.DBContext)
{
@@ -90,7 +90,7 @@ namespace AyaNova.Biz
_lastMMSnapshot = now;
}
/////////////////////////////////////////////
//ONCE A DAY SNAPS AND CLEANUP
@@ -147,8 +147,8 @@ namespace AyaNova.Biz
DateTime ClearDate = DateTime.UtcNow - tsDataRetention;
using (AyContext ct = ServiceProviderProvider.DBContext)
{
ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}");
ct.Database.ExecuteSqlInterpolated($"delete from ametricdd where t < {ClearDate.ToUniversalTime()}");
ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}");
ct.Database.ExecuteSqlInterpolated($"delete from ametricdd where t < {ClearDate.ToUniversalTime()}");
}
_lastDDSnapshot = now;
}