diff options
author | Justin Clark-Casey (justincc) | 2012-10-11 23:28:53 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-11 23:28:53 +0100 |
commit | 1f2472d0fcd86a7ae09c01ecb3508eab001ce033 (patch) | |
tree | 2668a8dc7ede987d1b104292508c311c03a37e59 /OpenSim/Region | |
parent | Assign endVector before control leaves ObjectCommandsModule.TryParseVectorRan... (diff) | |
download | opensim-SC_OLD-1f2472d0fcd86a7ae09c01ecb3508eab001ce033.zip opensim-SC_OLD-1f2472d0fcd86a7ae09c01ecb3508eab001ce033.tar.gz opensim-SC_OLD-1f2472d0fcd86a7ae09c01ecb3508eab001ce033.tar.bz2 opensim-SC_OLD-1f2472d0fcd86a7ae09c01ecb3508eab001ce033.tar.xz |
Extend "show stats" command to "show stats [list|all|<category name>]"
This allows different categories of stats to be shown, with options to list categories or show all stats.
Currently categories are scene and simulator and only a very few stats are currently registered via this mechanism.
This commit also adds percentage stats for packets and blocks reused from the packet pool.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 72 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs | 43 |
2 files changed, 70 insertions, 45 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f784398..4f1b439 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -223,8 +223,6 @@ namespace OpenSim | |||
223 | 223 | ||
224 | base.StartupSpecific(); | 224 | base.StartupSpecific(); |
225 | 225 | ||
226 | m_stats = StatsManager.SimExtraStats; | ||
227 | |||
228 | // Create a ModuleLoader instance | 226 | // Create a ModuleLoader instance |
229 | m_moduleLoader = new ModuleLoader(m_config.Source); | 227 | m_moduleLoader = new ModuleLoader(m_config.Source); |
230 | 228 | ||
@@ -234,51 +232,51 @@ namespace OpenSim | |||
234 | plugin.PostInitialise(); | 232 | plugin.PostInitialise(); |
235 | } | 233 | } |
236 | 234 | ||
237 | AddPluginCommands(); | 235 | if (m_console != null) |
236 | { | ||
237 | StatsManager.RegisterConsoleCommands(m_console); | ||
238 | AddPluginCommands(m_console); | ||
239 | } | ||
238 | } | 240 | } |
239 | 241 | ||
240 | protected virtual void AddPluginCommands() | 242 | protected virtual void AddPluginCommands(CommandConsole console) |
241 | { | 243 | { |
242 | // If console exists add plugin commands. | 244 | List<string> topics = GetHelpTopics(); |
243 | if (m_console != null) | ||
244 | { | ||
245 | List<string> topics = GetHelpTopics(); | ||
246 | 245 | ||
247 | foreach (string topic in topics) | 246 | foreach (string topic in topics) |
248 | { | 247 | { |
249 | string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); | 248 | string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); |
250 | 249 | ||
251 | // This is a hack to allow the user to enter the help command in upper or lowercase. This will go | 250 | // This is a hack to allow the user to enter the help command in upper or lowercase. This will go |
252 | // away at some point. | 251 | // away at some point. |
253 | m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic, | 252 | console.Commands.AddCommand(capitalizedTopic, false, "help " + topic, |
254 | "help " + capitalizedTopic, | 253 | "help " + capitalizedTopic, |
255 | "Get help on plugin command '" + topic + "'", | 254 | "Get help on plugin command '" + topic + "'", |
256 | HandleCommanderHelp); | 255 | HandleCommanderHelp); |
257 | m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, | 256 | console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, |
258 | "help " + capitalizedTopic, | 257 | "help " + capitalizedTopic, |
259 | "Get help on plugin command '" + topic + "'", | 258 | "Get help on plugin command '" + topic + "'", |
260 | HandleCommanderHelp); | 259 | HandleCommanderHelp); |
261 | 260 | ||
262 | ICommander commander = null; | 261 | ICommander commander = null; |
263 | 262 | ||
264 | Scene s = SceneManager.CurrentOrFirstScene; | 263 | Scene s = SceneManager.CurrentOrFirstScene; |
265 | 264 | ||
266 | if (s != null && s.GetCommanders() != null) | 265 | if (s != null && s.GetCommanders() != null) |
267 | { | 266 | { |
268 | if (s.GetCommanders().ContainsKey(topic)) | 267 | if (s.GetCommanders().ContainsKey(topic)) |
269 | commander = s.GetCommanders()[topic]; | 268 | commander = s.GetCommanders()[topic]; |
270 | } | 269 | } |
271 | 270 | ||
272 | if (commander == null) | 271 | if (commander == null) |
273 | continue; | 272 | continue; |
274 | 273 | ||
275 | foreach (string command in commander.Commands.Keys) | 274 | foreach (string command in commander.Commands.Keys) |
276 | { | 275 | { |
277 | m_console.Commands.AddCommand(capitalizedTopic, false, | 276 | console.Commands.AddCommand(capitalizedTopic, false, |
278 | topic + " " + command, | 277 | topic + " " + command, |
279 | topic + " " + commander.Commands[command].ShortHelp(), | 278 | topic + " " + commander.Commands[command].ShortHelp(), |
280 | String.Empty, HandleCommanderCommand); | 279 | String.Empty, HandleCommanderCommand); |
281 | } | ||
282 | } | 280 | } |
283 | } | 281 | } |
284 | } | 282 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs index fc9406b..3d9f94f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework.Monitoring; | ||
34 | 35 | ||
35 | namespace OpenSim.Region.ClientStack.LindenUDP | 36 | namespace OpenSim.Region.ClientStack.LindenUDP |
36 | { | 37 | { |
@@ -43,17 +44,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
43 | private bool packetPoolEnabled = true; | 44 | private bool packetPoolEnabled = true; |
44 | private bool dataBlockPoolEnabled = true; | 45 | private bool dataBlockPoolEnabled = true; |
45 | 46 | ||
47 | private PercentageStat m_packetsReusedStat = new PercentageStat( | ||
48 | "PacketsReused", | ||
49 | "Packets reused", | ||
50 | "simulator", | ||
51 | "simulator", | ||
52 | StatVerbosity.Debug, | ||
53 | "Number of packets reused out of all requests to the packet pool"); | ||
54 | |||
55 | private PercentageStat m_blocksReusedStat = new PercentageStat( | ||
56 | "BlocksReused", | ||
57 | "Blocks reused", | ||
58 | "simulator", | ||
59 | "simulator", | ||
60 | StatVerbosity.Debug, | ||
61 | "Number of data blocks reused out of all requests to the packet pool"); | ||
62 | |||
46 | /// <summary> | 63 | /// <summary> |
47 | /// Pool of packets available for reuse. | 64 | /// Pool of packets available for reuse. |
48 | /// </summary> | 65 | /// </summary> |
49 | private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); | 66 | private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); |
50 | 67 | ||
51 | private static Dictionary<Type, Stack<Object>> DataBlocks = | 68 | private static Dictionary<Type, Stack<Object>> DataBlocks = new Dictionary<Type, Stack<Object>>(); |
52 | new Dictionary<Type, Stack<Object>>(); | ||
53 | |||
54 | static PacketPool() | ||
55 | { | ||
56 | } | ||
57 | 69 | ||
58 | public static PacketPool Instance | 70 | public static PacketPool Instance |
59 | { | 71 | { |
@@ -72,8 +84,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
72 | get { return dataBlockPoolEnabled; } | 84 | get { return dataBlockPoolEnabled; } |
73 | } | 85 | } |
74 | 86 | ||
87 | private PacketPool() | ||
88 | { | ||
89 | StatsManager.RegisterStat(m_packetsReusedStat); | ||
90 | StatsManager.RegisterStat(m_blocksReusedStat); | ||
91 | } | ||
92 | |||
75 | public Packet GetPacket(PacketType type) | 93 | public Packet GetPacket(PacketType type) |
76 | { | 94 | { |
95 | m_packetsReusedStat.Consequent++; | ||
96 | |||
77 | Packet packet; | 97 | Packet packet; |
78 | 98 | ||
79 | if (!packetPoolEnabled) | 99 | if (!packetPoolEnabled) |
@@ -89,6 +109,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
89 | else | 109 | else |
90 | { | 110 | { |
91 | // Recycle old packages | 111 | // Recycle old packages |
112 | m_packetsReusedStat.Antecedent++; | ||
113 | |||
92 | packet = (pool[type]).Pop(); | 114 | packet = (pool[type]).Pop(); |
93 | } | 115 | } |
94 | } | 116 | } |
@@ -211,16 +233,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
211 | } | 233 | } |
212 | } | 234 | } |
213 | 235 | ||
214 | public static T GetDataBlock<T>() where T: new() | 236 | public T GetDataBlock<T>() where T: new() |
215 | { | 237 | { |
216 | lock (DataBlocks) | 238 | lock (DataBlocks) |
217 | { | 239 | { |
240 | m_blocksReusedStat.Consequent++; | ||
241 | |||
218 | Stack<Object> s; | 242 | Stack<Object> s; |
219 | 243 | ||
220 | if (DataBlocks.TryGetValue(typeof(T), out s)) | 244 | if (DataBlocks.TryGetValue(typeof(T), out s)) |
221 | { | 245 | { |
222 | if (s.Count > 0) | 246 | if (s.Count > 0) |
247 | { | ||
248 | m_blocksReusedStat.Antecedent++; | ||
223 | return (T)s.Pop(); | 249 | return (T)s.Pop(); |
250 | } | ||
224 | } | 251 | } |
225 | else | 252 | else |
226 | { | 253 | { |
@@ -231,7 +258,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
231 | } | 258 | } |
232 | } | 259 | } |
233 | 260 | ||
234 | public static void ReturnDataBlock<T>(T block) where T: new() | 261 | public void ReturnDataBlock<T>(T block) where T: new() |
235 | { | 262 | { |
236 | if (block == null) | 263 | if (block == null) |
237 | return; | 264 | return; |