aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs59
-rw-r--r--bin/OpenSim.ini.example31
2 files changed, 56 insertions, 34 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
index 0458a50..c329246 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs
@@ -41,6 +41,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
41 { 41 {
42 //public ScriptEngine m_ScriptEngine; 42 //public ScriptEngine m_ScriptEngine;
43 private int MaintenanceLoopms; 43 private int MaintenanceLoopms;
44 private int MaintenanceLoopTicks_ScriptLoadUnload;
45 private int MaintenanceLoopTicks_Other;
46
44 47
45 public MaintenanceThread() 48 public MaintenanceThread()
46 { 49 {
@@ -63,6 +66,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
63 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines) 66 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
64 { 67 {
65 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50); 68 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
69 MaintenanceLoopTicks_ScriptLoadUnload = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
70 MaintenanceLoopTicks_Other = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
71
66 return; 72 return;
67 } 73 }
68 } 74 }
@@ -123,6 +129,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
123 129
124 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks; 130 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
125 long Last_ReReadConfigFilens = DateTime.Now.Ticks; 131 long Last_ReReadConfigFilens = DateTime.Now.Ticks;
132 long Last_MaintenanceRun = 0;
133 int MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
134 int MaintenanceLoopTicks_Other_Count = 0;
135
126 while (true) 136 while (true)
127 { 137 {
128 try 138 try
@@ -132,15 +142,20 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
132 System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass 142 System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
133 //if (PleaseShutdown) 143 //if (PleaseShutdown)
134 // return; 144 // return;
145 MaintenanceLoopTicks_ScriptLoadUnload_Count++;
146 MaintenanceLoopTicks_Other_Count++;
147
135 148
136 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines)) 149 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
137 { 150 {
138 lastScriptEngine = m_ScriptEngine; 151 lastScriptEngine = m_ScriptEngine;
139 if (m_ScriptEngine != null) 152 // Re-reading config every x seconds
153 if (m_ScriptEngine.RefreshConfigFilens > 0)
140 { 154 {
141 // Re-reading config every x seconds 155
142 if (m_ScriptEngine.RefreshConfigFilens > 0) 156 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
143 { 157 {
158 MaintenanceLoopTicks_Other_Count = 0;
144 // Check if its time to re-read config 159 // Check if its time to re-read config
145 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > 160 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
146 m_ScriptEngine.RefreshConfigFilens) 161 m_ScriptEngine.RefreshConfigFilens)
@@ -150,29 +165,33 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
150 m_ScriptEngine.ReadConfig(); 165 m_ScriptEngine.ReadConfig();
151 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time 166 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
152 } 167 }
153 }
154 168
155 // Adjust number of running script threads if not correct
156 if (m_ScriptEngine.m_EventQueueManager != null)
157 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
158 169
159 // Check if any script has exceeded its max execution time 170 // Adjust number of running script threads if not correct
160 if (EventQueueManager.EnforceMaxExecutionTime) 171 if (m_ScriptEngine.m_EventQueueManager != null)
161 { 172 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
162 // We are enforcing execution time 173
163 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > 174 // Check if any script has exceeded its max execution time
164 EventQueueManager.maxFunctionExecutionTimens) 175 if (EventQueueManager.EnforceMaxExecutionTime)
165 { 176 {
166 // Its time to check again 177 // We are enforcing execution time
167 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check 178 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
168 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time 179 EventQueueManager.maxFunctionExecutionTimens)
180 {
181 // Its time to check again
182 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
183 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
184 }
169 } 185 }
170 } 186 }
171 187
172 // LOAD / UNLOAD SCRIPTS 188 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
173 if (m_ScriptEngine.m_ScriptManager != null) 189 {
174 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload(); 190 MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
175 191 // LOAD / UNLOAD SCRIPTS
192 if (m_ScriptEngine.m_ScriptManager != null)
193 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
194 }
176 } 195 }
177 } 196 }
178 } 197 }
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 732530b..793fe5b 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -171,8 +171,8 @@ msgformat = "PRIVMSG {0} : {3} - {1} of {2}"
171; Refresh ScriptEngine config options (these settings) every xx seconds 171; Refresh ScriptEngine config options (these settings) every xx seconds
172; 0 = Do not refresh 172; 0 = Do not refresh
173; Set it to number of seconds between refresh, for example 30. 173; Set it to number of seconds between refresh, for example 30.
174; Will allow you to change ScriptEngine settings while server is running just by editing this file. 174; Will allow you to change ScriptEngine settings while server is running just by using "CONFIG SET" on console
175; For example to increase or decrease number of threads. 175; For example to increase or decrease number of threads: CONFIG SET NumberOfScriptThreads 10
176; NOTE! Disabled for now. Feature does not work. 176; NOTE! Disabled for now. Feature does not work.
177RefreshConfig=0 177RefreshConfig=0
178 178
@@ -184,14 +184,6 @@ NumberOfScriptThreads=2
184; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest 184; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
185ScriptThreadPriority=BelowNormal 185ScriptThreadPriority=BelowNormal
186 186
187; Should the script threads be private for each region?
188; true: Each region will get <NumberOfScriptThreads> dedicated to scripts within that region
189; Number of threads will be <NumberOfScriptThreads>*<NumberOfRegions>
190; false: All regions share <NumberOfScriptThreads> for all their scripts
191; Note! If you run multiple script engines based on "OpenSim.Region.ScriptEngine.Common" then all of them will share the same threads.
192; *** This setting will not work until you restart OpenSim
193PrivateRegionThreads=false
194
195; How long MAX should a script event be allowed to run (per event execution)? 187; How long MAX should a script event be allowed to run (per event execution)?
196; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function 188; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
197; There is also a small speed penalty for every kill that is made 189; There is also a small speed penalty for every kill that is made
@@ -222,11 +214,22 @@ ScriptsPerAppDomain=1
222; How long load/unload thread should sleep if there is nothing to do 214; How long load/unload thread should sleep if there is nothing to do
223; Higher value makes it respond slower when scripts are added/removed from prims 215; Higher value makes it respond slower when scripts are added/removed from prims
224; But once active it will process all in queue before sleeping again 216; But once active it will process all in queue before sleeping again
225ScriptLoadUnloadLoopms=30
226 217
227; Loading and unloading of scripts is queued and processed by a separate thread. 218
228; This thread can either be shared among all regions, or private (one thread per region) 219; MaintenanceLoop
229PrivateScriptLoadUnloadThread=false 220; How often to run maintenance loop
221; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
222MaintenanceLoopms=50
223
224; How many maintenanceloops between each of these.
225; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
226; Script loading/unloading
227MaintenanceLoopTicks_ScriptLoadUnload=1
228
229; Other tasks
230; check if we need to reload config, adjust running config and enforce max execution time
231MaintenanceLoopTicks_Other=10
232
230 233
231; Maximum number of items in load/unload queue before we start rejecting loads 234; Maximum number of items in load/unload queue before we start rejecting loads
232; Note that we will only be rejecting load. Unloads will still be able to queue. 235; Note that we will only be rejecting load. Unloads will still be able to queue.