More performance improvements to XEngine script loading

0.6.8-post-fixes
John Hurliman 2009-10-29 06:42:40 -07:00
parent dd13fa361b
commit ec7fd8b1f8
2 changed files with 37 additions and 54 deletions

View File

@ -74,27 +74,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private string m_PrimName;
private string m_ScriptName;
private string m_Assembly;
private int m_StartParam = 0;
private int m_StartParam;
private string m_CurrentEvent = String.Empty;
private bool m_InSelfDelete = false;
private bool m_InSelfDelete;
private int m_MaxScriptQueue;
private bool m_SaveState = true;
private bool m_ShuttingDown = false;
private int m_ControlEventsInQueue = 0;
private int m_LastControlLevel = 0;
private bool m_CollisionInQueue = false;
private bool m_ShuttingDown;
private int m_ControlEventsInQueue;
private int m_LastControlLevel;
private bool m_CollisionInQueue;
private TaskInventoryItem m_thisScriptTask;
// The following is for setting a minimum delay between events
private double m_minEventDelay = 0;
private long m_eventDelayTicks = 0;
private long m_nextEventTimeTicks = 0;
private double m_minEventDelay;
private long m_eventDelayTicks;
private long m_nextEventTimeTicks;
private bool m_startOnInit = true;
private UUID m_AttachedAvatar = UUID.Zero;
private UUID m_AttachedAvatar;
private StateSource m_stateSource;
private bool m_postOnRez;
private bool m_startedFromSavedState = false;
private bool m_startedFromSavedState;
private UUID m_CurrentStateHash;
private UUID m_RegionID = UUID.Zero;
private UUID m_RegionID;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
m_LineMap;

View File

@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.CodeTools;
using OpenSim.Region.ScriptEngine.Shared.Instance;
using OpenSim.Region.ScriptEngine.Interfaces;
using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>;
using Parallel = OpenSim.Framework.Parallel;
namespace OpenSim.Region.ScriptEngine.XEngine
{
public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
@ -116,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private Dictionary<UUID, List<UUID> > m_DomainScripts =
new Dictionary<UUID, List<UUID> >();
private Queue m_CompileQueue = new Queue(100);
private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue();
IWorkItemResult m_CurrentCompile = null;
public string ScriptEngineName
@ -487,16 +490,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
else
{
lock (m_CompileQueue)
{
m_CompileQueue.Enqueue(parms);
m_CompileQueue.Enqueue(parms);
if (m_CurrentCompile == null)
{
m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback(this.DoOnRezScriptQueue),
new Object[0]);
}
if (m_CurrentCompile == null)
{
m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
}
}
}
@ -507,50 +505,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
m_InitialStartup = false;
System.Threading.Thread.Sleep(15000);
lock (m_CompileQueue)
if (m_CompileQueue.Count == 0)
{
if (m_CompileQueue.Count==0)
// No scripts on region, so won't get triggered later
// by the queue becoming empty so we trigger it here
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
// No scripts on region, so won't get triggered later
// by the queue becoming empty so we trigger it here
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
}
}
Object o;
lock (m_CompileQueue)
List<object[]> compiles = new List<object[]>();
object[] o;
while (m_CompileQueue.Dequeue(out o))
{
o = m_CompileQueue.Dequeue();
if (o == null)
{
m_CurrentCompile = null;
return null;
}
compiles.Add(o);
}
DoOnRezScript(o);
Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); });
m_CurrentCompile = null;
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
m_ScriptErrorMessage);
m_ScriptFailCount = 0;
lock (m_CompileQueue)
{
if (m_CompileQueue.Count > 0)
{
m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback(this.DoOnRezScriptQueue),
new Object[0]);
}
else
{
m_CurrentCompile = null;
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
m_ScriptErrorMessage);
m_ScriptFailCount = 0;
}
}
return null;
}
private bool DoOnRezScript(object parm)
private bool DoOnRezScript(object[] parms)
{
Object[] p = (Object[])parm;
Object[] p = parms;
uint localID = (uint)p[0];
UUID itemID = (UUID)p[1];
string script =(string)p[2];