framework main thread pool is always active and in use ( even id hard to catch) so show in on show stats. Disable ServerStatsCollector by default, since most don't use it, Adicionally it uses shared framework performance counters system that may be affected if a region crashs

0.9.0-post-fixes
UbitUmarov 2017-06-16 18:16:26 +01:00
parent 822574df9f
commit 4df19ece53
3 changed files with 47 additions and 24 deletions

View File

@ -88,7 +88,7 @@ namespace OpenSim.Framework.Monitoring
IConfig cfg = source.Configs["Monitoring"]; IConfig cfg = source.Configs["Monitoring"];
if (cfg != null) if (cfg != null)
Enabled = cfg.GetBoolean("ServerStatsEnabled", true); Enabled = cfg.GetBoolean("ServerStatsEnabled", false);
if (Enabled) if (Enabled)
{ {
@ -98,12 +98,18 @@ namespace OpenSim.Framework.Monitoring
public void Start() public void Start()
{ {
if(!Enabled)
return;
if (RegisteredStats.Count == 0) if (RegisteredStats.Count == 0)
RegisterServerStats(); RegisterServerStats();
} }
public void Close() public void Close()
{ {
if(!Enabled)
return;
if (RegisteredStats.Count > 0) if (RegisteredStats.Count > 0)
{ {
foreach (Stat stat in RegisteredStats.Values) foreach (Stat stat in RegisteredStats.Values)

View File

@ -882,16 +882,12 @@ namespace OpenSim.Framework.Servers
sb.Append("\n"); sb.Append("\n");
} }
sb.Append("\n"); sb.Append(GetThreadPoolReport());
// For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting sb.Append("\n");
// zero active threads.
int totalThreads = Process.GetCurrentProcess().Threads.Count; int totalThreads = Process.GetCurrentProcess().Threads.Count;
if (totalThreads > 0) if (totalThreads > 0)
sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); sb.AppendFormat("Total process threads active: {0}\n\n", totalThreads);
sb.Append("Main threadpool (excluding script engine pools)\n");
sb.Append(GetThreadPoolReport());
return sb.ToString(); return sb.ToString();
} }
@ -902,15 +898,46 @@ namespace OpenSim.Framework.Servers
/// <returns></returns> /// <returns></returns>
public static string GetThreadPoolReport() public static string GetThreadPoolReport()
{ {
StringBuilder sb = new StringBuilder();
// framework pool is alwasy active
int maxWorkers;
int minWorkers;
int curWorkers;
int maxComp;
int minComp;
int curComp;
try
{
ThreadPool.GetMaxThreads(out maxWorkers, out maxComp);
ThreadPool.GetMinThreads(out minWorkers, out minComp);
ThreadPool.GetAvailableThreads(out curWorkers, out curComp);
curWorkers = maxWorkers - curWorkers;
curComp = maxComp - curComp;
sb.Append("\nFramework main threadpool \n");
sb.AppendFormat("workers: {0} ({1} / {2})\n", curWorkers, maxWorkers, minWorkers);
sb.AppendFormat("Completion: {0} ({1} / {2})\n", curComp, maxComp, minComp);
}
catch { }
if (
Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
|| Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
{
sb.AppendFormat("\nThread pool used: Framework main threadpool\n");
return sb.ToString();
}
string threadPoolUsed = null; string threadPoolUsed = null;
int maxThreads = 0; int maxThreads = 0;
int minThreads = 0; int minThreads = 0;
int allocatedThreads = 0; int allocatedThreads = 0;
int inUseThreads = 0; int inUseThreads = 0;
int waitingCallbacks = 0; int waitingCallbacks = 0;
int completionPortThreads = 0;
StringBuilder sb = new StringBuilder();
if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
{ {
STPInfo stpi = Util.GetSmartThreadPoolInfo(); STPInfo stpi = Util.GetSmartThreadPoolInfo();
@ -926,22 +953,10 @@ namespace OpenSim.Framework.Servers
waitingCallbacks = stpi.WaitingCallbacks; waitingCallbacks = stpi.WaitingCallbacks;
} }
} }
else if (
Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
|| Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
{
threadPoolUsed = "BuiltInThreadPool";
ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
int availableThreads;
ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
inUseThreads = maxThreads - availableThreads;
allocatedThreads = -1;
waitingCallbacks = -1;
}
if (threadPoolUsed != null) if (threadPoolUsed != null)
{ {
sb.Append("\nThreadpool (excluding script engine pools)\n");
sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
sb.AppendFormat("Max threads : {0}\n", maxThreads); sb.AppendFormat("Max threads : {0}\n", maxThreads);
sb.AppendFormat("Min threads : {0}\n", minThreads); sb.AppendFormat("Min threads : {0}\n", minThreads);

View File

@ -2092,6 +2092,8 @@
; If true, this will print out an error if more than a minute has passed since the last simulator frame ; If true, this will print out an error if more than a minute has passed since the last simulator frame
; Also is another source of region statistics provided via the regionstats URL ; Also is another source of region statistics provided via the regionstats URL
Enabled = true Enabled = true
; next option may still use framework performance monitors designed for debug only, so avoid it
ServerStatsEnabled = false
[WebStats] [WebStats]