aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-16 03:26:47 +0000
committerJustin Clark-Casey (justincc)2012-03-16 03:26:47 +0000
commit6e8f80f1ab933bbd00b892fa6d01f93f62a1bbbd (patch)
tree7ea110ed31774d875574b474ddf0859979574b02 /OpenSim
parentAdd process working memory to "show stats" memory statistics. (diff)
downloadopensim-SC_OLD-6e8f80f1ab933bbd00b892fa6d01f93f62a1bbbd.zip
opensim-SC_OLD-6e8f80f1ab933bbd00b892fa6d01f93f62a1bbbd.tar.gz
opensim-SC_OLD-6e8f80f1ab933bbd00b892fa6d01f93f62a1bbbd.tar.bz2
opensim-SC_OLD-6e8f80f1ab933bbd00b892fa6d01f93f62a1bbbd.tar.xz
Improve threadpool reporting to "show threads" console command (also gets printed out periodically)
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs8
-rw-r--r--OpenSim/Framework/Util.cs56
2 files changed, 57 insertions, 7 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index d5c2515..5c74ac9 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -272,12 +272,8 @@ namespace OpenSim.Framework.Servers
272 sb.Append(Environment.NewLine); 272 sb.Append(Environment.NewLine);
273 } 273 }
274 274
275 int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; 275 sb.Append("\n*** Main threadpool (excluding script engine)***\n");
276 ThreadPool.GetAvailableThreads(out workers, out ports); 276 sb.Append(Util.GetThreadPoolReport());
277 ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts);
278
279 sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine);
280 sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine);
281 277
282 return sb.ToString(); 278 return sb.ToString();
283 } 279 }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 31fa101..9e0f138 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -147,7 +147,6 @@ namespace OpenSim.Framework
147 return lerp(y, lerp(x, a, b), lerp(x, c, d)); 147 return lerp(y, lerp(x, a, b), lerp(x, c, d));
148 } 148 }
149 149
150
151 public static Encoding UTF8 = Encoding.UTF8; 150 public static Encoding UTF8 = Encoding.UTF8;
152 151
153 /// <value> 152 /// <value>
@@ -1674,6 +1673,61 @@ namespace OpenSim.Framework
1674 } 1673 }
1675 } 1674 }
1676 1675
1676 /// <summary>
1677 /// Get a thread pool report.
1678 /// </summary>
1679 /// <returns></returns>
1680 public static string GetThreadPoolReport()
1681 {
1682 string threadPoolUsed = null;
1683 int maxThreads = 0;
1684 int minThreads = 0;
1685 int allocatedThreads = 0;
1686 int inUseThreads = 0;
1687 int waitingCallbacks = 0;
1688 int completionPortThreads = 0;
1689
1690 StringBuilder sb = new StringBuilder();
1691 if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
1692 {
1693 threadPoolUsed = "SmartThreadPool";
1694 maxThreads = m_ThreadPool.MaxThreads;
1695 minThreads = m_ThreadPool.MinThreads;
1696 inUseThreads = m_ThreadPool.InUseThreads;
1697 allocatedThreads = m_ThreadPool.ActiveThreads;
1698 waitingCallbacks = m_ThreadPool.WaitingCallbacks;
1699 }
1700 else if (
1701 FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem
1702 || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
1703 {
1704 threadPoolUsed = "BuiltInThreadPool";
1705 ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
1706 ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
1707 int availableThreads;
1708 ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
1709 inUseThreads = maxThreads - availableThreads;
1710 allocatedThreads = -1;
1711 waitingCallbacks = -1;
1712 }
1713
1714 if (threadPoolUsed != null)
1715 {
1716 sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
1717 sb.AppendFormat("Max threads : {0}\n", maxThreads);
1718 sb.AppendFormat("Min threads : {0}\n", minThreads);
1719 sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString());
1720 sb.AppendFormat("In use threads : {0}\n", inUseThreads);
1721 sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString());
1722 }
1723 else
1724 {
1725 sb.AppendFormat("Thread pool not used\n");
1726 }
1727
1728 return sb.ToString();
1729 }
1730
1677 private static object SmartThreadPoolCallback(object o) 1731 private static object SmartThreadPoolCallback(object o)
1678 { 1732 {
1679 object[] array = (object[])o; 1733 object[] array = (object[])o;