diff options
author | Tedd Hansen | 2008-02-01 20:12:25 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-01 20:12:25 +0000 |
commit | a9c1f3fdb4f7c7de0fe5e61ed0ecad7318137973 (patch) | |
tree | b4f7d09923248de11a88b7faf1f40521e9f1efc6 /OpenSim/Region/ScriptEngine/Common | |
parent | Highly experimental (diff) | |
download | opensim-SC_OLD-a9c1f3fdb4f7c7de0fe5e61ed0ecad7318137973.zip opensim-SC_OLD-a9c1f3fdb4f7c7de0fe5e61ed0ecad7318137973.tar.gz opensim-SC_OLD-a9c1f3fdb4f7c7de0fe5e61ed0ecad7318137973.tar.bz2 opensim-SC_OLD-a9c1f3fdb4f7c7de0fe5e61ed0ecad7318137973.tar.xz |
Experimental
Moved DotNetScriptEngine configuration to config file.
Added option to share script execution threads between regions.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common')
3 files changed, 55 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs index 70db724..730b63e 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs | |||
@@ -69,21 +69,25 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
69 | /// <summary> | 69 | /// <summary> |
70 | /// List of threads processing event queue | 70 | /// List of threads processing event queue |
71 | /// </summary> | 71 | /// </summary> |
72 | private List<EventQueueThreadClass> eventQueueThreads = new List<EventQueueThreadClass>(); | 72 | private List<EventQueueThreadClass> eventQueueThreads;// = new List<EventQueueThreadClass>(); |
73 | private object eventQueueThreadsLock = new object(); | 73 | private object eventQueueThreadsLock;// = new object(); |
74 | |||
75 | private static List<EventQueueThreadClass> staticEventQueueThreads;// = new List<EventQueueThreadClass>(); | ||
76 | private static object staticEventQueueThreadsLock;// = new object(); | ||
74 | 77 | ||
75 | public object queueLock = new object(); // Mutex lock object | 78 | public object queueLock = new object(); // Mutex lock object |
76 | 79 | ||
77 | /// <summary> | 80 | /// <summary> |
78 | /// How many threads to process queue with | 81 | /// How many threads to process queue with |
79 | /// </summary> | 82 | /// </summary> |
80 | private int numberOfThreads = 2; | 83 | private int numberOfThreads; |
81 | 84 | ||
82 | /// <summary> | 85 | /// <summary> |
83 | /// Maximum time one function can use for execution before we perform a thread kill | 86 | /// Maximum time one function can use for execution before we perform a thread kill |
84 | /// </summary> | 87 | /// </summary> |
85 | private int maxFunctionExecutionTimems = 50; | 88 | private int maxFunctionExecutionTimems; |
86 | private bool EnforceMaxExecutionTime = true; | 89 | private bool EnforceMaxExecutionTime; |
90 | |||
87 | 91 | ||
88 | /// <summary> | 92 | /// <summary> |
89 | /// Queue containing events waiting to be executed | 93 | /// Queue containing events waiting to be executed |
@@ -138,6 +142,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
138 | { | 142 | { |
139 | m_ScriptEngine = _ScriptEngine; | 143 | m_ScriptEngine = _ScriptEngine; |
140 | 144 | ||
145 | |||
146 | // Create thread pool list and lock object | ||
147 | // Determine from config if threads should be dedicated to regions or shared | ||
148 | if (m_ScriptEngine.ScriptConfigSource.GetBoolean("PrivateRegionThreads", false)) | ||
149 | { | ||
150 | // PRIVATE THREAD POOL PER REGION | ||
151 | eventQueueThreads = new List<EventQueueThreadClass>(); | ||
152 | eventQueueThreadsLock = new object(); | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | // SHARED THREAD POOL | ||
157 | // Crate the objects in statics | ||
158 | if (staticEventQueueThreads == null) | ||
159 | staticEventQueueThreads = new List<EventQueueThreadClass>(); | ||
160 | if (staticEventQueueThreadsLock == null) | ||
161 | staticEventQueueThreadsLock = new object(); | ||
162 | |||
163 | // Create local reference to them | ||
164 | eventQueueThreads = staticEventQueueThreads; | ||
165 | eventQueueThreadsLock = staticEventQueueThreadsLock; | ||
166 | } | ||
167 | |||
168 | numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2); | ||
169 | |||
170 | maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000); | ||
171 | EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", false); | ||
172 | |||
173 | |||
174 | |||
141 | // Start function max exec time enforcement thread | 175 | // Start function max exec time enforcement thread |
142 | if (EnforceMaxExecutionTime) | 176 | if (EnforceMaxExecutionTime) |
143 | { | 177 | { |
@@ -150,9 +184,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
150 | // | 184 | // |
151 | // Start event queue processing threads (worker threads) | 185 | // Start event queue processing threads (worker threads) |
152 | // | 186 | // |
187 | |||
153 | lock (eventQueueThreadsLock) | 188 | lock (eventQueueThreadsLock) |
154 | { | 189 | { |
155 | for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++) | 190 | for (int ThreadCount = eventQueueThreads.Count; ThreadCount <= numberOfThreads; ThreadCount++) |
156 | { | 191 | { |
157 | StartNewThreadClass(); | 192 | StartNewThreadClass(); |
158 | } | 193 | } |
@@ -315,7 +350,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
315 | } | 350 | } |
316 | } | 351 | } |
317 | 352 | ||
318 | private static void AbortThreadClass(EventQueueThreadClass threadClass) | 353 | private void AbortThreadClass(EventQueueThreadClass threadClass) |
319 | { | 354 | { |
320 | try | 355 | try |
321 | { | 356 | { |
@@ -326,12 +361,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
326 | Console.WriteLine("Could you please report this to Tedd:"); | 361 | Console.WriteLine("Could you please report this to Tedd:"); |
327 | Console.WriteLine("Script thread execution timeout kill ended in exception: " + ex.ToString()); | 362 | Console.WriteLine("Script thread execution timeout kill ended in exception: " + ex.ToString()); |
328 | } | 363 | } |
364 | m_ScriptEngine.Log.Debug("DotNetEngine", "Killed script execution thread, count: " + eventQueueThreads.Count); | ||
329 | } | 365 | } |
330 | 366 | ||
331 | private void StartNewThreadClass() | 367 | private void StartNewThreadClass() |
332 | { | 368 | { |
333 | EventQueueThreadClass eqtc = new EventQueueThreadClass(this); | 369 | EventQueueThreadClass eqtc = new EventQueueThreadClass(this); |
334 | eventQueueThreads.Add(eqtc); | 370 | eventQueueThreads.Add(eqtc); |
371 | m_ScriptEngine.Log.Debug("DotNetEngine", "Started new script execution thread, count: " + eventQueueThreads.Count); | ||
372 | |||
335 | } | 373 | } |
336 | } | 374 | } |
337 | } \ No newline at end of file | 375 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs index ad79fbc..67cf0e2 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs | |||
@@ -3,6 +3,7 @@ using System.Collections.Generic; | |||
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Threading; | 4 | using System.Threading; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using Nini.Config; | ||
6 | using OpenSim.Framework; | 7 | using OpenSim.Framework; |
7 | using OpenSim.Region.Environment.Scenes.Scripting; | 8 | using OpenSim.Region.Environment.Scenes.Scripting; |
8 | 9 | ||
@@ -16,7 +17,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
16 | /// <summary> | 17 | /// <summary> |
17 | /// How many ms to sleep if queue is empty | 18 | /// How many ms to sleep if queue is empty |
18 | /// </summary> | 19 | /// </summary> |
19 | private int nothingToDoSleepms = 50; | 20 | private int nothingToDoSleepms;// = 50; |
20 | 21 | ||
21 | public DateTime LastExecutionStarted; | 22 | public DateTime LastExecutionStarted; |
22 | public bool InExecution = false; | 23 | public bool InExecution = false; |
@@ -28,6 +29,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
28 | public EventQueueThreadClass(EventQueueManager eqm) | 29 | public EventQueueThreadClass(EventQueueManager eqm) |
29 | { | 30 | { |
30 | eventQueueManager = eqm; | 31 | eventQueueManager = eqm; |
32 | nothingToDoSleepms = eqm.m_ScriptEngine.ScriptConfigSource.GetInt("SleepTimeIfNoScriptExecutionMs", 50); | ||
31 | Start(); | 33 | Start(); |
32 | } | 34 | } |
33 | 35 | ||
@@ -183,7 +185,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
183 | } | 185 | } |
184 | catch (ThreadAbortException tae) | 186 | catch (ThreadAbortException tae) |
185 | { | 187 | { |
186 | throw tae; | 188 | eventQueueManager.m_ScriptEngine.Log.Notice("ScriptEngine", "ThreadAbortException while executing function."); |
187 | } | 189 | } |
188 | catch (Exception e) | 190 | catch (Exception e) |
189 | { | 191 | { |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs index da0baba..8b64d3d 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs | |||
@@ -51,10 +51,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
51 | public AppDomainManager m_AppDomainManager; | 51 | public AppDomainManager m_AppDomainManager; |
52 | public LSLLongCmdHandler m_LSLLongCmdHandler; | 52 | public LSLLongCmdHandler m_LSLLongCmdHandler; |
53 | 53 | ||
54 | public IConfigSource ConfigSource; | ||
55 | public IConfig ScriptConfigSource; | ||
56 | public abstract string ScriptConfigSourceName { get; } | ||
57 | |||
54 | public ScriptManager GetScriptManager() | 58 | public ScriptManager GetScriptManager() |
55 | { | 59 | { |
56 | return _GetScriptManager(); | 60 | return _GetScriptManager(); |
57 | } | 61 | } |
62 | |||
58 | public abstract ScriptManager _GetScriptManager(); | 63 | public abstract ScriptManager _GetScriptManager(); |
59 | 64 | ||
60 | private LogBase m_log; | 65 | private LogBase m_log; |
@@ -74,6 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
74 | { | 79 | { |
75 | World = Sceneworld; | 80 | World = Sceneworld; |
76 | m_log = logger; | 81 | m_log = logger; |
82 | ScriptConfigSource = ConfigSource.Configs[ScriptConfigSourceName]; | ||
77 | 83 | ||
78 | Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); | 84 | Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); |
79 | 85 | ||