aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2015-11-09 15:06:41 +0000
committerUbitUmarov2015-11-09 15:06:41 +0000
commitd17633f6c000b219b423d1268b9fed2ee2d6ccde (patch)
tree8abdc75b317d79e0c1d43483d517a6ee76500a73 /OpenSim/Region/Framework/Scenes
parentadd StatisticsFPSfactor configuration option (fudge factor) with default of 1... (diff)
downloadopensim-SC-d17633f6c000b219b423d1268b9fed2ee2d6ccde.zip
opensim-SC-d17633f6c000b219b423d1268b9fed2ee2d6ccde.tar.gz
opensim-SC-d17633f6c000b219b423d1268b9fed2ee2d6ccde.tar.bz2
opensim-SC-d17633f6c000b219b423d1268b9fed2ee2d6ccde.tar.xz
replace StatisticsFPSfactor that needed to be changed with FrameTime to a simpler true or false Normalized55FPS that is now TRUE by default. Incorrectly this commit also contains changes that should had their own commits: changes to heartbeat time control ant to gathering and calculation of related statistics.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs59
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SimStatsReporter.cs286
2 files changed, 179 insertions, 166 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1952402..4e629da 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -361,9 +361,9 @@ namespace OpenSim.Region.Framework.Scenes
361 /// </remarks> 361 /// </remarks>
362 public float FrameTime { get; private set; } 362 public float FrameTime { get; private set; }
363 363
364 // statistics frame scale factor for viewer and scripts. 364 // Normalize the frame related stats to nominal 55fps for viewer and scripts option
365 // see SimStatsReporter.cs 365 // see SimStatsReporter.cs
366 public float StatisticsFPSfactor { get; private set; } 366 public bool Normalized55FPS { get; private set; }
367 367
368 /// <summary> 368 /// <summary>
369 /// The minimum length of time in seconds that will be taken for a scene frame. 369 /// The minimum length of time in seconds that will be taken for a scene frame.
@@ -860,7 +860,7 @@ namespace OpenSim.Region.Framework.Scenes
860 { 860 {
861 m_config = config; 861 m_config = config;
862 FrameTime = 0.0908f; 862 FrameTime = 0.0908f;
863 StatisticsFPSfactor = 5.0f; 863 Normalized55FPS = true;
864 MinMaintenanceTime = 1; 864 MinMaintenanceTime = 1;
865 SeeIntoRegion = true; 865 SeeIntoRegion = true;
866 866
@@ -1101,7 +1101,7 @@ namespace OpenSim.Region.Framework.Scenes
1101 } 1101 }
1102 1102
1103 FrameTime = startupConfig.GetFloat( "FrameTime", FrameTime); 1103 FrameTime = startupConfig.GetFloat( "FrameTime", FrameTime);
1104 StatisticsFPSfactor = startupConfig.GetFloat( "StatisticsFPSfactor", StatisticsFPSfactor); 1104 Normalized55FPS = startupConfig.GetBoolean( "Normalized55FPS", Normalized55FPS);
1105 1105
1106 m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup); 1106 m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup);
1107 m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 1107 m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
@@ -1669,6 +1669,7 @@ namespace OpenSim.Region.Framework.Scenes
1669 endFrame = Frame + frames; 1669 endFrame = Frame + frames;
1670 1670
1671 float physicsFPS = 0f; 1671 float physicsFPS = 0f;
1672 float frameTimeMS = FrameTime * 1000.0f;
1672 1673
1673 int previousFrameTick; 1674 int previousFrameTick;
1674 1675
@@ -1676,6 +1677,7 @@ namespace OpenSim.Region.Framework.Scenes
1676 double tmpMS2; 1677 double tmpMS2;
1677 double framestart; 1678 double framestart;
1678 float sleepMS; 1679 float sleepMS;
1680 float sleepError = 0;
1679 1681
1680 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1682 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1681 { 1683 {
@@ -1759,8 +1761,7 @@ namespace OpenSim.Region.Framework.Scenes
1759 1761
1760 // Delete temp-on-rez stuff 1762 // Delete temp-on-rez stuff
1761 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1763 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1762 { 1764 {
1763
1764 m_cleaningTemps = true; 1765 m_cleaningTemps = true;
1765 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1766 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1766 tmpMS2 = Util.GetTimeStampMS(); 1767 tmpMS2 = Util.GetTimeStampMS();
@@ -1840,21 +1841,11 @@ namespace OpenSim.Region.Framework.Scenes
1840 } 1841 }
1841 1842
1842 EventManager.TriggerRegionHeartbeatEnd(this); 1843 EventManager.TriggerRegionHeartbeatEnd(this);
1843 1844 m_firstHeartbeat = false;
1844 Watchdog.UpdateThread(); 1845 Watchdog.UpdateThread();
1845 1846
1846 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1847 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1847 1848
1848 StatsReporter.AddPhysicsFPS(physicsFPS);
1849 StatsReporter.AddTimeDilation(TimeDilation);
1850 StatsReporter.AddFPS(1);
1851
1852 StatsReporter.addAgentMS(agentMS);
1853 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1854 StatsReporter.addOtherMS(otherMS);
1855 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1856
1857
1858 tmpMS = Util.GetTimeStampMS(); 1849 tmpMS = Util.GetTimeStampMS();
1859 1850
1860 previousFrameTick = m_lastFrameTick; 1851 previousFrameTick = m_lastFrameTick;
@@ -1862,20 +1853,36 @@ namespace OpenSim.Region.Framework.Scenes
1862 1853
1863 // estimate sleep time 1854 // estimate sleep time
1864 tmpMS2 = tmpMS - framestart; 1855 tmpMS2 = tmpMS - framestart;
1865 tmpMS2 = (double)FrameTime * 1000.0D - tmpMS2; 1856 tmpMS2 = (double)frameTimeMS - tmpMS2 - sleepError;
1866
1867 m_firstHeartbeat = false;
1868 1857
1858 // reuse frameMS as temporary
1859 frameMS = (float)tmpMS2;
1860
1869 // sleep if we can 1861 // sleep if we can
1870 if (tmpMS2 > 0) 1862 if (tmpMS2 > 0)
1871 Thread.Sleep((int)(tmpMS2 +0.5)); 1863 {
1864 Thread.Sleep((int)(tmpMS2 + 0.5));
1872 1865
1873 tmpMS2 = Util.GetTimeStampMS(); 1866 tmpMS2 = Util.GetTimeStampMS();
1867 sleepMS = (float)(tmpMS2 - tmpMS);
1868 sleepError = sleepMS - frameMS;
1869 Util.Clamp(sleepError, 0.0f, 20f);
1870 frameMS = (float)(tmpMS2 - framestart);
1871 }
1872 else
1873 {
1874 tmpMS2 = Util.GetTimeStampMS();
1875 frameMS = (float)(tmpMS2 - framestart);
1876 sleepMS = 0.0f;
1877 sleepError = 0.0f;
1878 }
1874 1879
1875 sleepMS = (float)(tmpMS2 - tmpMS); 1880 // script time is not scene frame time, but is displayed per frame
1876 frameMS = (float)(tmpMS2 - framestart); 1881 float scriptTimeMS = GetAndResetScriptExecutionTime();
1877 StatsReporter.addSleepMS(sleepMS); 1882 StatsReporter.AddFrameStats(TimeDilation, physicsFPS, agentMS,
1878 StatsReporter.addFrameMS(frameMS); 1883 physicsMS + physicsMS2, otherMS , sleepMS, frameMS, scriptTimeMS);
1884
1885
1879 1886
1880 // if (Frame%m_update_avatars == 0) 1887 // if (Frame%m_update_avatars == 0)
1881 // UpdateInWorldTime(); 1888 // UpdateInWorldTime();
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index bf65cab..c8f525e 100755
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -176,10 +176,13 @@ namespace OpenSim.Region.Framework.Scenes
176 // Sending a stats update every 3 seconds- 176 // Sending a stats update every 3 seconds-
177 private int m_statsUpdatesEveryMS = 3000; 177 private int m_statsUpdatesEveryMS = 3000;
178 private double m_lastUpdateTS; 178 private double m_lastUpdateTS;
179 private double m_prevFrameStatsTS;
180 private double m_FrameStatsTS;
179 private float m_timeDilation; 181 private float m_timeDilation;
180 private int m_fps; 182 private int m_fps;
181 183
182 private object m_statsLock = new object(); 184 private object m_statsLock = new object();
185 private object m_statsFrameLock = new object();
183 186
184 /// <summary> 187 /// <summary>
185 /// Parameter to adjust reported scene fps 188 /// Parameter to adjust reported scene fps
@@ -195,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes
195 /// corresponding, with default heartbeat rate, to a value of 5. 198 /// corresponding, with default heartbeat rate, to a value of 5.
196 /// </remarks> 199 /// </remarks>
197 private float m_statisticsFPSfactor = 5.0f; 200 private float m_statisticsFPSfactor = 5.0f;
198 201 private float m_targetFrameTime = 0.1f;
199 // saved last reported value so there is something available for llGetRegionFPS 202 // saved last reported value so there is something available for llGetRegionFPS
200 private float lastReportedSimFPS; 203 private float lastReportedSimFPS;
201 private float[] lastReportedSimStats = new float[m_statisticExtraArraySize + m_statisticViewerArraySize]; 204 private float[] lastReportedSimStats = new float[m_statisticExtraArraySize + m_statisticViewerArraySize];
@@ -219,6 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
219 private float m_imageMS; 222 private float m_imageMS;
220 private float m_otherMS; 223 private float m_otherMS;
221 private float m_sleeptimeMS; 224 private float m_sleeptimeMS;
225 private float m_scriptTimeMS;
222 226
223 private int m_rootAgents; 227 private int m_rootAgents;
224 private int m_childAgents; 228 private int m_childAgents;
@@ -257,7 +261,13 @@ namespace OpenSim.Region.Framework.Scenes
257 m_scene = scene; 261 m_scene = scene;
258 262
259 ReportingRegion = scene.RegionInfo; 263 ReportingRegion = scene.RegionInfo;
260 m_statisticsFPSfactor = scene.StatisticsFPSfactor; 264
265 if(scene.Normalized55FPS)
266 m_statisticsFPSfactor = 55.0f * m_scene.FrameTime;
267 else
268 m_statisticsFPSfactor = 1.0f;
269
270 m_targetFrameTime = 1000.0f * m_scene.FrameTime / m_statisticsFPSfactor;
261 271
262 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 272 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
263 m_report.AutoReset = true; 273 m_report.AutoReset = true;
@@ -266,6 +276,8 @@ namespace OpenSim.Region.Framework.Scenes
266 m_report.Enabled = true; 276 m_report.Enabled = true;
267 277
268 m_lastUpdateTS = Util.GetTimeStampMS(); 278 m_lastUpdateTS = Util.GetTimeStampMS();
279 m_FrameStatsTS = m_lastUpdateTS;
280 m_prevFrameStatsTS = m_lastUpdateTS;
269 281
270 if (StatsManager.SimExtraStats != null) 282 if (StatsManager.SimExtraStats != null)
271 OnSendStatsResult += StatsManager.SimExtraStats.ReceiveClassicSimStatsPacket; 283 OnSendStatsResult += StatsManager.SimExtraStats.ReceiveClassicSimStatsPacket;
@@ -350,28 +362,92 @@ namespace OpenSim.Region.Framework.Scenes
350#region various statistic googly moogly 362#region various statistic googly moogly
351 double timeTmp = m_lastUpdateTS; 363 double timeTmp = m_lastUpdateTS;
352 m_lastUpdateTS = Util.GetTimeStampMS(); 364 m_lastUpdateTS = Util.GetTimeStampMS();
353 365 float updateElapsed = (float)((m_lastUpdateTS - timeTmp)/1000.0);
354 float m_statsUpdateFactor = (float)((m_lastUpdateTS - timeTmp)/1000.0);
355 366
356 // factor to consider updates integration time 367 // factor to consider updates integration time
357 float updateFactor = 1.0f / m_statsUpdateFactor; 368 float updateTimeFactor = 1.0f / updateElapsed;
369
370
371 // scene frame stats
372 float reportedFPS;
373 float physfps;
374 float timeDilation;
375 float agentMS;
376 float physicsMS;
377 float otherMS;
378 float sleeptime;
379 float scriptTimeMS;
380 float totalFrameTime;
381
382 float invFrameElapsed;
358 383
359 // the nominal frame time, corrected by reporting multiplier 384 // get a copy under lock and reset
360 float TargetFrameTime = 1000.0f * m_scene.FrameTime / m_statisticsFPSfactor; 385 lock(m_statsFrameLock)
386 {
387 timeDilation = m_timeDilation;
388 reportedFPS = m_fps;
389 physfps = m_pfps;
390 agentMS = m_agentMS;
391 physicsMS = m_physicsMS;
392 otherMS = m_otherMS;
393 sleeptime = m_sleeptimeMS;
394 scriptTimeMS = m_scriptTimeMS;
395 totalFrameTime = m_frameMS;
396 // still not inv
397 invFrameElapsed = (float)((m_FrameStatsTS - m_prevFrameStatsTS) / 1000.0);
398
399 ResetFrameStats();
400 }
361 401
362 // acumulated fps scaled by reporting multiplier 402 if (invFrameElapsed / updateElapsed < 0.8)
363 float reportedFPS = (m_fps * m_statisticsFPSfactor); 403 // scene is in trouble, its account of time is most likely wrong
404 // can even be in stall
405 invFrameElapsed = updateTimeFactor;
406 else
407 invFrameElapsed = 1.0f / invFrameElapsed;
408
409 float perframefactor;
364 if (reportedFPS <= 0) 410 if (reportedFPS <= 0)
365 reportedFPS = 1; 411 {
412 reportedFPS = 0.0f;
413 physfps = 0.0f;
414 perframefactor = 1.0f;
415 timeDilation = 0.0f;
416 }
417 else
418 {
419 timeDilation /= reportedFPS;
420 reportedFPS *= m_statisticsFPSfactor;
421 perframefactor = 1.0f / (float)reportedFPS;
422 reportedFPS *= invFrameElapsed;
423 physfps *= invFrameElapsed * m_statisticsFPSfactor;
424 }
366 425
367 // factor to calculate per frame values 426 // some engines track frame time with error related to the simulation step size
368 float perframefactor = 1.0f / (float)reportedFPS; 427 if(physfps > reportedFPS)
428 physfps = reportedFPS;
369 429
370 // fps considering the integration time
371 reportedFPS = reportedFPS * updateFactor;
372 // save the reported value so there is something available for llGetRegionFPS 430 // save the reported value so there is something available for llGetRegionFPS
373 lastReportedSimFPS = reportedFPS; 431 lastReportedSimFPS = reportedFPS;
374 432
433 // scale frame stats
434
435 totalFrameTime *= perframefactor;
436 sleeptime *= perframefactor;
437 otherMS *= perframefactor;
438 physicsMS *= perframefactor;
439 agentMS *= perframefactor;
440 scriptTimeMS *= perframefactor;
441
442 // estimate spare time
443 float sparetime;
444 sparetime = m_targetFrameTime - (physicsMS + agentMS + otherMS);
445
446 if (sparetime < 0)
447 sparetime = 0;
448 else if (sparetime > totalFrameTime)
449 sparetime = totalFrameTime;
450
375#endregion 451#endregion
376 452
377 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 453 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
@@ -381,44 +457,11 @@ namespace OpenSim.Region.Framework.Scenes
381 m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount(); 457 m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
382 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); 458 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
383 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); 459 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
460 m_scriptLinesPerSecond = m_scene.SceneGraph.GetScriptLPS();
384 461
385 float physfps = m_pfps * updateFactor * m_statisticsFPSfactor; 462 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code
386 if (physfps < 0)
387 physfps = 0;
388 else if(physfps > reportedFPS)
389 physfps = reportedFPS; // pretend we are not insane
390
391 float sparetime;
392 float sleeptime;
393
394 float TotalFrameTime = m_frameMS * perframefactor;
395 sleeptime = m_sleeptimeMS * perframefactor;
396
397 sparetime = m_frameMS - m_sleeptimeMS; // total time minus sleep
398 sparetime *= perframefactor; // average per frame
399 sparetime = TargetFrameTime - sparetime; // real spare
400 if (sparetime < 0)
401 sparetime = 0;
402 else if (sparetime > TotalFrameTime)
403 sparetime = TotalFrameTime;
404
405 // don't send meaning less precision
406 reportedFPS = (float)Math.Round(reportedFPS,1);
407 physfps = (float)Math.Round(physfps,1);
408
409 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code
410 // so that stat numbers are always consistent. 463 // so that stat numbers are always consistent.
411 CheckStatSanity(); 464 CheckStatSanity();
412
413 // other MS is actually simulation time
414 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
415 // m_imageMS m_netMS are not included in m_frameMS
416
417 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS;
418 if (m_otherMS < 0)
419 m_otherMS = 0;
420
421 float scriptTimeMS = m_scene.GetAndResetScriptExecutionTime();
422 465
423 for (int i = 0; i < m_statisticViewerArraySize; i++) 466 for (int i = 0; i < m_statisticViewerArraySize; i++)
424 { 467 {
@@ -426,16 +469,16 @@ namespace OpenSim.Region.Framework.Scenes
426 } 469 }
427 470
428 sb[0].StatID = (uint) Stats.TimeDilation; 471 sb[0].StatID = (uint) Stats.TimeDilation;
429 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; 472 sb[0].StatValue = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation,3);
430 473
431 sb[1].StatID = (uint) Stats.SimFPS; 474 sb[1].StatID = (uint) Stats.SimFPS;
432 sb[1].StatValue = reportedFPS; 475 sb[1].StatValue = (float)Math.Round(reportedFPS,1);;
433 476
434 sb[2].StatID = (uint) Stats.PhysicsFPS; 477 sb[2].StatID = (uint) Stats.PhysicsFPS;
435 sb[2].StatValue = physfps; 478 sb[2].StatValue = (float)Math.Round(physfps,1);
436 479
437 sb[3].StatID = (uint) Stats.AgentUpdates; 480 sb[3].StatID = (uint) Stats.AgentUpdates;
438 sb[3].StatValue = m_agentUpdates * updateFactor; 481 sb[3].StatValue = m_agentUpdates * updateTimeFactor;
439 482
440 sb[4].StatID = (uint) Stats.Agents; 483 sb[4].StatID = (uint) Stats.Agents;
441 sb[4].StatValue = m_rootAgents; 484 sb[4].StatValue = m_rootAgents;
@@ -450,31 +493,31 @@ namespace OpenSim.Region.Framework.Scenes
450 sb[7].StatValue = m_activePrim; 493 sb[7].StatValue = m_activePrim;
451 494
452 sb[8].StatID = (uint)Stats.FrameMS; 495 sb[8].StatID = (uint)Stats.FrameMS;
453 sb[8].StatValue = TotalFrameTime; 496 sb[8].StatValue = totalFrameTime;
454 497
455 sb[9].StatID = (uint)Stats.NetMS; 498 sb[9].StatID = (uint)Stats.NetMS;
456 sb[9].StatValue = m_netMS * perframefactor; 499 sb[9].StatValue = m_netMS * perframefactor;
457 500
458 sb[10].StatID = (uint)Stats.PhysicsMS; 501 sb[10].StatID = (uint)Stats.PhysicsMS;
459 sb[10].StatValue = m_physicsMS * perframefactor; 502 sb[10].StatValue = physicsMS;
460 503
461 sb[11].StatID = (uint)Stats.ImageMS ; 504 sb[11].StatID = (uint)Stats.ImageMS ;
462 sb[11].StatValue = m_imageMS * perframefactor; 505 sb[11].StatValue = m_imageMS * perframefactor;
463 506
464 sb[12].StatID = (uint)Stats.OtherMS; 507 sb[12].StatID = (uint)Stats.OtherMS;
465 sb[12].StatValue = m_otherMS * perframefactor; 508 sb[12].StatValue = otherMS;
466 509
467 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 510 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
468 sb[13].StatValue = (m_inPacketsPerSecond * updateFactor); 511 sb[13].StatValue = (float)Math.Round(m_inPacketsPerSecond * updateTimeFactor);
469 512
470 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 513 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
471 sb[14].StatValue = (m_outPacketsPerSecond * updateFactor); 514 sb[14].StatValue = (float)Math.Round(m_outPacketsPerSecond * updateTimeFactor);
472 515
473 sb[15].StatID = (uint)Stats.UnAckedBytes; 516 sb[15].StatID = (uint)Stats.UnAckedBytes;
474 sb[15].StatValue = m_unAckedBytes; 517 sb[15].StatValue = m_unAckedBytes;
475 518
476 sb[16].StatID = (uint)Stats.AgentMS; 519 sb[16].StatID = (uint)Stats.AgentMS;
477 sb[16].StatValue = m_agentMS * perframefactor; 520 sb[16].StatValue = agentMS;
478 521
479 sb[17].StatID = (uint)Stats.PendingDownloads; 522 sb[17].StatID = (uint)Stats.PendingDownloads;
480 sb[17].StatValue = m_pendingDownloads; 523 sb[17].StatValue = m_pendingDownloads;
@@ -514,7 +557,7 @@ namespace OpenSim.Region.Framework.Scenes
514 sb[27].StatValue = 0; 557 sb[27].StatValue = 0;
515 558
516 sb[28].StatID = (uint)Stats.ScriptEps; // we actuall have this, but not messing array order AGAIN 559 sb[28].StatID = (uint)Stats.ScriptEps; // we actuall have this, but not messing array order AGAIN
517 sb[28].StatValue = m_scriptEventsPerSecond * updateFactor; 560 sb[28].StatValue = (float)Math.Round(m_scriptEventsPerSecond * updateTimeFactor);
518 561
519 sb[29].StatID = (uint)Stats.SimAIStepTimeMS; 562 sb[29].StatID = (uint)Stats.SimAIStepTimeMS;
520 sb[29].StatValue = 0; 563 sb[29].StatValue = 0;
@@ -541,8 +584,7 @@ namespace OpenSim.Region.Framework.Scenes
541 sb[36].StatValue = 0; 584 sb[36].StatValue = 0;
542 585
543 sb[37].StatID = (uint)Stats.ScriptMS; 586 sb[37].StatID = (uint)Stats.ScriptMS;
544 sb[37].StatValue = scriptTimeMS * perframefactor; 587 sb[37].StatValue = scriptTimeMS;
545
546 588
547 for (int i = 0; i < m_statisticViewerArraySize; i++) 589 for (int i = 0; i < m_statisticViewerArraySize; i++)
548 { 590 {
@@ -558,12 +600,12 @@ namespace OpenSim.Region.Framework.Scenes
558 } 600 }
559 601
560 sbex[0].StatID = (uint)Stats.LSLScriptLinesPerSecond; 602 sbex[0].StatID = (uint)Stats.LSLScriptLinesPerSecond;
561 sbex[0].StatValue = m_scriptLinesPerSecond * updateFactor; 603 sbex[0].StatValue = m_scriptLinesPerSecond * updateTimeFactor;
562 lastReportedSimStats[38] = m_scriptLinesPerSecond * updateFactor; 604 lastReportedSimStats[38] = m_scriptLinesPerSecond * updateTimeFactor;
563 605
564 sbex[1].StatID = (uint)Stats.FrameDilation2; 606 sbex[1].StatID = (uint)Stats.FrameDilation2;
565 sbex[1].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation; 607 sbex[1].StatValue = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
566 lastReportedSimStats[39] = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation; 608 lastReportedSimStats[39] = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
567 609
568 sbex[2].StatID = (uint)Stats.UsersLoggingIn; 610 sbex[2].StatID = (uint)Stats.UsersLoggingIn;
569 sbex[2].StatValue = m_usersLoggingIn; 611 sbex[2].StatValue = m_usersLoggingIn;
@@ -597,7 +639,7 @@ namespace OpenSim.Region.Framework.Scenes
597 { 639 {
598 lock (m_lastReportedExtraSimStats) 640 lock (m_lastReportedExtraSimStats)
599 { 641 {
600 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates * updateFactor; 642 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates * updateTimeFactor;
601 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; 643 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;
602 644
603 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); 645 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
@@ -612,7 +654,7 @@ namespace OpenSim.Region.Framework.Scenes
612 if (tuple.Key.EndsWith("MS")) 654 if (tuple.Key.EndsWith("MS"))
613 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframefactor; 655 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframefactor;
614 else 656 else
615 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * updateFactor; 657 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * updateTimeFactor;
616 } 658 }
617 } 659 }
618 } 660 }
@@ -626,47 +668,15 @@ namespace OpenSim.Region.Framework.Scenes
626 668
627 private void ResetValues() 669 private void ResetValues()
628 { 670 {
629 // Reset the number of frames that the physics library has
630 // processed since the last stats report
631
632 m_timeDilation = 0;
633 m_fps = 0;
634 m_pfps = 0;
635 m_agentUpdates = 0; 671 m_agentUpdates = 0;
636 m_objectUpdates = 0; 672 m_objectUpdates = 0;
637 //m_inPacketsPerSecond = 0;
638 //m_outPacketsPerSecond = 0;
639 m_unAckedBytes = 0; 673 m_unAckedBytes = 0;
640 m_scriptLinesPerSecond = 0;
641 m_scriptEventsPerSecond = 0; 674 m_scriptEventsPerSecond = 0;
642 675
643 m_frameMS = 0;
644 m_agentMS = 0;
645 m_netMS = 0; 676 m_netMS = 0;
646 m_physicsMS = 0;
647 m_imageMS = 0; 677 m_imageMS = 0;
648 m_otherMS = 0;
649 m_sleeptimeMS = 0;
650
651//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
652//Ckrinke m_scriptMS = 0;
653 } 678 }
654 679
655 # region methods called from Scene
656 // The majority of these functions are additive
657 // so that you can easily change the amount of
658 // seconds in between sim stats updates
659
660 public void AddTimeDilation(float td)
661 {
662 //float tdsetting = td;
663 //if (tdsetting > 1.0f)
664 //tdsetting = (tdsetting - (tdsetting - 0.91f));
665
666 //if (tdsetting < 0)
667 //tdsetting = 0.0f;
668 m_timeDilation = td;
669 }
670 680
671 internal void CheckStatSanity() 681 internal void CheckStatSanity()
672 { 682 {
@@ -684,14 +694,44 @@ namespace OpenSim.Region.Framework.Scenes
684 } 694 }
685 } 695 }
686 696
687 public void AddFPS(int frames) 697 # region methods called from Scene
698
699 public void AddFrameStats(float _timeDilation, float _physicsFPS, float _agentMS,
700 float _physicsMS, float _otherMS , float _sleepMS,
701 float _frameMS, float _scriptTimeMS)
688 { 702 {
689 m_fps += frames; 703 lock(m_statsFrameLock)
690 } 704 {
705 m_fps++;
706 m_timeDilation += _timeDilation;
707 m_pfps += _physicsFPS;
708 m_agentMS += _agentMS;
709 m_physicsMS += _physicsMS;
710 m_otherMS += _otherMS;
711 m_sleeptimeMS += _sleepMS;
712 m_frameMS += _frameMS;
713 m_scriptTimeMS += _scriptTimeMS;
714
715 if (_frameMS > SlowFramesStatReportThreshold)
716 SlowFramesStat.Value++;
717
718 m_FrameStatsTS = Util.GetTimeStampMS();
719 }
720 }
691 721
692 public void AddPhysicsFPS(float frames) 722 private void ResetFrameStats()
693 { 723 {
694 m_pfps += frames; 724 m_fps = 0;
725 m_timeDilation = 0.0f;
726 m_pfps = 0.0f;
727 m_agentMS = 0.0f;
728 m_physicsMS = 0.0f;
729 m_otherMS = 0.0f;
730 m_sleeptimeMS = 0.0f;
731 m_frameMS = 0.0f;
732 m_scriptTimeMS = 0.0f;
733
734 m_prevFrameStatsTS = m_FrameStatsTS;
695 } 735 }
696 736
697 public void AddObjectUpdates(int numUpdates) 737 public void AddObjectUpdates(int numUpdates)
@@ -720,46 +760,17 @@ namespace OpenSim.Region.Framework.Scenes
720 if (m_unAckedBytes < 0) m_unAckedBytes = 0; 760 if (m_unAckedBytes < 0) m_unAckedBytes = 0;
721 } 761 }
722 762
723 public void addFrameMS(float ms)
724 {
725 m_frameMS += ms;
726
727 // At the moment, we'll only report if a frame is over 120% of target, since commonly frames are a bit
728 // longer than ideal due to the inaccuracy of the Sleep in Scene.Update() (which in itself is a concern).
729 if (ms > SlowFramesStatReportThreshold)
730 SlowFramesStat.Value++;
731 }
732 763
733 public void addNetMS(float ms) 764 public void addNetMS(float ms)
734 { 765 {
735 m_netMS += ms; 766 m_netMS += ms;
736 } 767 }
737 768
738 public void addAgentMS(float ms)
739 {
740 m_agentMS += ms;
741 }
742
743 public void addPhysicsMS(float ms)
744 {
745 m_physicsMS += ms;
746 }
747
748 public void addImageMS(float ms) 769 public void addImageMS(float ms)
749 { 770 {
750 m_imageMS += ms; 771 m_imageMS += ms;
751 } 772 }
752 773
753 public void addOtherMS(float ms)
754 {
755 m_otherMS += ms;
756 }
757
758 public void addSleepMS(float ms)
759 {
760 m_sleeptimeMS += ms;
761 }
762
763 public void AddPendingDownloads(int count) 774 public void AddPendingDownloads(int count)
764 { 775 {
765 m_pendingDownloads += count; 776 m_pendingDownloads += count;
@@ -770,11 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
770 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); 781 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
771 } 782 }
772 783
773 public void addScriptLines(int count)
774 {
775 m_scriptLinesPerSecond += count;
776 }
777
778 public void addScriptEvents(int count) 784 public void addScriptEvents(int count)
779 { 785 {
780 m_scriptEventsPerSecond += count; 786 m_scriptEventsPerSecond += count;