From 4e06a46dc5e6d0fb6a894932e706e4a01351ec64 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 1 Jun 2012 04:07:39 +0100 Subject: [PATCH 1/3] If OdeScene.Near() returns no collision contacts, then exit as early as possible. All subsequent code is only relevant if there are contacts. --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 859045390c..c26c9c581a 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -1025,6 +1025,10 @@ namespace OpenSim.Region.Physics.OdePlugin count = CollideGeoms(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); + // All code after this is only relevant if we have any collisions + if (count <= 0) + return; + if (count > contacts.Length) m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); } From 6375db1533e6c625d7b6394542f74141092ff780 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 1 Jun 2012 04:23:36 +0100 Subject: [PATCH 2/3] Add optional total avatars, total prims and active prims stats to ODE plugin. These will act as a sanity check with the main scene stats, to show that physics scene entities are being managed properly. Total prims will not match scene total prims since physics total does not include phantom prims --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index c26c9c581a..c6ecc68ae9 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -142,6 +142,21 @@ namespace OpenSim.Region.Physics.OdePlugin /// private Dictionary m_stats = new Dictionary(); + /// + /// Stat name for total number of avatars in this ODE scene. + /// + public const string ODETotalAvatarsStatName = "ODETotalAvatars"; + + /// + /// Stat name for total number of prims in this ODE scene. + /// + public const string ODETotalPrimsStatName = "ODETotalPrims"; + + /// + /// Stat name for total number of prims with active physics in this ODE scene. + /// + public const string ODEActivePrimsStatName = "ODEActivePrims"; + /// /// Stat name for the total time spent in ODE frame processing. /// @@ -4220,6 +4235,12 @@ namespace OpenSim.Region.Physics.OdePlugin { returnStats = new Dictionary(m_stats); + // FIXME: This is a SUPER DUMB HACK until we can establish stats that aren't subject to a division by + // 3 from the SimStatsReporter. + returnStats[ODETotalAvatarsStatName] = _characters.Count * 3; + returnStats[ODETotalPrimsStatName] = _prims.Count * 3; + returnStats[ODEActivePrimsStatName] = _activeprims.Count * 3; + InitializeExtraStats(); } From 72219eae7d3dac01e73ab5fdf84f05f8d0fa00cf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 1 Jun 2012 04:45:42 +0100 Subject: [PATCH 3/3] Instead of updating sim stats root agent, child, objects and scripts accounts every single scene frame, update in the once every 3 seconds SimStatsReporter run --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 --- .../Framework/Scenes/SimStatsReporter.cs | 42 +++++++------------ 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ce386be205..702e3220f6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1462,10 +1462,6 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.AddPhysicsFPS(physicsFPS); StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); - StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); - StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); - StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); - StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); // frameMS currently records work frame times, not total frame times (work + any required sleep to // reach min frame time. @@ -1474,7 +1470,6 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.addAgentMS(agentMS); StatsReporter.addPhysicsMS(physicsMS + physicsMS2); StatsReporter.addOtherMS(otherMS); - StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); if (LoginsDisabled && Frame == 20) diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 08d8d7c28f..87af311a06 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -207,6 +207,10 @@ namespace OpenSim.Region.Framework.Scenes m_report.Close(); } + /// + /// Sets the number of milliseconds between stat updates. + /// + /// public void SetUpdateMS(int ms) { statsUpdatesEveryMS = ms; @@ -254,6 +258,16 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion + + m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); + m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); + m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); + m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); + m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); + + // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code + // so that stat numbers are always consistent. + CheckStatSanity(); //Our time dilation is 0.91 when we're running a full speed, // therefore to make sure we get an appropriate range, @@ -408,13 +422,6 @@ namespace OpenSim.Region.Framework.Scenes m_timeDilation = td; } - public void SetRootAgents(int rootAgents) - { - m_rootAgents = rootAgents; - CheckStatSanity(); - - } - internal void CheckStatSanity() { if (m_rootAgents < 0 || m_childAgents < 0) @@ -431,22 +438,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void SetChildAgents(int childAgents) - { - m_childAgents = childAgents; - CheckStatSanity(); - } - - public void SetObjects(int objects) - { - m_numPrim = objects; - } - - public void SetActiveObjects(int objects) - { - m_activePrim = objects; - } - public void AddFPS(int frames) { m_fps += frames; @@ -528,11 +519,6 @@ namespace OpenSim.Region.Framework.Scenes m_scriptLinesPerSecond += count; } - public void SetActiveScripts(int count) - { - m_activeScripts = count; - } - public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) { AddInPackets(inPackets);