From 0c466b28bbfeac8a4e0c3c61038290621c4f9f4f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 27 Oct 2009 16:24:43 -0700 Subject: Move the calculation of time dilation from the scene to the physics engine. The scene is still the one reporting dilation so this does not break the API or remove flexibility, but it gets the calculation happening in the right place for the normal OpenSim usage. The actual calculation of physics time dilation probably needs tweaking --- OpenSim/Region/Framework/Scenes/Scene.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c3875d..3b8cd1e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -135,6 +135,11 @@ namespace OpenSim.Region.Framework.Scenes protected SceneCommunicationService m_sceneGridService; public bool loginsdisabled = true; + public float TimeDilation + { + get { return m_sceneGraph.PhysicsScene.TimeDilation; } + } + public SceneCommunicationService SceneGridService { get { return m_sceneGridService; } @@ -1094,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); StatsReporter.AddPhysicsFPS(physicsFPS); - StatsReporter.AddTimeDilation(m_timedilation); + StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); StatsReporter.AddInPackets(0); StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); @@ -1141,18 +1146,6 @@ namespace OpenSim.Region.Framework.Scenes } finally { - //updateLock.ReleaseMutex(); - // Get actual time dilation - float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); - - // If actual time dilation is greater then one, we're catching up, so subtract - // the amount that's greater then 1 from the time dilation - if (tmpval > 1.0) - { - tmpval = tmpval - (tmpval - 1.0f); - } - m_timedilation = tmpval; - m_lastupdate = DateTime.UtcNow; } maintc = Environment.TickCount - maintc; -- cgit v1.1 From a069a1ee683f67405ae66205662bb8129087030b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 14:44:05 -0700 Subject: Limit physics time dilation to 1.0 --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3b8cd1e..8b0431c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes protected SceneCommunicationService m_sceneGridService; public bool loginsdisabled = true; - public float TimeDilation + public new float TimeDilation { get { return m_sceneGraph.PhysicsScene.TimeDilation; } } -- cgit v1.1 From 59eb378d16fd8a9e887560a2744cc798fef08263 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 23:10:16 -0700 Subject: Small performance tweaks to code called by the heartbeat loop --- OpenSim/Region/Framework/Scenes/Scene.cs | 60 +++++++++++++------------------- 1 file changed, 25 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8b0431c..78ccb55 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -257,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes // Central Update Loop protected int m_fps = 10; - protected int m_frame; + protected uint m_frame; protected float m_timespan = 0.089f; protected DateTime m_lastupdate = DateTime.UtcNow; @@ -1018,36 +1018,24 @@ namespace OpenSim.Region.Framework.Scenes /// public override void Update() { - int maintc = 0; + float physicsFPS; + int maintc; + while (!shuttingdown) { -//#if DEBUG -// int w = 0, io = 0; -// ThreadPool.GetAvailableThreads(out w, out io); -// if ((w < 10) || (io < 10)) -// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); -//#endif - maintc = Environment.TickCount; - TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; - float physicsFPS = 0; + physicsFPS = 0f; - frameMS = Environment.TickCount; + maintc = maintc = frameMS = otherMS = Environment.TickCount; + + // Increment the frame counter + ++m_frame; try { - // Increment the frame counter - m_frame++; - - // Loop it - if (m_frame == Int32.MaxValue) - m_frame = 0; - - otherMS = Environment.TickCount; - // Check if any objects have reached their targets CheckAtTargets(); - + // Update SceneObjectGroups that have scheduled themselves for updates // Objects queue their updates onto all scene presences if (m_frame % m_update_objects == 0) @@ -1067,13 +1055,13 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.UpdateScenePresenceMovement(); physicsMS = Environment.TickCount; - if ((m_frame % m_update_physics == 0) && m_physics_enabled) - physicsFPS = m_sceneGraph.UpdatePhysics( - Math.Max(SinceLastFrame.TotalSeconds, m_timespan) - ); - if (m_frame % m_update_physics == 0 && SynchronizeScene != null) - SynchronizeScene(this); - + if (m_frame % m_update_physics == 0) + { + if (m_physics_enabled) + physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); + if (SynchronizeScene != null) + SynchronizeScene(this); + } physicsMS = Environment.TickCount - physicsMS; physicsMS += physicsMS2; @@ -1095,25 +1083,27 @@ namespace OpenSim.Region.Framework.Scenes if (m_frame % m_update_land == 0) UpdateLand(); - otherMS = Environment.TickCount - otherMS; + int tickCount = Environment.TickCount; + otherMS = tickCount - otherMS; + frameMS = tickCount - frameMS; + // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); StatsReporter.AddPhysicsFPS(physicsFPS); StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); - StatsReporter.AddInPackets(0); StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); - frameMS = Environment.TickCount - frameMS; StatsReporter.addFrameMS(frameMS); StatsReporter.addPhysicsMS(physicsMS); StatsReporter.addOtherMS(otherMS); StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); } - if (loginsdisabled && (m_frame > 20)) + + if (loginsdisabled && m_frame > 20) { // In 99.9% of cases it is a bad idea to manually force garbage collection. However, // this is a rare case where we know we have just went through a long cycle of heap @@ -1176,9 +1166,9 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_groupsWithTargets) { - foreach (KeyValuePair kvp in m_groupsWithTargets) + foreach (SceneObjectGroup entry in m_groupsWithTargets.Values) { - kvp.Value.checkAtTargets(); + entry.checkAtTargets(); } } } -- cgit v1.1 From 711dde34e4e5da954a58393e1a177e8c6969b8b5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 1 Nov 2009 19:37:40 +1100 Subject: * Implements new 'Monitoring' system for reporting performance. * Mostly the same set as the StatsMonitor used for Viewer notification, but exposes some new frametimes - including EventMS, PhysicsUpdateMS, LandUpdateMS; new memory monitoring - both GC.TotalMemory and Process.PrivateWorkingMemory64; also exposes ThreadCount (using System.Diagnostics.Process) * Type 'monitor report' on the console to see output. * SNMP Implementation forthcoming. --- OpenSim/Region/Framework/Scenes/Scene.cs | 59 +++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 78ccb55..07fdc9f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -274,6 +274,21 @@ namespace OpenSim.Region.Framework.Scenes private int physicsMS2; private int physicsMS; private int otherMS; + private int tempOnRezMS; + private int eventMS; + private int backupMS; + private int terrainMS; + private int landMS; + + public int MonitorFrameTime { get { return frameMS; } } + public int MonitorPhysicsUpdateTime { get { return physicsMS; } } + public int MonitorPhysicsSyncTime { get { return physicsMS2; } } + public int MonitorOtherTime { get { return otherMS; } } + public int MonitorTempOnRezTime { get { return tempOnRezMS; } } + public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event? + public int MonitorBackupTime { get { return backupMS; } } + public int MonitorTerrainTime { get { return terrainMS; } } + public int MonitorLandTime { get { return landMS; } } private bool m_physics_enabled = true; private bool m_scripts_enabled = true; @@ -1026,7 +1041,8 @@ namespace OpenSim.Region.Framework.Scenes TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; physicsFPS = 0f; - maintc = maintc = frameMS = otherMS = Environment.TickCount; + maintc = maintc = otherMS = Environment.TickCount; + int tmpFrameMS = maintc; // Increment the frame counter ++m_frame; @@ -1046,15 +1062,16 @@ namespace OpenSim.Region.Framework.Scenes if (m_frame % m_update_presences == 0) m_sceneGraph.UpdatePresences(); - physicsMS2 = Environment.TickCount; + int TempPhysicsMS2 = Environment.TickCount; if ((m_frame % m_update_physics == 0) && m_physics_enabled) m_sceneGraph.UpdatePreparePhysics(); - physicsMS2 = Environment.TickCount - physicsMS2; + TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; + physicsMS2 = TempPhysicsMS2; if (m_frame % m_update_entitymovement == 0) m_sceneGraph.UpdateScenePresenceMovement(); - physicsMS = Environment.TickCount; + int TempPhysicsMS = Environment.TickCount; if (m_frame % m_update_physics == 0) { if (m_physics_enabled) @@ -1062,30 +1079,56 @@ namespace OpenSim.Region.Framework.Scenes if (SynchronizeScene != null) SynchronizeScene(this); } - physicsMS = Environment.TickCount - physicsMS; - physicsMS += physicsMS2; + TempPhysicsMS = Environment.TickCount - TempPhysicsMS; + physicsMS = TempPhysicsMS; // Delete temp-on-rez stuff if (m_frame % m_update_backup == 0) + { + int tozMS = Environment.TickCount; CleanTempObjects(); + tozMS -= Environment.TickCount; + tempOnRezMS = tozMS; + } if (RegionStatus != RegionStatus.SlaveScene) { if (m_frame % m_update_events == 0) + { + int evMS = Environment.TickCount; UpdateEvents(); + evMS -= Environment.TickCount; + eventMS = evMS; + } if (m_frame % m_update_backup == 0) + { + int backMS = Environment.TickCount; UpdateStorageBackup(); + backMS -= Environment.TickCount; + backupMS = backMS; + } if (m_frame % m_update_terrain == 0) + { + int terMS = Environment.TickCount; UpdateTerrain(); + terMS -= Environment.TickCount; + terrainMS = terMS; + } if (m_frame % m_update_land == 0) + { + int ldMS = Environment.TickCount; UpdateLand(); + ldMS -= Environment.TickCount; + landMS = ldMS; + } int tickCount = Environment.TickCount; otherMS = tickCount - otherMS; - frameMS = tickCount - frameMS; + tmpFrameMS -= tickCount; + frameMS = tmpFrameMS; // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); @@ -1097,7 +1140,7 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); StatsReporter.addFrameMS(frameMS); - StatsReporter.addPhysicsMS(physicsMS); + StatsReporter.addPhysicsMS(physicsMS + physicsMS2); StatsReporter.addOtherMS(otherMS); StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); -- cgit v1.1 From 838bc80ab9273c2834794535886a86c7574bb0d3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 2 Nov 2009 00:05:49 +1100 Subject: * Implemented some tweaks to monitoring module. * Output is prettier & more useful. * Added 'Alerts' to allow rules to be constructed using Monitors to detect for events such as deadlocks. This will be translated to SNMP Traps when I get SNMP implemented. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 07fdc9f..1e7803f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -279,6 +279,7 @@ namespace OpenSim.Region.Framework.Scenes private int backupMS; private int terrainMS; private int landMS; + private int lastCompletedFrame; public int MonitorFrameTime { get { return frameMS; } } public int MonitorPhysicsUpdateTime { get { return physicsMS; } } @@ -289,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes public int MonitorBackupTime { get { return backupMS; } } public int MonitorTerrainTime { get { return terrainMS; } } public int MonitorLandTime { get { return landMS; } } + public int MonitorLastFrameTick { get { return lastCompletedFrame; } } private bool m_physics_enabled = true; private bool m_scripts_enabled = true; @@ -1129,6 +1131,7 @@ namespace OpenSim.Region.Framework.Scenes otherMS = tickCount - otherMS; tmpFrameMS -= tickCount; frameMS = tmpFrameMS; + lastCompletedFrame = tickCount; // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); -- cgit v1.1 From 67ac9881faf2034facfe92613538938695c2cda9 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:28:35 -0800 Subject: Removing duplicate SceneObjectPart.RotationalVelocity property --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1e7803f..a6ee40a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4635,7 +4635,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. jointProxyObject.Velocity = trackedBody.Velocity; - jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity; + jointProxyObject.AngularVelocity = trackedBody.AngularVelocity; switch (joint.Type) { case PhysicsJointType.Ball: -- cgit v1.1