aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-05 00:17:55 +0100
committerJustin Clark-Casey (justincc)2012-06-05 00:17:55 +0100
commit655625ab872659cd8aff1fe5b11dc568c91aee6d (patch)
treec531af096c55b9d37b555b5ee5b81838762b641e /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-655625ab872659cd8aff1fe5b11dc568c91aee6d.zip
opensim-SC_OLD-655625ab872659cd8aff1fe5b11dc568c91aee6d.tar.gz
opensim-SC_OLD-655625ab872659cd8aff1fe5b11dc568c91aee6d.tar.bz2
opensim-SC_OLD-655625ab872659cd8aff1fe5b11dc568c91aee6d.tar.xz
Start sending spare frame time MS viewer stat. Make frame time correctly display total frame time, not just non-spare time.
This makes it easier to see when components of frame time exceed normal permitted frame time. Currently reflect scene frame times.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs90
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs112
2 files changed, 124 insertions, 78 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 702e322..ae35cb9 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -219,6 +219,7 @@ namespace OpenSim.Region.Framework.Scenes
219 private int backupMS; 219 private int backupMS;
220 private int terrainMS; 220 private int terrainMS;
221 private int landMS; 221 private int landMS;
222 private int spareMS;
222 223
223 /// <summary> 224 /// <summary>
224 /// Tick at which the last frame was processed. 225 /// Tick at which the last frame was processed.
@@ -1360,43 +1361,41 @@ namespace OpenSim.Region.Framework.Scenes
1360 endFrame = Frame + frames; 1361 endFrame = Frame + frames;
1361 1362
1362 float physicsFPS = 0f; 1363 float physicsFPS = 0f;
1363 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1364 int previousFrameTick, tmpMS;
1364 int previousFrameTick; 1365 int maintc = Util.EnvironmentTickCount();
1365 int maintc;
1366 1366
1367 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1367 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1368 { 1368 {
1369 maintc = Util.EnvironmentTickCount();
1370 ++Frame; 1369 ++Frame;
1371 1370
1372// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1371// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1373 1372
1374 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1373 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1375 1374
1376 try 1375 try
1377 { 1376 {
1378 // Apply taints in terrain module to terrain in physics scene 1377 // Apply taints in terrain module to terrain in physics scene
1379 if (Frame % m_update_terrain == 0) 1378 if (Frame % m_update_terrain == 0)
1380 { 1379 {
1381 terMS = Util.EnvironmentTickCount(); 1380 tmpMS = Util.EnvironmentTickCount();
1382 UpdateTerrain(); 1381 UpdateTerrain();
1383 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1382 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1384 } 1383 }
1385 1384
1386 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1385 tmpMS = Util.EnvironmentTickCount();
1387 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1386 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1388 m_sceneGraph.UpdatePreparePhysics(); 1387 m_sceneGraph.UpdatePreparePhysics();
1389 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1388 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1390 1389
1391 // Apply any pending avatar force input to the avatar's velocity 1390 // Apply any pending avatar force input to the avatar's velocity
1392 tmpAgentMS = Util.EnvironmentTickCount(); 1391 tmpMS = Util.EnvironmentTickCount();
1393 if (Frame % m_update_entitymovement == 0) 1392 if (Frame % m_update_entitymovement == 0)
1394 m_sceneGraph.UpdateScenePresenceMovement(); 1393 m_sceneGraph.UpdateScenePresenceMovement();
1395 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1394 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1396 1395
1397 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1396 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1398 // velocity 1397 // velocity
1399 tmpPhysicsMS = Util.EnvironmentTickCount(); 1398 tmpMS = Util.EnvironmentTickCount();
1400 if (Frame % m_update_physics == 0) 1399 if (Frame % m_update_physics == 0)
1401 { 1400 {
1402 if (m_physics_enabled) 1401 if (m_physics_enabled)
@@ -1405,9 +1404,9 @@ namespace OpenSim.Region.Framework.Scenes
1405 if (SynchronizeScene != null) 1404 if (SynchronizeScene != null)
1406 SynchronizeScene(this); 1405 SynchronizeScene(this);
1407 } 1406 }
1408 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1407 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1409 1408
1410 tmpAgentMS = Util.EnvironmentTickCount(); 1409 tmpMS = Util.EnvironmentTickCount();
1411 1410
1412 // Check if any objects have reached their targets 1411 // Check if any objects have reached their targets
1413 CheckAtTargets(); 1412 CheckAtTargets();
@@ -1422,29 +1421,29 @@ namespace OpenSim.Region.Framework.Scenes
1422 if (Frame % m_update_presences == 0) 1421 if (Frame % m_update_presences == 0)
1423 m_sceneGraph.UpdatePresences(); 1422 m_sceneGraph.UpdatePresences();
1424 1423
1425 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1424 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1426 1425
1427 // Delete temp-on-rez stuff 1426 // Delete temp-on-rez stuff
1428 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1427 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1429 { 1428 {
1430 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1429 tmpMS = Util.EnvironmentTickCount();
1431 m_cleaningTemps = true; 1430 m_cleaningTemps = true;
1432 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1431 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1433 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1432 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1434 } 1433 }
1435 1434
1436 if (Frame % m_update_events == 0) 1435 if (Frame % m_update_events == 0)
1437 { 1436 {
1438 evMS = Util.EnvironmentTickCount(); 1437 tmpMS = Util.EnvironmentTickCount();
1439 UpdateEvents(); 1438 UpdateEvents();
1440 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1439 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1441 } 1440 }
1442 1441
1443 if (Frame % m_update_backup == 0) 1442 if (Frame % m_update_backup == 0)
1444 { 1443 {
1445 backMS = Util.EnvironmentTickCount(); 1444 tmpMS = Util.EnvironmentTickCount();
1446 UpdateStorageBackup(); 1445 UpdateStorageBackup();
1447 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1446 backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
1448 } 1447 }
1449 1448
1450 //if (Frame % m_update_land == 0) 1449 //if (Frame % m_update_land == 0)
@@ -1453,24 +1452,6 @@ namespace OpenSim.Region.Framework.Scenes
1453 // UpdateLand(); 1452 // UpdateLand();
1454 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1453 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1455 //} 1454 //}
1456
1457 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1458 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1459
1460 // if (Frame%m_update_avatars == 0)
1461 // UpdateInWorldTime();
1462 StatsReporter.AddPhysicsFPS(physicsFPS);
1463 StatsReporter.AddTimeDilation(TimeDilation);
1464 StatsReporter.AddFPS(1);
1465
1466 // frameMS currently records work frame times, not total frame times (work + any required sleep to
1467 // reach min frame time.
1468 StatsReporter.addFrameMS(frameMS);
1469
1470 StatsReporter.addAgentMS(agentMS);
1471 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1472 StatsReporter.addOtherMS(otherMS);
1473 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1474 1455
1475 if (LoginsDisabled && Frame == 20) 1456 if (LoginsDisabled && Frame == 20)
1476 { 1457 {
@@ -1521,13 +1502,34 @@ namespace OpenSim.Region.Framework.Scenes
1521 1502
1522 previousFrameTick = m_lastFrameTick; 1503 previousFrameTick = m_lastFrameTick;
1523 m_lastFrameTick = Util.EnvironmentTickCount(); 1504 m_lastFrameTick = Util.EnvironmentTickCount();
1524 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1505 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1525 maintc = (int)(MinFrameTime * 1000) - maintc; 1506 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1526 1507
1527 if (maintc > 0) 1508 if (tmpMS > 0)
1528 Thread.Sleep(maintc); 1509 {
1510 Thread.Sleep(tmpMS);
1511 spareMS += tmpMS;
1512 }
1529 1513
1530 // Optionally warn if a frame takes double the amount of time that it should. 1514 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1515 maintc = Util.EnvironmentTickCount();
1516
1517 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1518
1519 // if (Frame%m_update_avatars == 0)
1520 // UpdateInWorldTime();
1521 StatsReporter.AddPhysicsFPS(physicsFPS);
1522 StatsReporter.AddTimeDilation(TimeDilation);
1523 StatsReporter.AddFPS(1);
1524
1525 StatsReporter.addFrameMS(frameMS);
1526 StatsReporter.addAgentMS(agentMS);
1527 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1528 StatsReporter.addOtherMS(otherMS);
1529 StatsReporter.AddSpareMS(spareMS);
1530 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1531
1532 // Optionally warn if a frame takes double the amount of time that it should.
1531 if (DebugUpdates 1533 if (DebugUpdates
1532 && Util.EnvironmentTickCountSubtract( 1534 && Util.EnvironmentTickCountSubtract(
1533 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1535 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 11c321b..88e0b05 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,7 +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,
93 VirtualSizeKb = 21,
94 ResidentSizeKb = 22,
95 PendingLocalUploads = 23,
86 UnAckedBytes = 24, 96 UnAckedBytes = 24,
97 PhysicsPinnedTasks = 25,
98 PhysicsLodTasks = 26,
99 SimPhysicsStepMs = 27,
100 SimPhysicsShapeMs = 28,
101 SimPhysicsOtherMs = 29,
102 SimPhysicsMemory = 30,
103 ScriptEps = 31,
104 SimSpareMs = 32,
105 SimSleepMs = 33,
106 SimIoPumpTime = 34
87 } 107 }
88 108
89 /// <summary> 109 /// <summary>
@@ -118,9 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
118 138
119 // Sending a stats update every 3 seconds- 139 // Sending a stats update every 3 seconds-
120 private int m_statsUpdatesEveryMS = 3000; 140 private int m_statsUpdatesEveryMS = 3000;
121 private float m_statsUpdateFactor = 0; 141 private float m_statsUpdateFactor;
122 private float m_timeDilation = 0; 142 private float m_timeDilation;
123 private int m_fps = 0; 143 private int m_fps;
124 144
125 /// <summary> 145 /// <summary>
126 /// Number of the last frame on which we processed a stats udpate. 146 /// Number of the last frame on which we processed a stats udpate.
@@ -143,41 +163,42 @@ namespace OpenSim.Region.Framework.Scenes
143 private float m_reportedFpsCorrectionFactor = 5; 163 private float m_reportedFpsCorrectionFactor = 5;
144 164
145 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
146 private float lastReportedSimFPS = 0; 166 private float lastReportedSimFPS;
147 private float[] lastReportedSimStats = new float[21]; 167 private float[] lastReportedSimStats = new float[22];
148 private float m_pfps = 0; 168 private float m_pfps;
149 169
150 /// <summary> 170 /// <summary>
151 /// Number of agent updates requested in this stats cycle 171 /// Number of agent updates requested in this stats cycle
152 /// </summary> 172 /// </summary>
153 private int m_agentUpdates = 0; 173 private int m_agentUpdates;
154 174
155 /// <summary> 175 /// <summary>
156 /// Number of object updates requested in this stats cycle 176 /// Number of object updates requested in this stats cycle
157 /// </summary> 177 /// </summary>
158 private int m_objectUpdates; 178 private int m_objectUpdates;
159 179
160 private int m_frameMS = 0; 180 private int m_frameMS;
161 private int m_netMS = 0; 181 private int m_spareMS;
162 private int m_agentMS = 0; 182 private int m_netMS;
163 private int m_physicsMS = 0; 183 private int m_agentMS;
164 private int m_imageMS = 0; 184 private int m_physicsMS;
165 private int m_otherMS = 0; 185 private int m_imageMS;
186 private int m_otherMS;
166 187
167//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.
168//Ckrinke private int m_scriptMS = 0; 189//Ckrinke private int m_scriptMS = 0;
169 190
170 private int m_rootAgents = 0; 191 private int m_rootAgents;
171 private int m_childAgents = 0; 192 private int m_childAgents;
172 private int m_numPrim = 0; 193 private int m_numPrim;
173 private int m_inPacketsPerSecond = 0; 194 private int m_inPacketsPerSecond;
174 private int m_outPacketsPerSecond = 0; 195 private int m_outPacketsPerSecond;
175 private int m_activePrim = 0; 196 private int m_activePrim;
176 private int m_unAckedBytes = 0; 197 private int m_unAckedBytes;
177 private int m_pendingDownloads = 0; 198 private int m_pendingDownloads;
178 private int m_pendingUploads = 0; 199 private int m_pendingUploads = 0; // FIXME: Not currently filled in
179 private int m_activeScripts = 0; 200 private int m_activeScripts;
180 private int m_scriptLinesPerSecond = 0; 201 private int m_scriptLinesPerSecond;
181 202
182 private int m_objectCapacity = 45000; 203 private int m_objectCapacity = 45000;
183 204
@@ -199,7 +220,7 @@ namespace OpenSim.Region.Framework.Scenes
199 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 220 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
200 m_report.AutoReset = true; 221 m_report.AutoReset = true;
201 m_report.Interval = m_statsUpdatesEveryMS; 222 m_report.Interval = m_statsUpdatesEveryMS;
202 m_report.Elapsed += statsHeartBeat; 223 m_report.Elapsed += TriggerStatsHeartbeat;
203 m_report.Enabled = true; 224 m_report.Enabled = true;
204 225
205 if (StatsManager.SimExtraStats != null) 226 if (StatsManager.SimExtraStats != null)
@@ -208,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
208 229
209 public void Close() 230 public void Close()
210 { 231 {
211 m_report.Elapsed -= statsHeartBeat; 232 m_report.Elapsed -= TriggerStatsHeartbeat;
212 m_report.Close(); 233 m_report.Close();
213 } 234 }
214 235
@@ -223,9 +244,23 @@ namespace OpenSim.Region.Framework.Scenes
223 m_report.Interval = m_statsUpdatesEveryMS; 244 m_report.Interval = m_statsUpdatesEveryMS;
224 } 245 }
225 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 }
259 }
260
226 private void statsHeartBeat(object sender, EventArgs e) 261 private void statsHeartBeat(object sender, EventArgs e)
227 { 262 {
228 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; 263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
229 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
230 265
231 // Know what's not thread safe in Mono... modifying timers. 266 // Know what's not thread safe in Mono... modifying timers.
@@ -292,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes
292 if (framesUpdated == 0) 327 if (framesUpdated == 0)
293 framesUpdated = 1; 328 framesUpdated = 1;
294 329
295 for (int i = 0; i < 21; i++) 330 for (int i = 0; i < 22; i++)
296 { 331 {
297 sb[i] = new SimStatsPacket.StatBlock(); 332 sb[i] = new SimStatsPacket.StatBlock();
298 } 333 }
@@ -359,8 +394,11 @@ namespace OpenSim.Region.Framework.Scenes
359 394
360 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 395 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
361 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; 396 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
362 397
363 for (int i = 0; i < 21; i++) 398 sb[21].StatID = (uint)Stats.SimSpareMs;
399 sb[21].StatValue = m_spareMS / framesUpdated;
400
401 for (int i = 0; i < 22; i++)
364 { 402 {
365 lastReportedSimStats[i] = sb[i].StatValue; 403 lastReportedSimStats[i] = sb[i].StatValue;
366 } 404 }
@@ -398,11 +436,11 @@ namespace OpenSim.Region.Framework.Scenes
398 } 436 }
399 } 437 }
400 438
401 resetvalues(); 439 ResetValues();
402 } 440 }
403 } 441 }
404 442
405 private void resetvalues() 443 private void ResetValues()
406 { 444 {
407 m_timeDilation = 0; 445 m_timeDilation = 0;
408 m_fps = 0; 446 m_fps = 0;
@@ -420,6 +458,7 @@ namespace OpenSim.Region.Framework.Scenes
420 m_physicsMS = 0; 458 m_physicsMS = 0;
421 m_imageMS = 0; 459 m_imageMS = 0;
422 m_otherMS = 0; 460 m_otherMS = 0;
461 m_spareMS = 0;
423 462
424//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 463//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
425//Ckrinke m_scriptMS = 0; 464//Ckrinke m_scriptMS = 0;
@@ -498,6 +537,11 @@ namespace OpenSim.Region.Framework.Scenes
498 m_frameMS += ms; 537 m_frameMS += ms;
499 } 538 }
500 539
540 public void AddSpareMS(int ms)
541 {
542 m_spareMS += ms;
543 }
544
501 public void addNetMS(int ms) 545 public void addNetMS(int ms)
502 { 546 {
503 m_netMS += ms; 547 m_netMS += ms;