Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim

cpu-performance
Melanie 2013-06-05 23:44:26 +01:00
commit e53b62304f
4 changed files with 88 additions and 41 deletions

View File

@ -62,6 +62,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
// count. The entries are removed when the interest count reaches 0. // count. The entries are removed when the interest count reaches 0.
Dictionary<UUID,UUID> classifiedCache = new Dictionary<UUID, UUID>(); Dictionary<UUID,UUID> classifiedCache = new Dictionary<UUID, UUID>();
Dictionary<UUID,int> classifiedInterest = new Dictionary<UUID, int>(); Dictionary<UUID,int> classifiedInterest = new Dictionary<UUID, int>();
Object classifiedLock;
public Scene Scene public Scene Scene
{ {
@ -329,10 +330,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
if(!classifiedCache.ContainsKey(cid)) if(!classifiedCache.ContainsKey(cid))
{ {
lock(classifiedCache)
classifiedCache.Add(cid,creatorId); classifiedCache.Add(cid,creatorId);
lock(classifiedInterest)
classifiedInterest.Add(cid, 0); classifiedInterest.Add(cid, 0);
} }
lock(classifiedInterest)
classifiedInterest[cid] ++; classifiedInterest[cid] ++;
} }
@ -349,19 +353,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
{ {
target = classifiedCache[queryClassifiedID]; target = classifiedCache[queryClassifiedID];
if(classifiedInterest[queryClassifiedID] -- == 0) lock(classifiedInterest)
{ classifiedInterest[queryClassifiedID] --;
lock(classifiedCache)
if(classifiedInterest[queryClassifiedID] == 0)
{ {
lock(classifiedInterest) lock(classifiedInterest)
{
classifiedInterest.Remove(queryClassifiedID); classifiedInterest.Remove(queryClassifiedID);
} lock(classifiedCache)
classifiedCache.Remove(queryClassifiedID); classifiedCache.Remove(queryClassifiedID);
} }
} }
}
string serverURI = string.Empty; string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(target, out serverURI); bool foreign = GetUserProfileServerURI(target, out serverURI);

View File

@ -121,6 +121,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <remarks> /// <remarks>
/// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is
/// necessary. /// necessary.
/// NOTE: To avoid deadlocks, do not lock m_attachments and then perform other tasks under that lock. Take a copy
/// of the list and act on that instead.
/// </remarks> /// </remarks>
private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
@ -971,22 +973,30 @@ namespace OpenSim.Region.Framework.Scenes
// and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
// be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
// not transporting the required data. // not transporting the required data.
lock (m_attachments) //
{ // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of
if (HasAttachments()) // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here
// which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status.
//
// FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts().
// But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing
// is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the
// script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine.
List<SceneObjectGroup> attachments = GetAttachments();
if (attachments.Count > 0)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
// Resume scripts // Resume scripts
foreach (SceneObjectGroup sog in m_attachments) foreach (SceneObjectGroup sog in attachments)
{ {
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
sog.ResumeScripts(); sog.ResumeScripts();
} }
} }
} }
}
// send the animations of the other presences to me // send the animations of the other presences to me
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)

View File

@ -360,7 +360,7 @@ public static class BSParam
new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat", new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat",
false ), false ),
new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval", new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval",
0.1f ), 0.089f ),
new ParameterDefn<bool>("MeshSculptedPrim", "Whether to create meshes for sculpties", new ParameterDefn<bool>("MeshSculptedPrim", "Whether to create meshes for sculpties",
true, true,

View File

@ -388,10 +388,22 @@ public class BSShapeMesh : BSShape
return retMesh; return retMesh;
} }
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
{
BSShape ret = null;
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
// and we must create a copy of the native shape since they are never shared.
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
{
// TODO: decide when the native shapes should be freed. Check in Dereference?
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
}
else
{ {
// Another reference to this shape is just counted. // Another reference to this shape is just counted.
IncrementReference(); IncrementReference();
return this; ret = this;
}
return ret;
} }
public override void Dereference(BSScene physicsScene) public override void Dereference(BSScene physicsScene)
{ {
@ -559,10 +571,22 @@ public class BSShapeHull : BSShape
return retHull; return retHull;
} }
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
{
BSShape ret = null;
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
// and we must create a copy of the native shape since they are never shared.
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
{
// TODO: decide when the native shapes should be freed. Check in Dereference?
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
}
else
{ {
// Another reference to this shape is just counted. // Another reference to this shape is just counted.
IncrementReference(); IncrementReference();
return this; ret = this;
}
return ret;
} }
public override void Dereference(BSScene physicsScene) public override void Dereference(BSScene physicsScene)
{ {
@ -1075,12 +1099,23 @@ public class BSShapeGImpact : BSShape
(w, iC, i, vC, v) => physicsScene.PE.CreateGImpactShape(w, iC, i, vC, v) ); (w, iC, i, vC, v) => physicsScene.PE.CreateGImpactShape(w, iC, i, vC, v) );
} }
public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
{ {
// Calling this reference means we want another handle to an existing shape BSShape ret = null;
// (usually linksets) so return this copy. // If the underlying shape is native, the actual shape has not been build (waiting for asset)
// and we must create a copy of the native shape since they are never shared.
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
{
// TODO: decide when the native shapes should be freed. Check in Dereference?
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
}
else
{
// Another reference to this shape is just counted.
IncrementReference(); IncrementReference();
return this; ret = this;
}
return ret;
} }
// Dereferencing a compound shape releases the hold on all the child shapes. // Dereferencing a compound shape releases the hold on all the child shapes.
public override void Dereference(BSScene physicsScene) public override void Dereference(BSScene physicsScene)