From 33448e4ba83b590e0e7e340faf3d7f2cef80c611 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Mon, 26 Oct 2009 07:50:25 -0700 Subject: Optimizations --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 2b858ec..37ec5df 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private StateSource m_stateSource; private bool m_postOnRez; private bool m_startedFromSavedState = false; - private string m_CurrentState = String.Empty; + private int m_CurrentStateHash; private UUID m_RegionID = UUID.Zero; private Dictionary, KeyValuePair> @@ -252,16 +252,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { m_Apis[api] = am.CreateApi(api); m_Apis[api].Initialize(engine, part, m_LocalID, itemID); - } + } + + try + { + if (dom != System.AppDomain.CurrentDomain) + m_Script = (IScript)dom.CreateInstanceAndUnwrap( + Path.GetFileNameWithoutExtension(assembly), + "SecondLife.Script"); + else + m_Script = (IScript)Assembly.Load( + Path.GetFileNameWithoutExtension(assembly)).CreateInstance( + "SecondLife.Script"); - try - { - m_Script = (IScript)dom.CreateInstanceAndUnwrap( - Path.GetFileNameWithoutExtension(assembly), - "SecondLife.Script"); //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); - RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); // lease.Register(this); } catch (Exception) @@ -893,7 +899,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance string xml = ScriptSerializer.Serialize(this); - if (m_CurrentState != xml) + // Compare hash of the state we just just created with the state last written to disk + // If the state is different, update the disk file. + if(xml.GetHashCode() != m_CurrentStateHash) { try { @@ -911,7 +919,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance //{ // throw new Exception("Completed persistence save, but no file was created"); //} - m_CurrentState = xml; + m_CurrentStateHash = xml.GetHashCode(); } } -- cgit v1.1 From dd13fa361b12fa2fb1c91c9f74379a305935a87d Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 05:56:37 -0700 Subject: * Misc. formatting cleanup for the previous patch * Added the new AppDomainLoading variable to the [XEngine] section in the example config --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 37ec5df..f16aefc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private StateSource m_stateSource; private bool m_postOnRez; private bool m_startedFromSavedState = false; - private int m_CurrentStateHash; + private UUID m_CurrentStateHash; private UUID m_RegionID = UUID.Zero; private Dictionary, KeyValuePair> @@ -901,7 +901,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // Compare hash of the state we just just created with the state last written to disk // If the state is different, update the disk file. - if(xml.GetHashCode() != m_CurrentStateHash) + UUID hash = UUID.Parse(Utils.MD5String(xml)); + + if(hash != m_CurrentStateHash) { try { @@ -919,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance //{ // throw new Exception("Completed persistence save, but no file was created"); //} - m_CurrentStateHash = xml.GetHashCode(); + m_CurrentStateHash = hash; } } -- cgit v1.1 From ec7fd8b1f810a13e7f78448e9ef81113ed3c5bf0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 06:42:40 -0700 Subject: More performance improvements to XEngine script loading --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f16aefc..549c038 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -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> m_LineMap; -- cgit v1.1