aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs45
-rw-r--r--OpenSim/Framework/Util.cs28
2 files changed, 67 insertions, 6 deletions
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index eb9fb8b..c22c119 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -293,10 +293,16 @@ namespace OpenSim.Framework.Servers
293 HandleDebugThreadpoolLevel); 293 HandleDebugThreadpoolLevel);
294 294
295 m_console.Commands.AddCommand( 295 m_console.Commands.AddCommand(
296 "Debug", false, "show threadpool calls", 296 "Debug", false, "show threadpool calls active",
297 "show threadpool calls", 297 "show threadpool calls active",
298 "Show the number of labelled threadpool calls.", 298 "Show details about threadpool calls that are still active (currently waiting or in progress)",
299 HandleShowThreadpoolCalls); 299 HandleShowThreadpoolCallsActive);
300
301 m_console.Commands.AddCommand(
302 "Debug", false, "show threadpool calls complete",
303 "show threadpool calls complete",
304 "Show details about threadpool calls that have been completed.",
305 HandleShowThreadpoolCallsComplete);
300 306
301 m_console.Commands.AddCommand( 307 m_console.Commands.AddCommand(
302 "Debug", false, "force gc", 308 "Debug", false, "force gc",
@@ -361,7 +367,36 @@ namespace OpenSim.Framework.Servers
361 Notice("serialosdreq is now {0}", setSerializeOsdRequests); 367 Notice("serialosdreq is now {0}", setSerializeOsdRequests);
362 } 368 }
363 369
364 private void HandleShowThreadpoolCalls(string module, string[] args) 370 private void HandleShowThreadpoolCallsActive(string module, string[] args)
371 {
372 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsInProgress().ToList();
373 calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value));
374 int namedCalls = 0;
375
376 ConsoleDisplayList cdl = new ConsoleDisplayList();
377 foreach (KeyValuePair<string, int> kvp in calls)
378 {
379 if (kvp.Value > 0)
380 {
381 cdl.AddRow(kvp.Key, kvp.Value);
382 namedCalls += kvp.Value;
383 }
384 }
385
386 cdl.AddRow("TOTAL NAMED", namedCalls);
387
388 long allQueuedCalls = Util.TotalQueuedFireAndForgetCalls;
389 long allRunningCalls = Util.TotalRunningFireAndForgetCalls;
390
391 cdl.AddRow("TOTAL QUEUED", allQueuedCalls);
392 cdl.AddRow("TOTAL RUNNING", allRunningCalls);
393 cdl.AddRow("TOTAL ANONYMOUS", allQueuedCalls + allRunningCalls - namedCalls);
394 cdl.AddRow("TOTAL ALL", allQueuedCalls + allRunningCalls);
395
396 MainConsole.Instance.Output(cdl.ToString());
397 }
398
399 private void HandleShowThreadpoolCallsComplete(string module, string[] args)
365 { 400 {
366 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsMade().ToList(); 401 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsMade().ToList();
367 calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value)); 402 calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value));
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index baad0b9..97c958a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2052,6 +2052,9 @@ namespace OpenSim.Framework
2052 private static long numTotalThreadFuncsCalled = 0; 2052 private static long numTotalThreadFuncsCalled = 0;
2053 private static Int32 threadFuncOverloadMode = 0; 2053 private static Int32 threadFuncOverloadMode = 0;
2054 2054
2055 public static long TotalQueuedFireAndForgetCalls { get { return numQueuedThreadFuncs; } }
2056 public static long TotalRunningFireAndForgetCalls { get { return numRunningThreadFuncs; } }
2057
2055 // Maps (ThreadFunc number -> Thread) 2058 // Maps (ThreadFunc number -> Thread)
2056 private static ConcurrentDictionary<long, ThreadInfo> activeThreads = new ConcurrentDictionary<long, ThreadInfo>(); 2059 private static ConcurrentDictionary<long, ThreadInfo> activeThreads = new ConcurrentDictionary<long, ThreadInfo>();
2057 2060
@@ -2089,6 +2092,13 @@ namespace OpenSim.Framework
2089 2092
2090 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>(); 2093 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>();
2091 2094
2095 public static Dictionary<string, int> GetFireAndForgetCallsInProgress()
2096 {
2097 return new Dictionary<string, int>(m_fireAndForgetCallsInProgress);
2098 }
2099
2100 private static Dictionary<string, int> m_fireAndForgetCallsInProgress = new Dictionary<string, int>();
2101
2092 public static void FireAndForget(System.Threading.WaitCallback callback) 2102 public static void FireAndForget(System.Threading.WaitCallback callback)
2093 { 2103 {
2094 FireAndForget(callback, null, null); 2104 FireAndForget(callback, null, null);
@@ -2109,6 +2119,11 @@ namespace OpenSim.Framework
2109 m_fireAndForgetCallsMade[context] = 1; 2119 m_fireAndForgetCallsMade[context] = 1;
2110 else 2120 else
2111 m_fireAndForgetCallsMade[context]++; 2121 m_fireAndForgetCallsMade[context]++;
2122
2123 if (!m_fireAndForgetCallsInProgress.ContainsKey(context))
2124 m_fireAndForgetCallsInProgress[context] = 1;
2125 else
2126 m_fireAndForgetCallsInProgress[context]++;
2112 } 2127 }
2113 2128
2114 WaitCallback realCallback; 2129 WaitCallback realCallback;
@@ -2121,7 +2136,15 @@ namespace OpenSim.Framework
2121 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 2136 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
2122 { 2137 {
2123 // If we're running regression tests, then we want any exceptions to rise up to the test code. 2138 // If we're running regression tests, then we want any exceptions to rise up to the test code.
2124 realCallback = o => { Culture.SetCurrentCulture(); callback(o); }; 2139 realCallback =
2140 o =>
2141 {
2142 Culture.SetCurrentCulture();
2143 callback(o);
2144
2145 if (context != null)
2146 m_fireAndForgetCallsInProgress[context]--;
2147 };
2125 } 2148 }
2126 else 2149 else
2127 { 2150 {
@@ -2160,6 +2183,9 @@ namespace OpenSim.Framework
2160 activeThreads.TryRemove(threadFuncNum, out dummy); 2183 activeThreads.TryRemove(threadFuncNum, out dummy);
2161 if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread) 2184 if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread)
2162 m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed())); 2185 m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed()));
2186
2187 if (context != null)
2188 m_fireAndForgetCallsInProgress[context]--;
2163 } 2189 }
2164 }; 2190 };
2165 } 2191 }