From e9153e1d1aae50024d8cd05fe14a9bce34343a0e Mon Sep 17 00:00:00 2001
From: teravus
Date: Thu, 15 Nov 2012 10:05:16 -0500
Subject: Revert "Merge master into teravuswork", it should have been
avination, not master.
This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing
changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64.
---
OpenSim/Framework/Monitoring/BaseStatsCollector.cs | 23 +-
OpenSim/Framework/Monitoring/MemoryWatchdog.cs | 10 +-
.../Framework/Monitoring/SimExtraStatsCollector.cs | 19 +-
OpenSim/Framework/Monitoring/StatsManager.cs | 360 ---------------------
OpenSim/Framework/Monitoring/Watchdog.cs | 35 +-
5 files changed, 14 insertions(+), 433 deletions(-)
(limited to 'OpenSim/Framework/Monitoring')
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
index 446e3c0..9ee0876 100644
--- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
@@ -43,32 +43,27 @@ namespace OpenSim.Framework.Monitoring
StringBuilder sb = new StringBuilder(Environment.NewLine);
sb.Append("MEMORY STATISTICS");
sb.Append(Environment.NewLine);
- sb.AppendFormat(
+ sb.Append(
+ string.Format(
"Allocated to OpenSim objects: {0} MB\n",
- Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
-
- sb.AppendFormat(
- "OpenSim last object memory churn : {0} MB/s\n",
- Math.Round((MemoryWatchdog.LastMemoryChurn * 1000) / 1024.0 / 1024, 3));
-
- sb.AppendFormat(
- "OpenSim average object memory churn : {0} MB/s\n",
- Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3));
+ Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
Process myprocess = Process.GetCurrentProcess();
if (!myprocess.HasExited)
{
myprocess.Refresh();
- sb.AppendFormat(
+ sb.Append(
+ string.Format(
"Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0),
Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0),
- Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0));
- sb.AppendFormat(
+ Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0)));
+ sb.Append(
+ string.Format(
"Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0),
Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0),
- Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0));
+ Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0)));
}
else
sb.Append("Process reported as Exited \n");
diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs
index c6010cd..a23cf1f 100644
--- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs
+++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Framework.Monitoring
private static bool m_enabled;
///
- /// Last memory churn in bytes per millisecond.
+ /// Average memory churn in bytes per millisecond.
///
public static double AverageMemoryChurn
{
@@ -68,14 +68,6 @@ namespace OpenSim.Framework.Monitoring
}
///
- /// Average memory churn in bytes per millisecond.
- ///
- public static double LastMemoryChurn
- {
- get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; }
- }
-
- ///
/// Maximum number of statistical samples.
///
///
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
index aa86202..cdd7cc7 100644
--- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
@@ -355,25 +355,10 @@ Asset service request failures: {3}" + Environment.NewLine,
sb.Append(Environment.NewLine);
sb.Append(
string.Format(
- "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n",
+ "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}",
inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
-
- Dictionary> sceneStats;
-
- if (StatsManager.TryGetStats("scene", out sceneStats))
- {
- foreach (KeyValuePair> kvp in sceneStats)
- {
- foreach (Stat stat in kvp.Value.Values)
- {
- if (stat.Verbosity == StatVerbosity.Info)
- {
- sb.AppendFormat("{0} ({1}): {2}{3}\n", stat.Name, stat.Container, stat.Value, stat.UnitName);
- }
- }
- }
- }
+ sb.Append(Environment.NewLine);
/*
sb.Append(Environment.NewLine);
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 4844336..d78fa6a 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -25,9 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
-using System.Collections.Generic;
-
namespace OpenSim.Framework.Monitoring
{
///
@@ -35,24 +32,6 @@ namespace OpenSim.Framework.Monitoring
///
public class StatsManager
{
- // Subcommand used to list other stats.
- public const string AllSubCommand = "all";
-
- // Subcommand used to list other stats.
- public const string ListSubCommand = "list";
-
- // All subcommands
- public static HashSet SubCommands = new HashSet { AllSubCommand, ListSubCommand };
-
- ///
- /// Registered stats categorized by category/container/shortname
- ///
- ///
- /// Do not add or remove directly from this dictionary.
- ///
- public static Dictionary>> RegisteredStats
- = new Dictionary>>();
-
private static AssetStatsCollector assetStats;
private static UserStatsCollector userStats;
private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector();
@@ -61,75 +40,6 @@ namespace OpenSim.Framework.Monitoring
public static UserStatsCollector UserStats { get { return userStats; } }
public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } }
- public static void RegisterConsoleCommands(ICommandConsole console)
- {
- console.Commands.AddCommand(
- "General",
- false,
- "show stats",
- "show stats [list|all|]",
- "Show statistical information for this server",
- "If no final argument is specified then legacy statistics information is currently shown.\n"
- + "If list is specified then statistic categories are shown.\n"
- + "If all is specified then all registered statistics are shown.\n"
- + "If a category name is specified then only statistics from that category are shown.\n"
- + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
- HandleShowStatsCommand);
- }
-
- public static void HandleShowStatsCommand(string module, string[] cmd)
- {
- ICommandConsole con = MainConsole.Instance;
-
- if (cmd.Length > 2)
- {
- var categoryName = cmd[2];
-
- if (categoryName == AllSubCommand)
- {
- foreach (var category in RegisteredStats.Values)
- {
- OutputCategoryStatsToConsole(con, category);
- }
- }
- else if (categoryName == ListSubCommand)
- {
- con.Output("Statistic categories available are:");
- foreach (string category in RegisteredStats.Keys)
- con.OutputFormat(" {0}", category);
- }
- else
- {
- Dictionary> category;
- if (!RegisteredStats.TryGetValue(categoryName, out category))
- {
- con.OutputFormat("No such category as {0}", categoryName);
- }
- else
- {
- OutputCategoryStatsToConsole(con, category);
- }
- }
- }
- else
- {
- // Legacy
- con.Output(SimExtraStats.Report());
- }
- }
-
- private static void OutputCategoryStatsToConsole(
- ICommandConsole con, Dictionary> category)
- {
- foreach (var container in category.Values)
- {
- foreach (Stat stat in container.Values)
- {
- con.Output(stat.ToConsoleString());
- }
- }
- }
-
///
/// Start collecting statistics related to assets.
/// Should only be called once.
@@ -151,275 +61,5 @@ namespace OpenSim.Framework.Monitoring
return userStats;
}
-
- ///
- /// Registers a statistic.
- ///
- ///
- ///
- public static bool RegisterStat(Stat stat)
- {
- Dictionary> category = null, newCategory;
- Dictionary container = null, newContainer;
-
- lock (RegisteredStats)
- {
- // Stat name is not unique across category/container/shortname key.
- // XXX: For now just return false. This is to avoid problems in regression tests where all tests
- // in a class are run in the same instance of the VM.
- if (TryGetStat(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)
- newContainer = new Dictionary(container);
- else
- newContainer = new Dictionary();
-
- if (category != null)
- newCategory = new Dictionary>(category);
- else
- newCategory = new Dictionary>();
-
- newContainer[stat.ShortName] = stat;
- newCategory[stat.Container] = newContainer;
- RegisteredStats[stat.Category] = newCategory;
- }
-
- return true;
- }
-
- ///
- /// Deregister a statistic
- /// >
- ///
- /// > category = null, newCategory;
- Dictionary container = null, newContainer;
-
- lock (RegisteredStats)
- {
- if (!TryGetStat(stat, out category, out container))
- return false;
-
- newContainer = new Dictionary(container);
- newContainer.Remove(stat.ShortName);
-
- newCategory = new Dictionary>(category);
- newCategory.Remove(stat.Container);
-
- newCategory[stat.Container] = newContainer;
- RegisteredStats[stat.Category] = newCategory;
-
- return true;
- }
- }
-
- public static bool TryGetStats(string category, out Dictionary> stats)
- {
- return RegisteredStats.TryGetValue(category, out stats);
- }
-
- public static bool TryGetStat(
- Stat stat,
- out Dictionary> category,
- out Dictionary container)
- {
- category = null;
- container = null;
-
- lock (RegisteredStats)
- {
- if (RegisteredStats.TryGetValue(stat.Category, out category))
- {
- if (category.TryGetValue(stat.Container, out container))
- {
- if (container.ContainsKey(stat.ShortName))
- return true;
- }
- }
- }
-
- return false;
- }
- }
-
- ///
- /// Stat type.
- ///
- ///
- /// A push stat is one which is continually updated and so it's value can simply by read.
- /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated.
- ///
- public enum StatType
- {
- Push,
- Pull
- }
-
- ///
- /// Verbosity of stat.
- ///
- ///
- /// Info will always be displayed.
- ///
- public enum StatVerbosity
- {
- Debug,
- Info
- }
-
- ///
- /// Holds individual static details
- ///
- public class Stat
- {
- ///
- /// Category of this stat (e.g. cache, scene, etc).
- ///
- public string Category { get; private set; }
-
- ///
- /// Containing name for this stat.
- /// FIXME: In the case of a scene, this is currently the scene name (though this leaves
- /// us with a to-be-resolved problem of non-unique region names).
- ///
- ///
- /// The container.
- ///
- public string Container { get; private set; }
-
- public StatType StatType { get; private set; }
-
- ///
- /// Action used to update this stat when the value is requested if it's a pull type.
- ///
- public Action PullAction { get; private set; }
-
- public StatVerbosity Verbosity { get; private set; }
- public string ShortName { get; private set; }
- public string Name { get; private set; }
- public string Description { get; private set; }
- public virtual string UnitName { get; private set; }
-
- public virtual double Value
- {
- get
- {
- // Asking for an update here means that the updater cannot access this value without infinite recursion.
- // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
- // called by the pull action and just return the value.
- if (StatType == StatType.Pull)
- PullAction(this);
-
- return m_value;
- }
-
- set
- {
- m_value = value;
- }
- }
-
- private double m_value;
-
- ///
- /// Constructor
- ///
- /// Short name for the stat. Must not contain spaces. e.g. "LongFrames"
- /// Human readable name for the stat. e.g. "Long frames"
- /// Description of stat
- ///
- /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value.
- /// e.g. " frames"
- ///
- /// Category under which this stat should appear, e.g. "scene". Do not capitalize.
- /// Entity to which this stat relates. e.g. scene name if this is a per scene stat.
- /// Push or pull
- /// Pull stats need an action to update the stat on request. Push stats should set null here.
- /// Verbosity of stat. Controls whether it will appear in short stat display or only full display.
- public Stat(
- string shortName,
- string name,
- string description,
- string unitName,
- string category,
- string container,
- StatType type,
- Action pullAction,
- StatVerbosity verbosity)
- {
- if (StatsManager.SubCommands.Contains(category))
- throw new Exception(
- string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category));
-
- ShortName = shortName;
- Name = name;
- Description = description;
- UnitName = unitName;
- Category = category;
- Container = container;
- StatType = type;
-
- if (StatType == StatType.Push && pullAction != null)
- throw new Exception("A push stat cannot have a pull action");
- else
- PullAction = pullAction;
-
- Verbosity = verbosity;
- }
-
- public virtual string ToConsoleString()
- {
- return string.Format(
- "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName);
- }
- }
-
- public class PercentageStat : Stat
- {
- public int Antecedent { get; set; }
- public int Consequent { get; set; }
-
- public override double Value
- {
- get
- {
- int c = Consequent;
-
- // Avoid any chance of a multi-threaded divide-by-zero
- if (c == 0)
- return 0;
-
- return (double)Antecedent / c * 100;
- }
-
- set
- {
- throw new Exception("Cannot set value on a PercentageStat");
- }
- }
-
- public PercentageStat(
- string shortName,
- string name,
- string description,
- string category,
- string container,
- StatType type,
- Action pullAction,
- StatVerbosity verbosity)
- : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {}
-
- public override string ToConsoleString()
- {
- return string.Format(
- "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})",
- Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
- }
}
}
\ No newline at end of file
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index 28d6d5c..b709baa 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -89,17 +89,6 @@ namespace OpenSim.Framework.Monitoring
FirstTick = Environment.TickCount & Int32.MaxValue;
LastTick = FirstTick;
}
-
- public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi)
- {
- Thread = previousTwi.Thread;
- FirstTick = previousTwi.FirstTick;
- LastTick = previousTwi.LastTick;
- Timeout = previousTwi.Timeout;
- IsTimedOut = previousTwi.IsTimedOut;
- AlarmIfTimeout = previousTwi.AlarmIfTimeout;
- AlarmMethod = previousTwi.AlarmMethod;
- }
}
///
@@ -231,25 +220,7 @@ namespace OpenSim.Framework.Monitoring
private static bool RemoveThread(int threadID)
{
lock (m_threads)
- {
- ThreadWatchdogInfo twi;
- if (m_threads.TryGetValue(threadID, out twi))
- {
- m_log.DebugFormat(
- "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId);
-
- m_threads.Remove(threadID);
-
- return true;
- }
- else
- {
- m_log.WarnFormat(
- "[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID);
-
- return false;
- }
- }
+ return m_threads.Remove(threadID);
}
public static bool AbortThread(int threadID)
@@ -364,9 +335,7 @@ namespace OpenSim.Framework.Monitoring
if (callbackInfos == null)
callbackInfos = new List();
- // Send a copy of the watchdog info to prevent race conditions where the watchdog
- // thread updates the monitoring info after an alarm has been sent out.
- callbackInfos.Add(new ThreadWatchdogInfo(threadInfo));
+ callbackInfos.Add(threadInfo);
}
}
}
--
cgit v1.1