diff options
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 16 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 56 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 |
3 files changed, 71 insertions, 8 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index d5c2515..06a8021 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -269,15 +269,19 @@ namespace OpenSim.Framework.Servers | |||
269 | t.Priority, | 269 | t.Priority, |
270 | t.ThreadState); | 270 | t.ThreadState); |
271 | 271 | ||
272 | sb.Append(Environment.NewLine); | 272 | sb.Append("\n"); |
273 | } | 273 | } |
274 | 274 | ||
275 | int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; | 275 | sb.Append("\n"); |
276 | ThreadPool.GetAvailableThreads(out workers, out ports); | ||
277 | ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts); | ||
278 | 276 | ||
279 | sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine); | 277 | // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting |
280 | sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine); | 278 | // zero active threads. |
279 | int totalThreads = Process.GetCurrentProcess().Threads.Count; | ||
280 | if (totalThreads > 0) | ||
281 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); | ||
282 | |||
283 | sb.Append("Main threadpool (excluding script engine pools)\n"); | ||
284 | sb.Append(Util.GetThreadPoolReport()); | ||
281 | 285 | ||
282 | return sb.ToString(); | 286 | return sb.ToString(); |
283 | } | 287 | } |
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; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 3697f78..d4108d7 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -380,6 +380,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
380 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | 380 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) |
381 | return; | 381 | return; |
382 | 382 | ||
383 | MainConsole.Instance.OutputFormat(GetStatusReport()); | ||
384 | } | ||
385 | |||
386 | public string GetStatusReport() | ||
387 | { | ||
383 | StringBuilder sb = new StringBuilder(); | 388 | StringBuilder sb = new StringBuilder(); |
384 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); | 389 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); |
385 | 390 | ||
@@ -407,7 +412,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
407 | Listener l = AsyncCommandManager.GetListenerPlugin(this); | 412 | Listener l = AsyncCommandManager.GetListenerPlugin(this); |
408 | sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); | 413 | sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); |
409 | 414 | ||
410 | MainConsole.Instance.OutputFormat(sb.ToString()); | 415 | return sb.ToString(); |
411 | } | 416 | } |
412 | 417 | ||
413 | public void HandleShowScripts(string module, string[] cmdparams) | 418 | public void HandleShowScripts(string module, string[] cmdparams) |