aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSteven Zielinski2015-04-21 15:33:54 -0400
committerSteven Zielinski2015-04-21 17:33:26 -0400
commit0b3adc961b5fbb9771f494dfe644946d7deebe71 (patch)
tree8c0a5b82da8c85de75cd802d23bf7b5966681a53 /OpenSim
parentRevert "Enable grab feature (Ctrl+Drag) for non-physical link-sets and add co... (diff)
downloadopensim-SC_OLD-0b3adc961b5fbb9771f494dfe644946d7deebe71.zip
opensim-SC_OLD-0b3adc961b5fbb9771f494dfe644946d7deebe71.tar.gz
opensim-SC_OLD-0b3adc961b5fbb9771f494dfe644946d7deebe71.tar.bz2
opensim-SC_OLD-0b3adc961b5fbb9771f494dfe644946d7deebe71.tar.xz
Added in all metrics for Phase 1 except for Time Dilation.
Test Plan: Tested on local opensim and firestorm. Not tested with JSON stats reporter. Reviewers: rlouden Reviewed By: rlouden Differential Revision: http://cr.irl.ucf.edu/D269
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/Scene.cs104
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/SimStatsReporter.cs123
2 files changed, 218 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4715558..906c862 100644..100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1107,7 +1107,27 @@ namespace OpenSim.Region.Framework.Scenes
1107 1107
1108 #endregion Interest Management 1108 #endregion Interest Management
1109 1109
1110 StatsReporter = new SimStatsReporter(this); 1110 // Acquire the statistics section of the OpenSim.ini file located
1111 // in the bin directory
1112 IConfig statisticsConfig = m_config.Configs["Statistics"];
1113
1114 // Confirm that the statistics section existed in the configuration
1115 // file
1116 if (statisticsConfig != null)
1117 {
1118 // Create the StatsReporter using the number of frames to store
1119 // for the frame time statistics, or 10 frames if the config
1120 // file doesn't contain a value
1121 StatsReporter = new SimStatsReporter(this,
1122 statisticsConfig.GetInt("NumberOfFrames", 10));
1123 }
1124 else
1125 {
1126 // Create a StatsReporter with the current scene and a default
1127 // 10 frames stored for the frame time statistics
1128 StatsReporter = new SimStatsReporter(this);
1129 }
1130
1111 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1131 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1112 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1132 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1113 1133
@@ -1607,6 +1627,21 @@ namespace OpenSim.Region.Framework.Scenes
1607 float physicsFPS = 0f; 1627 float physicsFPS = 0f;
1608 int previousFrameTick, tmpMS; 1628 int previousFrameTick, tmpMS;
1609 1629
1630 // These variables will be used to save the precise frame time using the
1631 // Stopwatch class of Microsoft SDK; the times are recorded at the start
1632 // and end of a particular section of code, and then used to calculate
1633 // the frame times, which are the sums of the sections for each given name
1634 double preciseTotalFrameTime = 0.0;
1635 double preciseSimFrameTime = 0.0;
1636 double precisePhysicsFrameTime = 0.0;
1637 Stopwatch totalFrameStopwatch = new Stopwatch();
1638 Stopwatch simFrameStopwatch = new Stopwatch();
1639 Stopwatch physicsFrameStopwatch = new Stopwatch();
1640
1641 // Begin the stopwatch to keep track of the time that the frame
1642 // started running to determine how long the frame took to complete
1643 totalFrameStopwatch.Start();
1644
1610 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1645 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1611 { 1646 {
1612 ++Frame; 1647 ++Frame;
@@ -1622,25 +1657,62 @@ namespace OpenSim.Region.Framework.Scenes
1622 // Apply taints in terrain module to terrain in physics scene 1657 // Apply taints in terrain module to terrain in physics scene
1623 if (Frame % m_update_terrain == 0) 1658 if (Frame % m_update_terrain == 0)
1624 { 1659 {
1660 // At several points inside the code there was a need to
1661 // create a more precise measurement of time elapsed.
1662 // This led to the addition of variables that have a
1663 // similar function and thus remain tightly connected to
1664 // their original counterparts. However, the original
1665 // code is not receiving comments from our group because
1666 // we don't feel right modifying the code to that degree
1667 // at this point in time, the precise values all begin
1668 // with the keyword precise
1625 tmpMS = Util.EnvironmentTickCount(); 1669 tmpMS = Util.EnvironmentTickCount();
1670
1671 simFrameStopwatch.Start();
1626 UpdateTerrain(); 1672 UpdateTerrain();
1673
1674 // Get the simulation frame time that the avatar force
1675 // input took
1676 simFrameStopwatch.Stop();
1677 preciseSimFrameTime =
1678 simFrameStopwatch.Elapsed.TotalMilliseconds;
1627 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); 1679 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1628 } 1680 }
1629 1681
1630 tmpMS = Util.EnvironmentTickCount(); 1682 tmpMS = Util.EnvironmentTickCount();
1683
1684 // Begin the stopwatch to track the time to prepare physics
1685 physicsFrameStopwatch.Start();
1631 if (PhysicsEnabled && Frame % m_update_physics == 0) 1686 if (PhysicsEnabled && Frame % m_update_physics == 0)
1632 m_sceneGraph.UpdatePreparePhysics(); 1687 m_sceneGraph.UpdatePreparePhysics();
1688
1689 // Get the time it took to prepare the physics, this
1690 // would report the most precise time that physics was
1691 // running on the machine and should the physics not be
1692 // enabled will report the time it took to check if physics
1693 // was enabled
1694 physicsFrameStopwatch.Stop();
1695 precisePhysicsFrameTime =
1696 physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1633 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1697 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1634 1698
1635 // Apply any pending avatar force input to the avatar's velocity 1699 // Apply any pending avatar force input to the avatar's velocity
1636 tmpMS = Util.EnvironmentTickCount(); 1700 tmpMS = Util.EnvironmentTickCount();
1701 simFrameStopwatch.Restart();
1637 if (Frame % m_update_entitymovement == 0) 1702 if (Frame % m_update_entitymovement == 0)
1638 m_sceneGraph.UpdateScenePresenceMovement(); 1703 m_sceneGraph.UpdateScenePresenceMovement();
1704
1705 // Get the simulation frame time that the avatar force input
1706 // took
1707 simFrameStopwatch.Stop();
1708 preciseSimFrameTime +=
1709 simFrameStopwatch.Elapsed.TotalMilliseconds;
1639 agentMS = Util.EnvironmentTickCountSubtract(tmpMS); 1710 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1640 1711
1641 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1712 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1642 // velocity 1713 // velocity
1643 tmpMS = Util.EnvironmentTickCount(); 1714 tmpMS = Util.EnvironmentTickCount();
1715 physicsFrameStopwatch.Restart();
1644 if (Frame % m_update_physics == 0) 1716 if (Frame % m_update_physics == 0)
1645 { 1717 {
1646 if (PhysicsEnabled) 1718 if (PhysicsEnabled)
@@ -1649,8 +1721,16 @@ namespace OpenSim.Region.Framework.Scenes
1649 if (SynchronizeScene != null) 1721 if (SynchronizeScene != null)
1650 SynchronizeScene(this); 1722 SynchronizeScene(this);
1651 } 1723 }
1724
1725 // Add the main physics update time to the prepare physics
1726 // time
1727 physicsFrameStopwatch.Stop();
1728 precisePhysicsFrameTime +=
1729 physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1652 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); 1730 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1653 1731
1732 // Start the stopwatch for the remainder of the simulation
1733 simFrameStopwatch.Restart();
1654 tmpMS = Util.EnvironmentTickCount(); 1734 tmpMS = Util.EnvironmentTickCount();
1655 1735
1656 // Check if any objects have reached their targets 1736 // Check if any objects have reached their targets
@@ -1738,6 +1818,11 @@ namespace OpenSim.Region.Framework.Scenes
1738 EventManager.TriggerRegionHeartbeatEnd(this); 1818 EventManager.TriggerRegionHeartbeatEnd(this);
1739 otherMS = eventMS + backupMS + terrainMS + landMS; 1819 otherMS = eventMS + backupMS + terrainMS + landMS;
1740 1820
1821 // Get the elapsed time for the simulation frame
1822 simFrameStopwatch.Stop();
1823 preciseSimFrameTime +=
1824 simFrameStopwatch.Elapsed.TotalMilliseconds;
1825
1741 if (!UpdateOnTimer) 1826 if (!UpdateOnTimer)
1742 { 1827 {
1743 Watchdog.UpdateThread(); 1828 Watchdog.UpdateThread();
@@ -1754,6 +1839,14 @@ namespace OpenSim.Region.Framework.Scenes
1754 spareMS = Math.Max(0, MinFrameTicks - physicsMS2 - agentMS - physicsMS - otherMS); 1839 spareMS = Math.Max(0, MinFrameTicks - physicsMS2 - agentMS - physicsMS - otherMS);
1755 } 1840 }
1756 1841
1842 // Get the total frame time
1843 totalFrameStopwatch.Stop();
1844 preciseTotalFrameTime =
1845 totalFrameStopwatch.Elapsed.TotalMilliseconds;
1846
1847 // Restart the stopwatch for the total time of the next frame
1848 totalFrameStopwatch.Restart();
1849
1757 previousFrameTick = m_lastFrameTick; 1850 previousFrameTick = m_lastFrameTick;
1758 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick); 1851 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick);
1759 m_lastFrameTick = Util.EnvironmentTickCount(); 1852 m_lastFrameTick = Util.EnvironmentTickCount();
@@ -1771,6 +1864,15 @@ namespace OpenSim.Region.Framework.Scenes
1771 StatsReporter.AddSpareMS(spareMS); 1864 StatsReporter.AddSpareMS(spareMS);
1772 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); 1865 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1773 1866
1867 // Send the correct time values to the stats reporter for the
1868 // frame times
1869 StatsReporter.addFrameTimeMilliseconds(preciseTotalFrameTime,
1870 preciseSimFrameTime, precisePhysicsFrameTime, 0.0);
1871
1872 // Send the correct number of frames that the physics library
1873 // has processed to the stats reporter
1874 StatsReporter.addPhysicsFrame(1);
1875
1774 // Optionally warn if a frame takes double the amount of time that it should. 1876 // Optionally warn if a frame takes double the amount of time that it should.
1775 if (DebugUpdates 1877 if (DebugUpdates
1776 && Util.EnvironmentTickCountSubtract( 1878 && Util.EnvironmentTickCountSubtract(
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 8f1e345..6182bcd 100644..100755
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -213,6 +213,27 @@ namespace OpenSim.Region.Framework.Scenes
213 213
214 private int m_objectCapacity = 45000; 214 private int m_objectCapacity = 45000;
215 215
216 // This is the number of frames that will be stored and then averaged for
217 // the Total, Simulation, Physics, and Network Frame Time; It is set to
218 // 10 by default but can be changed by the OpenSim.ini configuration file
219 // NumberOfFrames parameter
220 private int m_numberFramesStored = 10;
221
222 // The arrays that will hold the time it took to run the past N frames,
223 // where N is the num_frames_to_average given by the configuration file
224 private double[] m_totalFrameTimeMilliseconds;
225 private double[] m_simulationFrameTimeMilliseconds;
226 private double[] m_physicsFrameTimeMilliseconds;
227 private double[] m_networkFrameTimeMilliseconds;
228
229 // The location of the next time in milliseconds that will be
230 // (over)written when the next frame completes
231 private int m_nextLocation = 0;
232
233 // The correct number of frames that have completed since the last stats
234 // update for physics
235 private int m_numberPhysicsFrames;
236
216 private Scene m_scene; 237 private Scene m_scene;
217 238
218 private RegionInfo ReportingRegion; 239 private RegionInfo ReportingRegion;
@@ -223,6 +244,13 @@ namespace OpenSim.Region.Framework.Scenes
223 244
224 public SimStatsReporter(Scene scene) 245 public SimStatsReporter(Scene scene)
225 { 246 {
247 // Initialize the different frame time arrays to the correct sizes
248 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
249 m_simulationFrameTimeMilliseconds = new
250 double[m_numberFramesStored];
251 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
252 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
253
226 m_scene = scene; 254 m_scene = scene;
227 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; 255 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
228 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); 256 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@@ -256,6 +284,13 @@ namespace OpenSim.Region.Framework.Scenes
256 StatsManager.RegisterStat(SlowFramesStat); 284 StatsManager.RegisterStat(SlowFramesStat);
257 } 285 }
258 286
287 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
288 {
289 // Store the number of frames from the OpenSim.ini configuration
290 // file
291 m_numberFramesStored = numberOfFrames;
292 }
293
259 public void Close() 294 public void Close()
260 { 295 {
261 m_report.Elapsed -= TriggerStatsHeartbeat; 296 m_report.Elapsed -= TriggerStatsHeartbeat;
@@ -289,6 +324,11 @@ namespace OpenSim.Region.Framework.Scenes
289 324
290 private void statsHeartBeat(object sender, EventArgs e) 325 private void statsHeartBeat(object sender, EventArgs e)
291 { 326 {
327 double totalSumFrameTime;
328 double simulationSumFrameTime;
329 double physicsSumFrameTime;
330 double networkSumFrameTime;
331
292 if (!m_scene.Active) 332 if (!m_scene.Active)
293 return; 333 return;
294 334
@@ -314,14 +354,21 @@ namespace OpenSim.Region.Framework.Scenes
314 354
315#region various statistic googly moogly 355#region various statistic googly moogly
316 356
357 // ORIGINAL code commented out until we have time to add our own
358 // statistics to the statistics window, this will be done as a
359 // new section given the title of our current project
317 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently 360 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently
318 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. 361 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
319 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 362 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
320 363 int reportedFPS = m_fps;
364
321 // save the reported value so there is something available for llGetRegionFPS 365 // save the reported value so there is something available for llGetRegionFPS
322 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 366 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
323 367
324 float physfps = ((m_pfps / 1000)); 368 // ORIGINAL code commented out until we have time to add our own
369 // statistics to the statistics window
370 //float physfps = ((m_pfps / 1000));
371 float physfps = m_numberPhysicsFrames;
325 372
326 //if (physfps > 600) 373 //if (physfps > 600)
327 //physfps = physfps - (physfps - 600); 374 //physfps = physfps - (physfps - 600);
@@ -364,6 +411,26 @@ namespace OpenSim.Region.Framework.Scenes
364 sb[i] = new SimStatsPacket.StatBlock(); 411 sb[i] = new SimStatsPacket.StatBlock();
365 } 412 }
366 413
414 // Resetting the sums of the frame times to prevent any errors
415 // in calculating the moving average for frame time
416 totalSumFrameTime = 0;
417 simulationSumFrameTime = 0;
418 physicsSumFrameTime = 0;
419 networkSumFrameTime = 0;
420
421 // Loop through all the frames that were stored for the current
422 // heartbeat to process the moving average of frame times
423 for (int i = 0; i < m_numberFramesStored; i++)
424 {
425 // Sum up each frame time in order to calculate the moving
426 // average of frame time
427 totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
428 simulationSumFrameTime +=
429 m_simulationFrameTimeMilliseconds[i];
430 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
431 networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
432 }
433
367 sb[0].StatID = (uint) Stats.TimeDilation; 434 sb[0].StatID = (uint) Stats.TimeDilation;
368 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 435 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
369 436
@@ -388,21 +455,31 @@ namespace OpenSim.Region.Framework.Scenes
388 sb[7].StatID = (uint) Stats.ActivePrim; 455 sb[7].StatID = (uint) Stats.ActivePrim;
389 sb[7].StatValue = m_activePrim; 456 sb[7].StatValue = m_activePrim;
390 457
458 // ORIGINAL code commented out until we have time to add our own
459 // statistics to the statistics window
391 sb[8].StatID = (uint)Stats.FrameMS; 460 sb[8].StatID = (uint)Stats.FrameMS;
392 sb[8].StatValue = m_frameMS / framesUpdated; 461 //sb[8].StatValue = m_frameMS / framesUpdated;
462 sb[8].StatValue = (float) totalSumFrameTime /
463 m_numberFramesStored;
393 464
394 sb[9].StatID = (uint)Stats.NetMS; 465 sb[9].StatID = (uint)Stats.NetMS;
395 sb[9].StatValue = m_netMS / framesUpdated; 466 //sb[9].StatValue = m_netMS / framesUpdated;
467 sb[9].StatValue = (float) networkSumFrameTime /
468 m_numberFramesStored;
396 469
397 sb[10].StatID = (uint)Stats.PhysicsMS; 470 sb[10].StatID = (uint)Stats.PhysicsMS;
398 sb[10].StatValue = m_physicsMS / framesUpdated; 471 //sb[10].StatValue = m_physicsMS / framesUpdated;
472 sb[10].StatValue = (float) physicsSumFrameTime /
473 m_numberFramesStored;
399 474
400 sb[11].StatID = (uint)Stats.ImageMS ; 475 sb[11].StatID = (uint)Stats.ImageMS ;
401 sb[11].StatValue = m_imageMS / framesUpdated; 476 sb[11].StatValue = m_imageMS / framesUpdated;
402 477
403 sb[12].StatID = (uint)Stats.OtherMS; 478 sb[12].StatID = (uint)Stats.OtherMS;
404 sb[12].StatValue = m_otherMS / framesUpdated; 479 //sb[12].StatValue = m_otherMS / framesUpdated;
405 480 sb[12].StatValue = (float) simulationSumFrameTime /
481 m_numberFramesStored;
482
406 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 483 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
407 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 484 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
408 485
@@ -475,6 +552,10 @@ namespace OpenSim.Region.Framework.Scenes
475 552
476 private void ResetValues() 553 private void ResetValues()
477 { 554 {
555 // Reset the number of frames that the physics library has
556 // processed since the last stats report
557 m_numberPhysicsFrames = 0;
558
478 m_timeDilation = 0; 559 m_timeDilation = 0;
479 m_fps = 0; 560 m_fps = 0;
480 m_pfps = 0; 561 m_pfps = 0;
@@ -605,6 +686,32 @@ namespace OpenSim.Region.Framework.Scenes
605 m_otherMS += ms; 686 m_otherMS += ms;
606 } 687 }
607 688
689 public void addPhysicsFrame(int frames)
690 {
691 // Add the number of physics frames to the correct total physics
692 // frames
693 m_numberPhysicsFrames += frames;
694 }
695
696 public void addFrameTimeMilliseconds(double total, double simulation,
697 double physics, double network)
698 {
699 // Save the frame times from the current frame into the appropriate
700 // arrays
701 m_totalFrameTimeMilliseconds[m_nextLocation] = total;
702 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
703 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
704 m_networkFrameTimeMilliseconds[m_nextLocation] = network;
705
706 // Update to the next location in the list
707 m_nextLocation++;
708
709 // Since the list will begin to overwrite the oldest frame values
710 // first, the next location needs to loop back to the beginning of the
711 // list whenever it reaches the end
712 m_nextLocation = m_nextLocation % m_numberFramesStored;
713 }
714
608 public void AddPendingDownloads(int count) 715 public void AddPendingDownloads(int count)
609 { 716 {
610 m_pendingDownloads += count; 717 m_pendingDownloads += count;