diff options
Diffstat (limited to 'OpenSim/Framework/Servers/ServerBase.cs')
-rw-r--r-- | OpenSim/Framework/Servers/ServerBase.cs | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 7108314..35177f4 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | 30 | using System.Diagnostics; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Linq; | ||
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using System.Text; | 34 | using System.Text; |
34 | using System.Text.RegularExpressions; | 35 | using System.Text.RegularExpressions; |
@@ -279,6 +280,29 @@ namespace OpenSim.Framework.Servers | |||
279 | "debug threadpool status", | 280 | "debug threadpool status", |
280 | "Show current debug threadpool parameters.", | 281 | "Show current debug threadpool parameters.", |
281 | HandleDebugThreadpoolStatus); | 282 | HandleDebugThreadpoolStatus); |
283 | |||
284 | m_console.Commands.AddCommand( | ||
285 | "Debug", false, "debug threadpool level", | ||
286 | "debug threadpool level 0.." + Util.MAX_THREADPOOL_LEVEL, | ||
287 | "Turn on logging of activity in the main thread pool.", | ||
288 | "Log levels:\n" | ||
289 | + " 0 = no logging\n" | ||
290 | + " 1 = only first line of stack trace; don't log common threads\n" | ||
291 | + " 2 = full stack trace; don't log common threads\n" | ||
292 | + " 3 = full stack trace, including common threads\n", | ||
293 | HandleDebugThreadpoolLevel); | ||
294 | |||
295 | // m_console.Commands.AddCommand( | ||
296 | // "Debug", false, "show threadpool calls active", | ||
297 | // "show threadpool calls active", | ||
298 | // "Show details about threadpool calls that are still active (currently waiting or in progress)", | ||
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); | ||
282 | 306 | ||
283 | m_console.Commands.AddCommand( | 307 | m_console.Commands.AddCommand( |
284 | "Debug", false, "force gc", | 308 | "Debug", false, "force gc", |
@@ -343,6 +367,57 @@ namespace OpenSim.Framework.Servers | |||
343 | Notice("serialosdreq is now {0}", setSerializeOsdRequests); | 367 | Notice("serialosdreq is now {0}", setSerializeOsdRequests); |
344 | } | 368 | } |
345 | 369 | ||
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) | ||
400 | { | ||
401 | List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsMade().ToList(); | ||
402 | calls.Sort((kvp1, kvp2) => kvp2.Value.CompareTo(kvp1.Value)); | ||
403 | int namedCallsMade = 0; | ||
404 | |||
405 | ConsoleDisplayList cdl = new ConsoleDisplayList(); | ||
406 | foreach (KeyValuePair<string, int> kvp in calls) | ||
407 | { | ||
408 | cdl.AddRow(kvp.Key, kvp.Value); | ||
409 | namedCallsMade += kvp.Value; | ||
410 | } | ||
411 | |||
412 | cdl.AddRow("TOTAL NAMED", namedCallsMade); | ||
413 | |||
414 | long allCallsMade = Util.TotalFireAndForgetCallsMade; | ||
415 | cdl.AddRow("TOTAL ANONYMOUS", allCallsMade - namedCallsMade); | ||
416 | cdl.AddRow("TOTAL ALL", allCallsMade); | ||
417 | |||
418 | MainConsole.Instance.Output(cdl.ToString()); | ||
419 | } | ||
420 | |||
346 | private void HandleDebugThreadpoolStatus(string module, string[] args) | 421 | private void HandleDebugThreadpoolStatus(string module, string[] args) |
347 | { | 422 | { |
348 | int workerThreads, iocpThreads; | 423 | int workerThreads, iocpThreads; |
@@ -432,6 +507,33 @@ namespace OpenSim.Framework.Servers | |||
432 | } | 507 | } |
433 | } | 508 | } |
434 | 509 | ||
510 | private static void HandleDebugThreadpoolLevel(string module, string[] cmdparams) | ||
511 | { | ||
512 | if (cmdparams.Length < 4) | ||
513 | { | ||
514 | MainConsole.Instance.Output("Usage: debug threadpool level 0.." + Util.MAX_THREADPOOL_LEVEL); | ||
515 | return; | ||
516 | } | ||
517 | |||
518 | string rawLevel = cmdparams[3]; | ||
519 | int newLevel; | ||
520 | |||
521 | if (!int.TryParse(rawLevel, out newLevel)) | ||
522 | { | ||
523 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawLevel); | ||
524 | return; | ||
525 | } | ||
526 | |||
527 | if (newLevel < 0 || newLevel > Util.MAX_THREADPOOL_LEVEL) | ||
528 | { | ||
529 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0.." + Util.MAX_THREADPOOL_LEVEL, newLevel); | ||
530 | return; | ||
531 | } | ||
532 | |||
533 | Util.LogThreadPool = newLevel; | ||
534 | MainConsole.Instance.OutputFormat("LogThreadPool set to {0}", newLevel); | ||
535 | } | ||
536 | |||
435 | private void HandleForceGc(string module, string[] args) | 537 | private void HandleForceGc(string module, string[] args) |
436 | { | 538 | { |
437 | Notice("Manually invoking runtime garbage collection"); | 539 | Notice("Manually invoking runtime garbage collection"); |