From f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Sep 2009 03:33:31 +0100 Subject: [PATCH] Thank you, dslake, for a set of patches to improve OpenSim startup and idle performance. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 49 +++++++++++++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 +- .../Framework/Scenes/SceneObjectGroup.cs | 7 ++- .../Region/Physics/OdePlugin/ODECharacter.cs | 5 ++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 5 ++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 10 ++-- prebuild.xml | 2 + 8 files changed, 63 insertions(+), 21 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9c2ee4ae09..4a16a702c4 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -412,8 +412,8 @@ namespace OpenSim.Data.MySQL public List LoadObjects(UUID regionUUID) { UUID lastGroupID = UUID.Zero; - List objects = new List(); - List prims = new List(); + Dictionary objects = new Dictionary(); + Dictionary prims = new Dictionary(); SceneObjectGroup grp = null; lock (m_Connection) @@ -441,14 +441,14 @@ namespace OpenSim.Data.MySQL else prim.Shape = BuildShape(reader); - prims.Add(prim); + prims[prim.UUID] = prim; UUID groupID = new UUID(reader["SceneGroupID"].ToString()); if (groupID != lastGroupID) // New SOG { if (grp != null) - objects.Add(grp); + objects[grp.UUID] = grp; lastGroupID = groupID; @@ -487,16 +487,47 @@ namespace OpenSim.Data.MySQL } if (grp != null) - objects.Add(grp); + objects[grp.UUID] = grp; cmd.Dispose(); } - foreach (SceneObjectPart part in prims) - LoadItems(part); + // Instead of attempting to LoadItems on every prim, + // most of which probably have no items... get a + // list from DB of all prims which have items and + // LoadItems only on those + List primsWithInventory = new List(); + lock (m_Connection) + { + MySqlCommand itemCmd = m_Connection.CreateCommand(); + itemCmd.CommandText = "select distinct primID from primitems"; + IDataReader itemReader = ExecuteReader(itemCmd); + try + { + while (itemReader.Read()) + { + if (!(itemReader["primID"] is DBNull)) + { + UUID primID = new UUID(itemReader["primID"].ToString()); + if (prims.ContainsKey(primID)) + { + primsWithInventory.Add(prims[primID]); + } + } + } + } + finally + { + itemReader.Close(); + } + itemCmd.Dispose(); + } + foreach (SceneObjectPart prim in primsWithInventory) + { + LoadItems(prim); + } m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); - - return objects; + return new List(objects.Values); } /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 33afc40dc2..ec209ed3c9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -998,7 +998,7 @@ namespace OpenSim.Region.Framework.Scenes physicsMS2 = Environment.TickCount - physicsMS2; if (m_frame % m_update_entitymovement == 0) - m_sceneGraph.UpdateEntityMovement(); + m_sceneGraph.UpdateScenePresenceMovement(); physicsMS = Environment.TickCount; if ((m_frame % m_update_physics == 0) && m_physics_enabled) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 3007598829..48dea0719a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -198,9 +198,9 @@ namespace OpenSim.Region.Framework.Scenes } } - protected internal void UpdateEntityMovement() + protected internal void UpdateScenePresenceMovement() { - List moveEntities = GetEntities(); + List moveEntities = GetScenePresences(); foreach (EntityBase entity in moveEntities) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d72ed7dadf..5be074e9d1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1904,7 +1904,7 @@ namespace OpenSim.Region.Framework.Scenes //return; //} - if (Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02) && UsePhysics) + if (UsePhysics && Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02)) { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; @@ -1916,11 +1916,10 @@ namespace OpenSim.Region.Framework.Scenes checkAtTargets(); - if (((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) + if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) - || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)) - && UsePhysics) + || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))) { m_rootPart.UpdateFlag = 1; diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 38df751c5d..dd58a4e2d0 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -223,6 +223,11 @@ namespace OpenSim.Region.Physics.OdePlugin set { m_localID = value; } } + public override int GetHashCode() + { + return (int)m_localID; + } + public override bool Grabbed { set { return; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index d0f77e6f55..673ae39ff6 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -260,6 +260,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_localID = value; } } + public override int GetHashCode() + { + return (int)m_localID; + } + public override bool Grabbed { set { return; } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 817cc2225b..e702d5eab9 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -235,11 +235,11 @@ namespace OpenSim.Region.Physics.OdePlugin private d.NearCallback nearCallback; public d.TriCallback triCallback; public d.TriArrayCallback triArrayCallback; - private readonly List _characters = new List(); - private readonly List _prims = new List(); - private readonly List _activeprims = new List(); - private readonly List _taintedPrim = new List(); - private readonly List _taintedActors = new List(); + private readonly HashSet _characters = new HashSet(); + private readonly HashSet _prims = new HashSet(); + private readonly HashSet _activeprims = new HashSet(); + private readonly HashSet _taintedPrim = new HashSet(); + private readonly HashSet _taintedActors = new HashSet(); private readonly List _perloopContact = new List(); private readonly List _collisionEventPrim = new List(); public Dictionary geom_name_map = new Dictionary(); diff --git a/prebuild.xml b/prebuild.xml index 343b06a166..cdffd8a099 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -501,6 +501,7 @@ ../../../../bin/ + @@ -3714,6 +3715,7 @@ ../../../../bin/ +