aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs94
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs214
3 files changed, 159 insertions, 151 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 7688cf8..76a952b 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -947,7 +947,7 @@ namespace OpenSim.Region.Framework.Scenes
947 OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; 947 OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted;
948 if (handlerTerrainTainted != null) 948 if (handlerTerrainTainted != null)
949 { 949 {
950 foreach (OnTerrainTickDelegate d in handlerTerrainTainted.GetInvocationList()) 950 foreach (OnTerrainTaintedDelegate d in handlerTerrainTainted.GetInvocationList())
951 { 951 {
952 try 952 try
953 { 953 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index b79892d..315b340 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -222,6 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
222 private int backupMS; 222 private int backupMS;
223 private int terrainMS; 223 private int terrainMS;
224 private int landMS; 224 private int landMS;
225 private int spareMS;
225 226
226 /// <summary> 227 /// <summary>
227 /// Tick at which the last frame was processed. 228 /// Tick at which the last frame was processed.
@@ -1408,45 +1409,41 @@ namespace OpenSim.Region.Framework.Scenes
1408 endFrame = Frame + frames; 1409 endFrame = Frame + frames;
1409 1410
1410 float physicsFPS = 0f; 1411 float physicsFPS = 0f;
1411 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1412 int previousFrameTick, tmpMS;
1412 int previousFrameTick; 1413 int maintc = Util.EnvironmentTickCount();
1413 int maintc;
1414 int sleepMS;
1415 int framestart;
1416 1414
1417 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1415 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1418 { 1416 {
1419 framestart = Util.EnvironmentTickCount();
1420 ++Frame; 1417 ++Frame;
1421 1418
1422// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1419// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1423 1420
1424 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1421 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1425 1422
1426 try 1423 try
1427 { 1424 {
1428 // Apply taints in terrain module to terrain in physics scene 1425 // Apply taints in terrain module to terrain in physics scene
1429 if (Frame % m_update_terrain == 0) 1426 if (Frame % m_update_terrain == 0)
1430 { 1427 {
1431 terMS = Util.EnvironmentTickCount(); 1428 tmpMS = Util.EnvironmentTickCount();
1432 UpdateTerrain(); 1429 UpdateTerrain();
1433 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1430 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1434 } 1431 }
1435 1432
1436 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1433 tmpMS = Util.EnvironmentTickCount();
1437 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1434 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1438 m_sceneGraph.UpdatePreparePhysics(); 1435 m_sceneGraph.UpdatePreparePhysics();
1439 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1436 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1440 1437
1441 // Apply any pending avatar force input to the avatar's velocity 1438 // Apply any pending avatar force input to the avatar's velocity
1442 tmpAgentMS = Util.EnvironmentTickCount(); 1439 tmpMS = Util.EnvironmentTickCount();
1443 if (Frame % m_update_entitymovement == 0) 1440 if (Frame % m_update_entitymovement == 0)
1444 m_sceneGraph.UpdateScenePresenceMovement(); 1441 m_sceneGraph.UpdateScenePresenceMovement();
1445 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1442 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1446 1443
1447 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1444 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1448 // velocity 1445 // velocity
1449 tmpPhysicsMS = Util.EnvironmentTickCount(); 1446 tmpMS = Util.EnvironmentTickCount();
1450 if (Frame % m_update_physics == 0) 1447 if (Frame % m_update_physics == 0)
1451 { 1448 {
1452 if (m_physics_enabled) 1449 if (m_physics_enabled)
@@ -1455,9 +1452,9 @@ namespace OpenSim.Region.Framework.Scenes
1455 if (SynchronizeScene != null) 1452 if (SynchronizeScene != null)
1456 SynchronizeScene(this); 1453 SynchronizeScene(this);
1457 } 1454 }
1458 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1455 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1459 1456
1460 tmpAgentMS = Util.EnvironmentTickCount(); 1457 tmpMS = Util.EnvironmentTickCount();
1461 1458
1462 // Check if any objects have reached their targets 1459 // Check if any objects have reached their targets
1463 CheckAtTargets(); 1460 CheckAtTargets();
@@ -1472,29 +1469,29 @@ namespace OpenSim.Region.Framework.Scenes
1472 if (Frame % m_update_presences == 0) 1469 if (Frame % m_update_presences == 0)
1473 m_sceneGraph.UpdatePresences(); 1470 m_sceneGraph.UpdatePresences();
1474 1471
1475 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1472 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1476 1473
1477 // Delete temp-on-rez stuff 1474 // Delete temp-on-rez stuff
1478 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1475 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1479 { 1476 {
1480 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1477 tmpMS = Util.EnvironmentTickCount();
1481 m_cleaningTemps = true; 1478 m_cleaningTemps = true;
1482 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1479 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1483 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1480 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1484 } 1481 }
1485 1482
1486 if (Frame % m_update_events == 0) 1483 if (Frame % m_update_events == 0)
1487 { 1484 {
1488 evMS = Util.EnvironmentTickCount(); 1485 tmpMS = Util.EnvironmentTickCount();
1489 UpdateEvents(); 1486 UpdateEvents();
1490 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1487 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1491 } 1488 }
1492 1489
1493 if (Frame % m_update_backup == 0) 1490 if (Frame % m_update_backup == 0)
1494 { 1491 {
1495 backMS = Util.EnvironmentTickCount(); 1492 tmpMS = Util.EnvironmentTickCount();
1496 UpdateStorageBackup(); 1493 UpdateStorageBackup();
1497 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1494 backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
1498 } 1495 }
1499 1496
1500 //if (Frame % m_update_land == 0) 1497 //if (Frame % m_update_land == 0)
@@ -1503,24 +1500,6 @@ namespace OpenSim.Region.Framework.Scenes
1503 // UpdateLand(); 1500 // UpdateLand();
1504 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1501 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1505 //} 1502 //}
1506
1507 // frameMS = Util.EnvironmentTickCountSubtract(maintc);
1508 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1509
1510 // if (Frame%m_update_avatars == 0)
1511 // UpdateInWorldTime();
1512 StatsReporter.AddPhysicsFPS(physicsFPS);
1513 StatsReporter.AddTimeDilation(TimeDilation);
1514 StatsReporter.AddFPS(1);
1515
1516 // frameMS currently records work frame times, not total frame times (work + any required sleep to
1517 // reach min frame time.
1518 // StatsReporter.addFrameMS(frameMS);
1519
1520 StatsReporter.addAgentMS(agentMS);
1521 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1522 StatsReporter.addOtherMS(otherMS);
1523 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1524 1503
1525 if (LoginsDisabled && Frame == 20) 1504 if (LoginsDisabled && Frame == 20)
1526 { 1505 {
@@ -1571,23 +1550,36 @@ namespace OpenSim.Region.Framework.Scenes
1571 1550
1572 previousFrameTick = m_lastFrameTick; 1551 previousFrameTick = m_lastFrameTick;
1573 m_lastFrameTick = Util.EnvironmentTickCount(); 1552 m_lastFrameTick = Util.EnvironmentTickCount();
1574 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1553 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1575 maintc = (int)(MinFrameTime * 1000) - maintc; 1554 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1576 1555
1577 m_firstHeartbeat = false; 1556 m_firstHeartbeat = false;
1578 1557
1558 if (tmpMS > 0)
1559 {
1560 Thread.Sleep(tmpMS);
1561 spareMS += tmpMS;
1562 }
1563
1564 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1565 maintc = Util.EnvironmentTickCount();
1579 1566
1580 sleepMS = Util.EnvironmentTickCount(); 1567 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1581 1568
1582 if (maintc > 0) 1569 // if (Frame%m_update_avatars == 0)
1583 Thread.Sleep(maintc); 1570 // UpdateInWorldTime();
1571 StatsReporter.AddPhysicsFPS(physicsFPS);
1572 StatsReporter.AddTimeDilation(TimeDilation);
1573 StatsReporter.AddFPS(1);
1584 1574
1585 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1586 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1587 StatsReporter.addSleepMS(sleepMS);
1588 StatsReporter.addFrameMS(frameMS); 1575 StatsReporter.addFrameMS(frameMS);
1589 1576 StatsReporter.addAgentMS(agentMS);
1590 // Optionally warn if a frame takes double the amount of time that it should. 1577 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1578 StatsReporter.addOtherMS(otherMS);
1579 StatsReporter.AddSpareMS(spareMS);
1580 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1581
1582 // Optionally warn if a frame takes double the amount of time that it should.
1591 if (DebugUpdates 1583 if (DebugUpdates
1592 && Util.EnvironmentTickCountSubtract( 1584 && Util.EnvironmentTickCountSubtract(
1593 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1585 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 0efe4c4..18e6ece 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -56,10 +56,17 @@ namespace OpenSim.Region.Framework.Scenes
56 56
57 public event YourStatsAreWrong OnStatsIncorrect; 57 public event YourStatsAreWrong OnStatsIncorrect;
58 58
59 private SendStatResult handlerSendStatResult = null; 59 private SendStatResult handlerSendStatResult;
60 60
61 private YourStatsAreWrong handlerStatsIncorrect = null; 61 private YourStatsAreWrong handlerStatsIncorrect;
62 62
63 /// <summary>
64 /// These are the IDs of stats sent in the StatsPacket to the viewer.
65 /// </summary>
66 /// <remarks>
67 /// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators
68 /// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky).
69 /// </remarks>
63 public enum Stats : uint 70 public enum Stats : uint
64 { 71 {
65 TimeDilation = 0, 72 TimeDilation = 0,
@@ -83,20 +90,20 @@ namespace OpenSim.Region.Framework.Scenes
83 OutPacketsPerSecond = 18, 90 OutPacketsPerSecond = 18,
84 PendingDownloads = 19, 91 PendingDownloads = 19,
85 PendingUploads = 20, 92 PendingUploads = 20,
86 VirtualSizeKB = 21, 93 VirtualSizeKb = 21,
87 ResidentSizeKB = 22, 94 ResidentSizeKb = 22,
88 PendingLocalUploads = 23, 95 PendingLocalUploads = 23,
89 UnAckedBytes = 24, 96 UnAckedBytes = 24,
90 PhysicsPinnedTasks = 25, 97 PhysicsPinnedTasks = 25,
91 PhysicsLODTasks = 26, 98 PhysicsLodTasks = 26,
92 PhysicsStepMS = 27, 99 SimPhysicsStepMs = 27,
93 PhysicsShapeMS = 28, 100 SimPhysicsShapeMs = 28,
94 PhysicsOtherMS = 29, 101 SimPhysicsOtherMs = 29,
95 PhysicsMemory = 30, 102 SimPhysicsMemory = 30,
96 ScriptEPS = 31, 103 ScriptEps = 31,
97 SimSpareTime = 32, 104 SimSpareMs = 32,
98 SimSleepTime = 33, 105 SimSleepMs = 33,
99 IOPumpTime = 34 106 SimIoPumpTime = 34
100 } 107 }
101 108
102 /// <summary> 109 /// <summary>
@@ -130,10 +137,15 @@ namespace OpenSim.Region.Framework.Scenes
130 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>(); 137 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
131 138
132 // Sending a stats update every 3 seconds- 139 // Sending a stats update every 3 seconds-
133 private int statsUpdatesEveryMS = 3000; 140 private int m_statsUpdatesEveryMS = 3000;
134 private float statsUpdateFactor = 0; 141 private float m_statsUpdateFactor;
135 private float m_timeDilation = 0; 142 private float m_timeDilation;
136 private int m_fps = 0; 143 private int m_fps;
144
145 /// <summary>
146 /// Number of the last frame on which we processed a stats udpate.
147 /// </summary>
148 private uint m_lastUpdateFrame;
137 149
138 /// <summary> 150 /// <summary>
139 /// Our nominal fps target, as expected in fps stats when a sim is running normally. 151 /// Our nominal fps target, as expected in fps stats when a sim is running normally.
@@ -151,43 +163,42 @@ namespace OpenSim.Region.Framework.Scenes
151 private float m_reportedFpsCorrectionFactor = 5; 163 private float m_reportedFpsCorrectionFactor = 5;
152 164
153 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
154 private float lastReportedSimFPS = 0; 166 private float lastReportedSimFPS;
155 private float[] lastReportedSimStats = new float[23]; 167 private float[] lastReportedSimStats = new float[22];
156 private float m_pfps = 0; 168 private float m_pfps;
157 169
158 /// <summary> 170 /// <summary>
159 /// Number of agent updates requested in this stats cycle 171 /// Number of agent updates requested in this stats cycle
160 /// </summary> 172 /// </summary>
161 private int m_agentUpdates = 0; 173 private int m_agentUpdates;
162 174
163 /// <summary> 175 /// <summary>
164 /// Number of object updates requested in this stats cycle 176 /// Number of object updates requested in this stats cycle
165 /// </summary> 177 /// </summary>
166 private int m_objectUpdates; 178 private int m_objectUpdates;
167 179
168 private int m_frameMS = 0; 180 private int m_frameMS;
169 private int m_netMS = 0; 181 private int m_spareMS;
170 private int m_agentMS = 0; 182 private int m_netMS;
171 private int m_physicsMS = 0; 183 private int m_agentMS;
172 private int m_imageMS = 0; 184 private int m_physicsMS;
173 private int m_otherMS = 0; 185 private int m_imageMS;
174 private int m_sleeptimeMS = 0; 186 private int m_otherMS;
175
176 187
177//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 188//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
178//Ckrinke private int m_scriptMS = 0; 189//Ckrinke private int m_scriptMS = 0;
179 190
180 private int m_rootAgents = 0; 191 private int m_rootAgents;
181 private int m_childAgents = 0; 192 private int m_childAgents;
182 private int m_numPrim = 0; 193 private int m_numPrim;
183 private int m_inPacketsPerSecond = 0; 194 private int m_inPacketsPerSecond;
184 private int m_outPacketsPerSecond = 0; 195 private int m_outPacketsPerSecond;
185 private int m_activePrim = 0; 196 private int m_activePrim;
186 private int m_unAckedBytes = 0; 197 private int m_unAckedBytes;
187 private int m_pendingDownloads = 0; 198 private int m_pendingDownloads;
188 private int m_pendingUploads = 0; 199 private int m_pendingUploads = 0; // FIXME: Not currently filled in
189 private int m_activeScripts = 0; 200 private int m_activeScripts;
190 private int m_scriptLinesPerSecond = 0; 201 private int m_scriptLinesPerSecond;
191 202
192 private int m_objectCapacity = 45000; 203 private int m_objectCapacity = 45000;
193 204
@@ -203,13 +214,13 @@ namespace OpenSim.Region.Framework.Scenes
203 { 214 {
204 m_scene = scene; 215 m_scene = scene;
205 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; 216 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
206 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 217 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
207 ReportingRegion = scene.RegionInfo; 218 ReportingRegion = scene.RegionInfo;
208 219
209 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 220 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
210 m_report.AutoReset = true; 221 m_report.AutoReset = true;
211 m_report.Interval = statsUpdatesEveryMS; 222 m_report.Interval = m_statsUpdatesEveryMS;
212 m_report.Elapsed += statsHeartBeat; 223 m_report.Elapsed += TriggerStatsHeartbeat;
213 m_report.Enabled = true; 224 m_report.Enabled = true;
214 225
215 if (StatsManager.SimExtraStats != null) 226 if (StatsManager.SimExtraStats != null)
@@ -218,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
218 229
219 public void Close() 230 public void Close()
220 { 231 {
221 m_report.Elapsed -= statsHeartBeat; 232 m_report.Elapsed -= TriggerStatsHeartbeat;
222 m_report.Close(); 233 m_report.Close();
223 } 234 }
224 235
@@ -228,14 +239,28 @@ namespace OpenSim.Region.Framework.Scenes
228 /// <param name='ms'></param> 239 /// <param name='ms'></param>
229 public void SetUpdateMS(int ms) 240 public void SetUpdateMS(int ms)
230 { 241 {
231 statsUpdatesEveryMS = ms; 242 m_statsUpdatesEveryMS = ms;
232 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 243 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
233 m_report.Interval = statsUpdatesEveryMS; 244 m_report.Interval = m_statsUpdatesEveryMS;
245 }
246
247 private void TriggerStatsHeartbeat(object sender, EventArgs args)
248 {
249 try
250 {
251 statsHeartBeat(sender, args);
252 }
253 catch (Exception e)
254 {
255 m_log.Warn(string.Format(
256 "[SIM STATS REPORTER] Update for {0} failed with exception ",
257 m_scene.RegionInfo.RegionName), e);
258 }
234 } 259 }
235 260
236 private void statsHeartBeat(object sender, EventArgs e) 261 private void statsHeartBeat(object sender, EventArgs e)
237 { 262 {
238 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; 263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
239 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
240 265
241 // Know what's not thread safe in Mono... modifying timers. 266 // Know what's not thread safe in Mono... modifying timers.
@@ -262,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes
262 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 287 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
263 288
264 // save the reported value so there is something available for llGetRegionFPS 289 // save the reported value so there is something available for llGetRegionFPS
265 lastReportedSimFPS = reportedFPS / statsUpdateFactor; 290 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
266 291
267 float physfps = ((m_pfps / 1000)); 292 float physfps = ((m_pfps / 1000));
268 293
@@ -273,7 +298,6 @@ namespace OpenSim.Region.Framework.Scenes
273 physfps = 0; 298 physfps = 0;
274 299
275#endregion 300#endregion
276 float factor = 1 / statsUpdateFactor;
277 if (reportedFPS <= 0) 301 if (reportedFPS <= 0)
278 reportedFPS = 1; 302 reportedFPS = 1;
279 303
@@ -284,21 +308,9 @@ namespace OpenSim.Region.Framework.Scenes
284 float targetframetime = 1100.0f / (float)m_nominalReportedFps; 308 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
285 309
286 float sparetime; 310 float sparetime;
287 float sleeptime;
288 if (TotalFrameTime > targetframetime) 311 if (TotalFrameTime > targetframetime)
289 { 312 {
290 sparetime = 0; 313 sparetime = 0;
291 sleeptime = 0;
292 }
293 else
294 {
295 sparetime = m_frameMS - m_physicsMS - m_agentMS;
296 sparetime *= perframe;
297 if (sparetime < 0)
298 sparetime = 0;
299 else if (sparetime > TotalFrameTime)
300 sparetime = TotalFrameTime;
301 sleeptime = m_sleeptimeMS * perframe;
302 } 314 }
303 315
304 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 316 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
@@ -315,11 +327,19 @@ namespace OpenSim.Region.Framework.Scenes
315 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; 327 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
316 // m_imageMS m_netMS are not included in m_frameMS 328 // m_imageMS m_netMS are not included in m_frameMS
317 329
318 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; 330 m_otherMS = m_frameMS - m_physicsMS - m_agentMS;
319 if (m_otherMS < 0) 331 if (m_otherMS < 0)
320 m_otherMS = 0; 332 m_otherMS = 0;
321 333
322 for (int i = 0; i < 23; i++) 334 uint thisFrame = m_scene.Frame;
335 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
336 m_lastUpdateFrame = thisFrame;
337
338 // Avoid div-by-zero if somehow we've not updated any frames.
339 if (framesUpdated == 0)
340 framesUpdated = 1;
341
342 for (int i = 0; i < 22; i++)
323 { 343 {
324 sb[i] = new SimStatsPacket.StatBlock(); 344 sb[i] = new SimStatsPacket.StatBlock();
325 } 345 }
@@ -328,13 +348,13 @@ namespace OpenSim.Region.Framework.Scenes
328 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 348 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
329 349
330 sb[1].StatID = (uint) Stats.SimFPS; 350 sb[1].StatID = (uint) Stats.SimFPS;
331 sb[1].StatValue = reportedFPS / statsUpdateFactor; 351 sb[1].StatValue = reportedFPS / m_statsUpdateFactor;
332 352
333 sb[2].StatID = (uint) Stats.PhysicsFPS; 353 sb[2].StatID = (uint) Stats.PhysicsFPS;
334 sb[2].StatValue = physfps / statsUpdateFactor; 354 sb[2].StatValue = physfps / m_statsUpdateFactor;
335 355
336 sb[3].StatID = (uint) Stats.AgentUpdates; 356 sb[3].StatID = (uint) Stats.AgentUpdates;
337 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 357 sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);
338 358
339 sb[4].StatID = (uint) Stats.Agents; 359 sb[4].StatID = (uint) Stats.Agents;
340 sb[4].StatValue = m_rootAgents; 360 sb[4].StatValue = m_rootAgents;
@@ -349,38 +369,31 @@ namespace OpenSim.Region.Framework.Scenes
349 sb[7].StatValue = m_activePrim; 369 sb[7].StatValue = m_activePrim;
350 370
351 sb[8].StatID = (uint)Stats.FrameMS; 371 sb[8].StatID = (uint)Stats.FrameMS;
352 // sb[8].StatValue = m_frameMS / statsUpdateFactor; 372 sb[8].StatValue = m_frameMS / framesUpdated;
353 sb[8].StatValue = TotalFrameTime;
354 373
355 sb[9].StatID = (uint)Stats.NetMS; 374 sb[9].StatID = (uint)Stats.NetMS;
356 // sb[9].StatValue = m_netMS / statsUpdateFactor; 375 sb[9].StatValue = m_netMS / framesUpdated;
357 sb[9].StatValue = m_netMS * perframe;
358 376
359 sb[10].StatID = (uint)Stats.PhysicsMS; 377 sb[10].StatID = (uint)Stats.PhysicsMS;
360 // sb[10].StatValue = m_physicsMS / statsUpdateFactor; 378 sb[10].StatValue = m_physicsMS / framesUpdated;
361 sb[10].StatValue = m_physicsMS * perframe;
362 379
363 sb[11].StatID = (uint)Stats.ImageMS ; 380 sb[11].StatID = (uint)Stats.ImageMS ;
364 // sb[11].StatValue = m_imageMS / statsUpdateFactor; 381 sb[11].StatValue = m_imageMS / framesUpdated;
365 sb[11].StatValue = m_imageMS * perframe;
366 382
367 sb[12].StatID = (uint)Stats.OtherMS; 383 sb[12].StatID = (uint)Stats.OtherMS;
368 // sb[12].StatValue = m_otherMS / statsUpdateFactor; 384 sb[12].StatValue = m_otherMS / framesUpdated;
369 sb[12].StatValue = m_otherMS * perframe;
370
371 385
372 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 386 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
373 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); 387 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
374 388
375 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 389 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
376 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 390 sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);
377 391
378 sb[15].StatID = (uint)Stats.UnAckedBytes; 392 sb[15].StatID = (uint)Stats.UnAckedBytes;
379 sb[15].StatValue = m_unAckedBytes; 393 sb[15].StatValue = m_unAckedBytes;
380 394
381 sb[16].StatID = (uint)Stats.AgentMS; 395 sb[16].StatID = (uint)Stats.AgentMS;
382// sb[16].StatValue = m_agentMS / statsUpdateFactor; 396 sb[16].StatValue = m_agentMS / framesUpdated;
383 sb[16].StatValue = m_agentMS * perframe;
384 397
385 sb[17].StatID = (uint)Stats.PendingDownloads; 398 sb[17].StatID = (uint)Stats.PendingDownloads;
386 sb[17].StatValue = m_pendingDownloads; 399 sb[17].StatValue = m_pendingDownloads;
@@ -392,15 +405,12 @@ namespace OpenSim.Region.Framework.Scenes
392 sb[19].StatValue = m_activeScripts; 405 sb[19].StatValue = m_activeScripts;
393 406
394 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 407 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
395 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 408 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
396 409
397 sb[21].StatID = (uint)Stats.SimSpareTime; 410 sb[21].StatID = (uint)Stats.SimSpareMs;
398 sb[21].StatValue = sparetime; 411 sb[21].StatValue = m_spareMS / framesUpdated;
399 412
400 sb[22].StatID = (uint)Stats.SimSleepTime; 413 for (int i = 0; i < 22; i++)
401 sb[22].StatValue = sleeptime;
402
403 for (int i = 0; i < 23; i++)
404 { 414 {
405 lastReportedSimStats[i] = sb[i].StatValue; 415 lastReportedSimStats[i] = sb[i].StatValue;
406 } 416 }
@@ -419,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes
419 // Extra statistics that aren't currently sent to clients 429 // Extra statistics that aren't currently sent to clients
420 lock (m_lastReportedExtraSimStats) 430 lock (m_lastReportedExtraSimStats)
421 { 431 {
422 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / statsUpdateFactor; 432 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
423 433
424 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); 434 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
425 435
@@ -427,16 +437,22 @@ namespace OpenSim.Region.Framework.Scenes
427 { 437 {
428 foreach (KeyValuePair<string, float> tuple in physicsStats) 438 foreach (KeyValuePair<string, float> tuple in physicsStats)
429 { 439 {
430 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / statsUpdateFactor; 440 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
441 // Need to change things so that stats source can indicate whether they are per second or
442 // per frame.
443 if (tuple.Key.EndsWith("MS"))
444 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
445 else
446 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
431 } 447 }
432 } 448 }
433 } 449 }
434 450
435 resetvalues(); 451 ResetValues();
436 } 452 }
437 } 453 }
438 454
439 private void resetvalues() 455 private void ResetValues()
440 { 456 {
441 m_timeDilation = 0; 457 m_timeDilation = 0;
442 m_fps = 0; 458 m_fps = 0;
@@ -454,7 +470,7 @@ namespace OpenSim.Region.Framework.Scenes
454 m_physicsMS = 0; 470 m_physicsMS = 0;
455 m_imageMS = 0; 471 m_imageMS = 0;
456 m_otherMS = 0; 472 m_otherMS = 0;
457 m_sleeptimeMS = 0; 473 m_spareMS = 0;
458 474
459//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 475//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
460//Ckrinke m_scriptMS = 0; 476//Ckrinke m_scriptMS = 0;
@@ -533,6 +549,11 @@ namespace OpenSim.Region.Framework.Scenes
533 m_frameMS += ms; 549 m_frameMS += ms;
534 } 550 }
535 551
552 public void AddSpareMS(int ms)
553 {
554 m_spareMS += ms;
555 }
556
536 public void addNetMS(int ms) 557 public void addNetMS(int ms)
537 { 558 {
538 m_netMS += ms; 559 m_netMS += ms;
@@ -558,11 +579,6 @@ namespace OpenSim.Region.Framework.Scenes
558 m_otherMS += ms; 579 m_otherMS += ms;
559 } 580 }
560 581
561 public void addSleepMS(int ms)
562 {
563 m_sleeptimeMS += ms;
564 }
565
566 public void AddPendingDownloads(int count) 582 public void AddPendingDownloads(int count)
567 { 583 {
568 m_pendingDownloads += count; 584 m_pendingDownloads += count;