aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-11-04 00:55:48 +0000
committerJustin Clark-Casey (justincc)2014-11-25 23:23:10 +0000
commitec8d21c434a39f46518ee9cf9f5539d1790eacc0 (patch)
tree2aa340fb34c6f6e8e8f2e31c2034b5841307a7bf /OpenSim/Framework
parentAdd "show threadpool calls" command to show count of all labelled smartthread... (diff)
downloadopensim-SC_OLD-ec8d21c434a39f46518ee9cf9f5539d1790eacc0.zip
opensim-SC_OLD-ec8d21c434a39f46518ee9cf9f5539d1790eacc0.tar.gz
opensim-SC_OLD-ec8d21c434a39f46518ee9cf9f5539d1790eacc0.tar.bz2
opensim-SC_OLD-ec8d21c434a39f46518ee9cf9f5539d1790eacc0.tar.xz
Label all threadpool calls being made in core OpenSimulator. This is to add problem diagnosis.
"show threadpool calls" now also returns named (labelled), anonymous (unlabelled) and total call stats.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/RestClient.cs2
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs8
-rw-r--r--OpenSim/Framework/Util.cs23
3 files changed, 22 insertions, 11 deletions
diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs
index de6fe30..72018e4 100644
--- a/OpenSim/Framework/Communications/RestClient.cs
+++ b/OpenSim/Framework/Communications/RestClient.cs
@@ -483,7 +483,7 @@ namespace OpenSim.Framework.Communications
483 /// In case, we are invoked asynchroneously this object will keep track of the state 483 /// In case, we are invoked asynchroneously this object will keep track of the state
484 /// </summary> 484 /// </summary>
485 AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state); 485 AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state);
486 Util.FireAndForget(RequestHelper, ar); 486 Util.FireAndForget(RequestHelper, ar, "RestClient.BeginRequest");
487 return ar; 487 return ar;
488 } 488 }
489 489
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 379e224..eb9fb8b 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -365,13 +365,21 @@ namespace OpenSim.Framework.Servers
365 { 365 {
366 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsMade().ToList(); 366 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsMade().ToList();
367 calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value)); 367 calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value));
368 int namedCallsMade = 0;
368 369
369 ConsoleDisplayList cdl = new ConsoleDisplayList(); 370 ConsoleDisplayList cdl = new ConsoleDisplayList();
370 foreach (KeyValuePair<string, int> kvp in calls) 371 foreach (KeyValuePair<string, int> kvp in calls)
371 { 372 {
372 cdl.AddRow(kvp.Key, kvp.Value); 373 cdl.AddRow(kvp.Key, kvp.Value);
374 namedCallsMade += kvp.Value;
373 } 375 }
374 376
377 cdl.AddRow("TOTAL NAMED", namedCallsMade);
378
379 long allCallsMade = Util.TotalFireAndForgetCallsMade;
380 cdl.AddRow("TOTAL ANONYMOUS", allCallsMade - namedCallsMade);
381 cdl.AddRow("TOTAL ALL", allCallsMade);
382
375 MainConsole.Instance.Output(cdl.ToString()); 383 MainConsole.Instance.Output(cdl.ToString());
376 } 384 }
377 385
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 53bbb06..baad0b9 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1928,11 +1928,6 @@ namespace OpenSim.Framework
1928 } 1928 }
1929 } 1929 }
1930 1930
1931 public static void FireAndForget(System.Threading.WaitCallback callback)
1932 {
1933 FireAndForget(callback, null, null);
1934 }
1935
1936 public static void InitThreadPool(int minThreads, int maxThreads) 1931 public static void InitThreadPool(int minThreads, int maxThreads)
1937 { 1932 {
1938 if (maxThreads < 2) 1933 if (maxThreads < 2)
@@ -1977,8 +1972,7 @@ namespace OpenSim.Framework
1977 throw new NotImplementedException(); 1972 throw new NotImplementedException();
1978 } 1973 }
1979 } 1974 }
1980 1975
1981
1982 /// <summary> 1976 /// <summary>
1983 /// Additional information about threads in the main thread pool. Used to time how long the 1977 /// Additional information about threads in the main thread pool. Used to time how long the
1984 /// thread has been running, and abort it if it has timed-out. 1978 /// thread has been running, and abort it if it has timed-out.
@@ -2052,10 +2046,10 @@ namespace OpenSim.Framework
2052 } 2046 }
2053 } 2047 }
2054 2048
2055
2056 private static long nextThreadFuncNum = 0; 2049 private static long nextThreadFuncNum = 0;
2057 private static long numQueuedThreadFuncs = 0; 2050 private static long numQueuedThreadFuncs = 0;
2058 private static long numRunningThreadFuncs = 0; 2051 private static long numRunningThreadFuncs = 0;
2052 private static long numTotalThreadFuncsCalled = 0;
2059 private static Int32 threadFuncOverloadMode = 0; 2053 private static Int32 threadFuncOverloadMode = 0;
2060 2054
2061 // Maps (ThreadFunc number -> Thread) 2055 // Maps (ThreadFunc number -> Thread)
@@ -2086,20 +2080,29 @@ namespace OpenSim.Framework
2086 } 2080 }
2087 } 2081 }
2088 2082
2083 public static long TotalFireAndForgetCallsMade { get { return numTotalThreadFuncsCalled; } }
2084
2089 public static Dictionary<string, int> GetFireAndForgetCallsMade() 2085 public static Dictionary<string, int> GetFireAndForgetCallsMade()
2090 { 2086 {
2091 return new Dictionary<string, int>(m_fireAndForgetCallsMade); 2087 return new Dictionary<string, int>(m_fireAndForgetCallsMade);
2092 } 2088 }
2093 2089
2094 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>(); 2090 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>();
2095 2091
2092 public static void FireAndForget(System.Threading.WaitCallback callback)
2093 {
2094 FireAndForget(callback, null, null);
2095 }
2096
2096 public static void FireAndForget(System.Threading.WaitCallback callback, object obj) 2097 public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
2097 { 2098 {
2098 FireAndForget(callback, obj, null); 2099 FireAndForget(callback, obj, null);
2099 } 2100 }
2100 2101
2101 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context) 2102 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context)
2102 { 2103 {
2104 Interlocked.Increment(ref numTotalThreadFuncsCalled);
2105
2103 if (context != null) 2106 if (context != null)
2104 { 2107 {
2105 if (!m_fireAndForgetCallsMade.ContainsKey(context)) 2108 if (!m_fireAndForgetCallsMade.ContainsKey(context))