From 32396742f86fb5336de5acd4e2a05099f111022a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Aug 2016 06:26:31 +0100 Subject: reduce unnecessary allocation of new items --- OpenSim/Framework/Monitoring/StatsManager.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Monitoring') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 8787ea0..008127e 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -361,8 +361,8 @@ namespace OpenSim.Framework.Monitoring /// public static bool RegisterStat(Stat stat) { - SortedDictionary> category = null, newCategory; - SortedDictionary container = null, newContainer; + SortedDictionary> category = null; + SortedDictionary container = null; lock (RegisteredStats) { @@ -375,19 +375,15 @@ namespace OpenSim.Framework.Monitoring // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. // This means that we don't need to lock or copy them on iteration, which will be a much more // common operation after startup. - if (container != null) - newContainer = new SortedDictionary(container); - else - newContainer = new SortedDictionary(); + if (container == null) + container = new SortedDictionary(); - if (category != null) - newCategory = new SortedDictionary>(category); - else - newCategory = new SortedDictionary>(); + if (category == null) + category = new SortedDictionary>(); - newContainer[stat.ShortName] = stat; - newCategory[stat.Container] = newContainer; - RegisteredStats[stat.Category] = newCategory; + container[stat.ShortName] = stat; + category[stat.Container] = container; + RegisteredStats[stat.Category] = category; } return true; -- cgit v1.1 From fc459420263329d4e93910df9e761db94bce10e0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Aug 2016 06:57:21 +0100 Subject: remove redundate console comand add, change stat deregister --- OpenSim/Framework/Monitoring/StatsManager.cs | 36 +++++++++++----------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Monitoring') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 008127e..c0be87b 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -80,16 +80,7 @@ namespace OpenSim.Framework.Monitoring + "'all' will show all statistics.\n" + "A name will show statistics from that category.\n" + "A . name will show statistics from that category in that container.\n" - + "More than one name can be given separated by spaces.\n" - + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", - HandleShowStatsCommand); - - console.Commands.AddCommand( - "General", - false, - "show stats", - "show stats [list|all|([.])+", - "Alias for 'stats show' command", + + "More than one name can be given separated by spaces.\n", HandleShowStatsCommand); StatsLogger.RegisterConsoleCommands(console); @@ -396,23 +387,24 @@ namespace OpenSim.Framework.Monitoring /// public static bool DeregisterStat(Stat stat) { - SortedDictionary> category = null, newCategory; - SortedDictionary container = null, newContainer; + SortedDictionary> category = null; + SortedDictionary container = null; lock (RegisteredStats) { if (!TryGetStatParents(stat, out category, out container)) return false; - - newContainer = new SortedDictionary(container); - newContainer.Remove(stat.ShortName); - - newCategory = new SortedDictionary>(category); - newCategory.Remove(stat.Container); - - newCategory[stat.Container] = newContainer; - RegisteredStats[stat.Category] = newCategory; - + + if(container != null) + { + container.Remove(stat.ShortName); + if(category != null && container.Count == 0) + { + category.Remove(stat.Container); + if(category.Count == 0) + RegisteredStats.Remove(stat.Category); + } + } return true; } } -- cgit v1.1 From 387d564aadc38c28af78d5b60a3bad57f1a8a2d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Aug 2016 07:41:11 +0100 Subject: do similar changes to unused checksManager --- OpenSim/Framework/Monitoring/ChecksManager.cs | 45 +++++++++++++-------------- OpenSim/Framework/Monitoring/StatsManager.cs | 3 -- 2 files changed, 21 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Monitoring') diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs index e4a7f8c..ff3b041 100644 --- a/OpenSim/Framework/Monitoring/ChecksManager.cs +++ b/OpenSim/Framework/Monitoring/ChecksManager.cs @@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring /// public static bool RegisterCheck(Check check) { - SortedDictionary> category = null, newCategory; - SortedDictionary container = null, newContainer; + SortedDictionary> category = null; + SortedDictionary container = null; lock (RegisteredChecks) { @@ -146,19 +146,15 @@ namespace OpenSim.Framework.Monitoring // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. // This means that we don't need to lock or copy them on iteration, which will be a much more // common operation after startup. - if (container != null) - newContainer = new SortedDictionary(container); - else - newContainer = new SortedDictionary(); + if (container == null) + container = new SortedDictionary(); - if (category != null) - newCategory = new SortedDictionary>(category); - else - newCategory = new SortedDictionary>(); + if (category == null) + category = new SortedDictionary>(); - newContainer[check.ShortName] = check; - newCategory[check.Container] = newContainer; - RegisteredChecks[check.Category] = newCategory; + container[check.ShortName] = check; + category[check.Container] = container; + RegisteredChecks[check.Category] = category; } return true; @@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring /// public static bool DeregisterCheck(Check check) { - SortedDictionary> category = null, newCategory; - SortedDictionary container = null, newContainer; + SortedDictionary> category = null; + SortedDictionary container = null; lock (RegisteredChecks) { if (!TryGetCheckParents(check, out category, out container)) return false; - newContainer = new SortedDictionary(container); - newContainer.Remove(check.ShortName); - - newCategory = new SortedDictionary>(category); - newCategory.Remove(check.Container); - - newCategory[check.Container] = newContainer; - RegisteredChecks[check.Category] = newCategory; - + if(container != null) + { + container.Remove(check.ShortName); + if(category != null && container.Count == 0) + { + category.Remove(check.Container); + if(category.Count == 0) + RegisteredChecks.Remove(check.Category); + } + } return true; } } diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index c0be87b..6277d44 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -363,9 +363,6 @@ namespace OpenSim.Framework.Monitoring if (TryGetStatParents(stat, out category, out container)) return false; - // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. - // This means that we don't need to lock or copy them on iteration, which will be a much more - // common operation after startup. if (container == null) container = new SortedDictionary(); -- cgit v1.1 From 7ce6430a86d3ea5a5acc541f25b7813da6796296 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Aug 2016 04:55:01 +0100 Subject: put back the console comand i remove since it is not a repetion --- OpenSim/Framework/Monitoring/StatsManager.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/Monitoring') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 6277d44..30926d8 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -83,6 +83,13 @@ namespace OpenSim.Framework.Monitoring + "More than one name can be given separated by spaces.\n", HandleShowStatsCommand); + console.Commands.AddCommand( + "General", + false, + "show stats", + "show stats [list|all|([.])+", + "Alias for 'stats show' command", + HandleShowStatsCommand); StatsLogger.RegisterConsoleCommands(console); } -- cgit v1.1 From 38ba839eb35987e47b98f795fbdc6083ab48921c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Aug 2016 23:31:18 +0100 Subject: watchdog timeouts: replace a silly List copy i added doing it a better way --- OpenSim/Framework/Monitoring/Watchdog.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Monitoring') diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index b2c1fb1..ff439f5 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -332,18 +332,18 @@ namespace OpenSim.Framework.Monitoring if (callback != null) { List callbackInfos = null; - List threadsInfo; + List threadsToRemove = null; lock (m_threads) { - // get a copy since we may change m_threads - threadsInfo = m_threads.Values.ToList(); - - foreach(ThreadWatchdogInfo threadInfo in threadsInfo) + foreach(ThreadWatchdogInfo threadInfo in m_threads.Values) { if(threadInfo.Thread.ThreadState == ThreadState.Stopped) { - RemoveThread(threadInfo.Thread.ManagedThreadId); + if(threadsToRemove == null) + threadsToRemove = new List(); + + threadsToRemove.Add(threadInfo); if(callbackInfos == null) callbackInfos = new List(); @@ -365,6 +365,10 @@ namespace OpenSim.Framework.Monitoring } } } + + if(threadsToRemove != null) + foreach(ThreadWatchdogInfo twi in threadsToRemove) + RemoveThread(twi.Thread.ManagedThreadId); } if(callbackInfos != null) -- cgit v1.1