aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-31 01:52:26 +0100
committerJustin Clark-Casey (justincc)2012-05-31 01:52:26 +0100
commit0b02a4d42e989609a4e1ba39d2aee9a7f9655613 (patch)
tree353e05997fb8478cb6b3691edc943604e5dd78ff /OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
parentAdd console command "teleport user" to allow teleport from the region console (diff)
downloadopensim-SC-0b02a4d42e989609a4e1ba39d2aee9a7f9655613.zip
opensim-SC-0b02a4d42e989609a4e1ba39d2aee9a7f9655613.tar.gz
opensim-SC-0b02a4d42e989609a4e1ba39d2aee9a7f9655613.tar.bz2
opensim-SC-0b02a4d42e989609a4e1ba39d2aee9a7f9655613.tar.xz
Add an optional mechanism for physics modules to collect and return arbitrary stats.
If active, the physics module can return arbitrary stat counters that can be seen via the MonitoringModule (http://opensimulator.org/wiki/Monitoring_Module) This is only active in OdeScene if collect_stats = true in [ODEPhysicsSettings]. This patch allows OdeScene to collect elapsed time information for calls to the ODE native collision methods to assess what proportion of time this takes compared to total physics processing. This data is returned as ODENativeCollisionFrameMS in the monitoring module, updated every 3 seconds. The performance effect of collecting stats is probably extremely minor, dwarfed by the rest of the physics code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs48
1 files changed, 43 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 5c56264..08d8d7c 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -26,7 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29//using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Timers; 30using System.Timers;
31using OpenMetaverse.Packets; 31using OpenMetaverse.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
@@ -35,10 +35,18 @@ using OpenSim.Region.Framework.Interfaces;
35 35
36namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
37{ 37{
38 /// <summary>
39 /// Collect statistics from the scene to send to the client and for access by other monitoring tools.
40 /// </summary>
41 /// <remarks>
42 /// FIXME: This should be a monitoring region module
43 /// </remarks>
38 public class SimStatsReporter 44 public class SimStatsReporter
39 { 45 {
40// private static readonly log4net.ILog m_log 46 private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 47 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48
49 public const string LastReportedObjectUpdateStatName = "LastReportedObjectUpdates";
42 50
43 public delegate void SendStatResult(SimStats stats); 51 public delegate void SendStatResult(SimStats stats);
44 52
@@ -100,6 +108,14 @@ namespace OpenSim.Region.Framework.Scenes
100 get { return lastReportedSimStats; } 108 get { return lastReportedSimStats; }
101 } 109 }
102 110
111 /// <summary>
112 /// Extra sim statistics that are used by monitors but not sent to the client.
113 /// </summary>
114 /// <value>
115 /// The keys are the stat names.
116 /// </value>
117 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
118
103 // Sending a stats update every 3 seconds- 119 // Sending a stats update every 3 seconds-
104 private int statsUpdatesEveryMS = 3000; 120 private int statsUpdatesEveryMS = 3000;
105 private float statsUpdateFactor = 0; 121 private float statsUpdateFactor = 0;
@@ -334,7 +350,20 @@ namespace OpenSim.Region.Framework.Scenes
334 } 350 }
335 351
336 // Extra statistics that aren't currently sent to clients 352 // Extra statistics that aren't currently sent to clients
337 LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor; 353 lock (m_lastReportedExtraSimStats)
354 {
355 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / statsUpdateFactor;
356
357 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
358
359 if (physicsStats != null)
360 {
361 foreach (KeyValuePair<string, float> tuple in physicsStats)
362 {
363 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / statsUpdateFactor;
364 }
365 }
366 }
338 367
339 resetvalues(); 368 resetvalues();
340 } 369 }
@@ -487,7 +516,10 @@ namespace OpenSim.Region.Framework.Scenes
487 public void AddPendingDownloads(int count) 516 public void AddPendingDownloads(int count)
488 { 517 {
489 m_pendingDownloads += count; 518 m_pendingDownloads += count;
490 if (m_pendingDownloads < 0) m_pendingDownloads = 0; 519
520 if (m_pendingDownloads < 0)
521 m_pendingDownloads = 0;
522
491 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); 523 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
492 } 524 }
493 525
@@ -509,5 +541,11 @@ namespace OpenSim.Region.Framework.Scenes
509 } 541 }
510 542
511 #endregion 543 #endregion
544
545 public Dictionary<string, float> GetExtraSimStats()
546 {
547 lock (m_lastReportedExtraSimStats)
548 return new Dictionary<string, float>(m_lastReportedExtraSimStats);
549 }
512 } 550 }
513} 551}