aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorGlenn Martin2015-04-20 14:55:00 -0400
committerGlenn Martin2015-04-21 14:29:17 -0400
commit1959eb8372b6c8e35e1afa435504e9ef41dec958 (patch)
treed9cb670464215a7baeaee11638544635237f5eb7 /OpenSim/Region/Framework/Scenes/Scene.cs
parentRevert "Enable grab feature (Ctrl+Drag) for non-physical link-sets and add co... (diff)
downloadopensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.zip
opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.gz
opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.bz2
opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.xz
Moved over metrics from previous OpenSim 0.8.0.3 repository (this new repository is now the master branch from OpenSim).
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/Scene.cs108
1 files changed, 107 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4715558..052567f 100644..100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -526,6 +526,13 @@ namespace OpenSim.Region.Framework.Scenes
526 get { return m_sceneGraph.PhysicsScene.TimeDilation; } 526 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
527 } 527 }
528 528
529 public void setThreadCount(int inUseThreads)
530 {
531 // Just pass the thread count information on its way as the Scene
532 // does not require the value for anything at this time
533 StatsReporter.SetThreadCount(inUseThreads);
534 }
535
529 public SceneCommunicationService SceneGridService 536 public SceneCommunicationService SceneGridService
530 { 537 {
531 get { return m_sceneGridService; } 538 get { return m_sceneGridService; }
@@ -1107,7 +1114,35 @@ namespace OpenSim.Region.Framework.Scenes
1107 1114
1108 #endregion Interest Management 1115 #endregion Interest Management
1109 1116
1110 StatsReporter = new SimStatsReporter(this); 1117 // The timer used by the Stopwatch class depends on the system hardware and operating system; inform
1118 // if the timer is based on a high-resolution performance counter or based on the system timer;
1119 // the performance counter will provide a more precise time than the system timer
1120 if (Stopwatch.IsHighResolution)
1121 m_log.InfoFormat("[SCENE]: Using high-resolution performance counter for statistics.");
1122 else
1123 m_log.InfoFormat("[SCENE]: Using system timer for statistics.");
1124
1125 // Acquire the statistics section of the OpenSim.ini file located
1126 // in the bin directory
1127 IConfig statisticsConfig = m_config.Configs["Statistics"];
1128
1129 // Confirm that the statistics section existed in the configuration
1130 // file
1131 if (statisticsConfig != null)
1132 {
1133 // Create the StatsReporter using the number of frames to store
1134 // for the frame time statistics, or 10 frames if the config
1135 // file doesn't contain a value
1136 StatsReporter = new SimStatsReporter(this,
1137 statisticsConfig.GetInt("NumberOfFrames", 10));
1138 }
1139 else
1140 {
1141 // Create a StatsReporter with the current scene and a default
1142 // 10 frames stored for the frame time statistics
1143 StatsReporter = new SimStatsReporter(this);
1144 }
1145
1111 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1146 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1112 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1147 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1113 1148
@@ -1607,6 +1642,21 @@ namespace OpenSim.Region.Framework.Scenes
1607 float physicsFPS = 0f; 1642 float physicsFPS = 0f;
1608 int previousFrameTick, tmpMS; 1643 int previousFrameTick, tmpMS;
1609 1644
1645 // These variables will be used to save the precise frame time using the
1646 // Stopwatch class of Microsoft SDK; the times are recorded at the start
1647 // and end of a parcticular section of code, and then used to calculate
1648 // the frame times, which are the sums of the sections for each given name
1649 double preciseTotalFrameTime = 0.0;
1650 double preciseSimFrameTime = 0.0;
1651 double precisePhysicsFrameTime = 0.0;
1652 Stopwatch totalFrameStopwatch = new Stopwatch();
1653 Stopwatch simFrameStopwatch = new Stopwatch();
1654 Stopwatch physicsFrameStopwatch = new Stopwatch();
1655
1656 // Begin the stopwatch to keep track of the time that the frame
1657 // started running to determine how long the frame took to complete
1658 totalFrameStopwatch.Start();
1659
1610 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1660 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1611 { 1661 {
1612 ++Frame; 1662 ++Frame;
@@ -1627,20 +1677,47 @@ namespace OpenSim.Region.Framework.Scenes
1627 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); 1677 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1628 } 1678 }
1629 1679
1680 // At several points inside the code there was a need to
1681 // create a more precise measurement of time elapsed. This
1682 // led to the addition of variables that have a similar
1683 // function and thus remain tightly connected to their
1684 // original counterparts. However, the original code is
1685 // not receiving comments from our group because we don't
1686 // feel right modifying the code to that degree at this
1687 // point in time, the precise values all begin with the
1688 // keyword precise
1689
1630 tmpMS = Util.EnvironmentTickCount(); 1690 tmpMS = Util.EnvironmentTickCount();
1691
1692 // Begin the stopwatch to track the time to prepare physics
1693 physicsFrameStopwatch.Start();
1631 if (PhysicsEnabled && Frame % m_update_physics == 0) 1694 if (PhysicsEnabled && Frame % m_update_physics == 0)
1632 m_sceneGraph.UpdatePreparePhysics(); 1695 m_sceneGraph.UpdatePreparePhysics();
1696
1697 // Get the time it took to prepare the physics, this
1698 // would report the most precise time that physics was
1699 // running on the machine and should the physics not be
1700 // enabled will report the time it took to check if physics
1701 // was enabled
1702 physicsFrameStopwatch.Stop();
1703 precisePhysicsFrameTime = physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1633 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1704 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1634 1705
1635 // Apply any pending avatar force input to the avatar's velocity 1706 // Apply any pending avatar force input to the avatar's velocity
1636 tmpMS = Util.EnvironmentTickCount(); 1707 tmpMS = Util.EnvironmentTickCount();
1708 simFrameStopwatch.Start();
1637 if (Frame % m_update_entitymovement == 0) 1709 if (Frame % m_update_entitymovement == 0)
1638 m_sceneGraph.UpdateScenePresenceMovement(); 1710 m_sceneGraph.UpdateScenePresenceMovement();
1711
1712 // Get the simulation frame time that the avatar force input took
1713 simFrameStopwatch.Stop();
1714 preciseSimFrameTime = simFrameStopwatch.Elapsed.TotalMilliseconds;
1639 agentMS = Util.EnvironmentTickCountSubtract(tmpMS); 1715 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1640 1716
1641 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1717 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1642 // velocity 1718 // velocity
1643 tmpMS = Util.EnvironmentTickCount(); 1719 tmpMS = Util.EnvironmentTickCount();
1720 physicsFrameStopwatch.Restart();
1644 if (Frame % m_update_physics == 0) 1721 if (Frame % m_update_physics == 0)
1645 { 1722 {
1646 if (PhysicsEnabled) 1723 if (PhysicsEnabled)
@@ -1649,8 +1726,14 @@ namespace OpenSim.Region.Framework.Scenes
1649 if (SynchronizeScene != null) 1726 if (SynchronizeScene != null)
1650 SynchronizeScene(this); 1727 SynchronizeScene(this);
1651 } 1728 }
1729
1730 // Add the main physics update time to the prepare physics time
1731 physicsFrameStopwatch.Stop();
1732 precisePhysicsFrameTime += physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1652 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); 1733 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1653 1734
1735 // Start the stopwatch for the remainder of the simulation
1736 simFrameStopwatch.Restart();
1654 tmpMS = Util.EnvironmentTickCount(); 1737 tmpMS = Util.EnvironmentTickCount();
1655 1738
1656 // Check if any objects have reached their targets 1739 // Check if any objects have reached their targets
@@ -1754,6 +1837,10 @@ namespace OpenSim.Region.Framework.Scenes
1754 spareMS = Math.Max(0, MinFrameTicks - physicsMS2 - agentMS - physicsMS - otherMS); 1837 spareMS = Math.Max(0, MinFrameTicks - physicsMS2 - agentMS - physicsMS - otherMS);
1755 } 1838 }
1756 1839
1840 // Get the elapsed time for the simulation frame
1841 simFrameStopwatch.Stop();
1842 preciseSimFrameTime += simFrameStopwatch.Elapsed.TotalMilliseconds;
1843
1757 previousFrameTick = m_lastFrameTick; 1844 previousFrameTick = m_lastFrameTick;
1758 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick); 1845 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick);
1759 m_lastFrameTick = Util.EnvironmentTickCount(); 1846 m_lastFrameTick = Util.EnvironmentTickCount();
@@ -1771,6 +1858,15 @@ namespace OpenSim.Region.Framework.Scenes
1771 StatsReporter.AddSpareMS(spareMS); 1858 StatsReporter.AddSpareMS(spareMS);
1772 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); 1859 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1773 1860
1861 // Send the correct time values to the stats reporter for the
1862 // frame times
1863 StatsReporter.addFrameTimeMilliseconds(preciseTotalFrameTime,
1864 preciseSimFrameTime, precisePhysicsFrameTime, 0.0);
1865
1866 // Send the correct number of frames that the physics library
1867 // has processed to the stats reporter
1868 StatsReporter.addPhysicsFrame(1);
1869
1774 // Optionally warn if a frame takes double the amount of time that it should. 1870 // Optionally warn if a frame takes double the amount of time that it should.
1775 if (DebugUpdates 1871 if (DebugUpdates
1776 && Util.EnvironmentTickCountSubtract( 1872 && Util.EnvironmentTickCountSubtract(
@@ -1782,6 +1878,9 @@ namespace OpenSim.Region.Framework.Scenes
1782 RegionInfo.RegionName); 1878 RegionInfo.RegionName);
1783 } 1879 }
1784 1880
1881 // Finished updating scene frame, so stop the total frame's Stopwatch
1882 totalFrameStopwatch.Stop();
1883
1785 return spareMS >= 0; 1884 return spareMS >= 0;
1786 } 1885 }
1787 1886
@@ -2702,6 +2801,9 @@ namespace OpenSim.Region.Framework.Scenes
2702 bool vialogin; 2801 bool vialogin;
2703 bool reallyNew = true; 2802 bool reallyNew = true;
2704 2803
2804 // Update the number of users attempting to login
2805 StatsReporter.UpdateUsersLoggingIn(true);
2806
2705 // Validation occurs in LLUDPServer 2807 // Validation occurs in LLUDPServer
2706 // 2808 //
2707 // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with 2809 // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with
@@ -2786,6 +2888,10 @@ namespace OpenSim.Region.Framework.Scenes
2786 EventManager.TriggerOnClientLogin(client); 2888 EventManager.TriggerOnClientLogin(client);
2787 } 2889 }
2788 2890
2891 // User has logged into the scene so update the list of users logging
2892 // in
2893 StatsReporter.UpdateUsersLoggingIn(false);
2894
2789 m_LastLogin = Util.EnvironmentTickCount(); 2895 m_LastLogin = Util.EnvironmentTickCount();
2790 2896
2791 return sp; 2897 return sp;