diff options
author | Charles Krinke | 2008-05-25 19:26:21 +0000 |
---|---|---|
committer | Charles Krinke | 2008-05-25 19:26:21 +0000 |
commit | 83bfd29af889631ed2f22e774d50d80aa1ceb198 (patch) | |
tree | 9c93bde5a53b81daaa1f61e5796e8e000e573419 | |
parent | Thank you kindly, Tiffany for a patch that helps: (diff) | |
download | opensim-SC-83bfd29af889631ed2f22e774d50d80aa1ceb198.zip opensim-SC-83bfd29af889631ed2f22e774d50d80aa1ceb198.tar.gz opensim-SC-83bfd29af889631ed2f22e774d50d80aa1ceb198.tar.bz2 opensim-SC-83bfd29af889631ed2f22e774d50d80aa1ceb198.tar.xz |
Thank you very much, Xantor for a patch that:
Copying, reseting, dragging scripts cause unnecessary recompilation,
slowing down the simulator and filling up the ScriptEngines directory
with compiled .dll and misc. files.
This patch keeps track of compiled assets since the last simulator restarts,
and only recompiles new assets. (editing a script generates a new asset,
so no problems there).
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index c84975a..366aaf1 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs | |||
@@ -81,12 +81,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
81 | Unload = 2 | 81 | Unload = 2 |
82 | } | 82 | } |
83 | 83 | ||
84 | // Xantor 20080525: Keep a list of compiled scripts this session for reuse | ||
85 | public Dictionary<LLUUID, String> scriptList = new Dictionary<LLUUID, string>(); | ||
86 | |||
84 | // Object<string, Script<string, script>> | 87 | // Object<string, Script<string, script>> |
85 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 88 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
86 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | 89 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! |
87 | public Dictionary<uint, Dictionary<LLUUID, IScript>> Scripts = | 90 | public Dictionary<uint, Dictionary<LLUUID, IScript>> Scripts = |
88 | new Dictionary<uint, Dictionary<LLUUID, IScript>>(); | 91 | new Dictionary<uint, Dictionary<LLUUID, IScript>>(); |
89 | 92 | ||
93 | |||
90 | public Scene World | 94 | public Scene World |
91 | { | 95 | { |
92 | get { return m_scriptEngine.World; } | 96 | get { return m_scriptEngine.World; } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 55289d9..a328a58 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
29 | using libsecondlife; | 31 | using libsecondlife; |
30 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
31 | using OpenSim.Region.Environment.Scenes; | 33 | using OpenSim.Region.Environment.Scenes; |
@@ -43,6 +45,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
43 | } | 45 | } |
44 | private Compiler.LSL.Compiler LSLCompiler; | 46 | private Compiler.LSL.Compiler LSLCompiler; |
45 | 47 | ||
48 | private static readonly ILog m_log | ||
49 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
46 | 51 | ||
47 | public override void Initialize() | 52 | public override void Initialize() |
48 | { | 53 | { |
@@ -70,10 +75,31 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
70 | 75 | ||
71 | SceneObjectPart m_host = World.GetSceneObjectPart(localID); | 76 | SceneObjectPart m_host = World.GetSceneObjectPart(localID); |
72 | 77 | ||
78 | // Xantor 20080525: I need assetID here to see if we already compiled this one previously | ||
79 | LLUUID assetID = LLUUID.Zero; | ||
80 | TaskInventoryItem taskInventoryItem = new TaskInventoryItem(); | ||
81 | if(m_host.TaskInventory.TryGetValue(itemID,out taskInventoryItem)) | ||
82 | assetID = taskInventoryItem.AssetID; | ||
83 | |||
84 | |||
73 | try | 85 | try |
74 | { | 86 | { |
75 | // Compile (We assume LSL) | 87 | // Xantor 20080525 see if we already compiled this script this session, stop incessant recompiling on |
76 | CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); | 88 | // scriptreset, spawning of objects with embedded scripts etc. |
89 | |||
90 | if (scriptList.TryGetValue(assetID, out CompiledScriptFile)) | ||
91 | { | ||
92 | m_log.InfoFormat("[SCRIPT]: Found existing compile of assetID {0}: {1}", assetID, CompiledScriptFile); | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | // Compile (We assume LSL) | ||
97 | CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); | ||
98 | |||
99 | // Xantor 20080525 Save compiled scriptfile for later use | ||
100 | m_log.InfoFormat("[SCRIPT]: Compiled assetID {0}: {1}", assetID, CompiledScriptFile); | ||
101 | scriptList.Add(assetID, CompiledScriptFile); | ||
102 | } | ||
77 | 103 | ||
78 | //#if DEBUG | 104 | //#if DEBUG |
79 | //long before; | 105 | //long before; |