Better timing of MaintenanceThread's tasks (uses less CPU)
Updated OpenSim.ini.exampleafrisby-rexmerge
parent
582964800c
commit
0fb4374c1a
|
@ -41,6 +41,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
{
|
{
|
||||||
//public ScriptEngine m_ScriptEngine;
|
//public ScriptEngine m_ScriptEngine;
|
||||||
private int MaintenanceLoopms;
|
private int MaintenanceLoopms;
|
||||||
|
private int MaintenanceLoopTicks_ScriptLoadUnload;
|
||||||
|
private int MaintenanceLoopTicks_Other;
|
||||||
|
|
||||||
|
|
||||||
public MaintenanceThread()
|
public MaintenanceThread()
|
||||||
{
|
{
|
||||||
|
@ -63,6 +66,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
||||||
{
|
{
|
||||||
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
||||||
|
MaintenanceLoopTicks_ScriptLoadUnload = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
||||||
|
MaintenanceLoopTicks_Other = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +129,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
|
|
||||||
long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
|
long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
|
||||||
long Last_ReReadConfigFilens = DateTime.Now.Ticks;
|
long Last_ReReadConfigFilens = DateTime.Now.Ticks;
|
||||||
|
long Last_MaintenanceRun = 0;
|
||||||
|
int MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
|
||||||
|
int MaintenanceLoopTicks_Other_Count = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -132,15 +142,20 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
|
System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
|
||||||
//if (PleaseShutdown)
|
//if (PleaseShutdown)
|
||||||
// return;
|
// return;
|
||||||
|
MaintenanceLoopTicks_ScriptLoadUnload_Count++;
|
||||||
|
MaintenanceLoopTicks_Other_Count++;
|
||||||
|
|
||||||
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
||||||
{
|
{
|
||||||
lastScriptEngine = m_ScriptEngine;
|
lastScriptEngine = m_ScriptEngine;
|
||||||
if (m_ScriptEngine != null)
|
|
||||||
{
|
|
||||||
// Re-reading config every x seconds
|
// Re-reading config every x seconds
|
||||||
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
|
||||||
|
{
|
||||||
|
MaintenanceLoopTicks_Other_Count = 0;
|
||||||
// Check if its time to re-read config
|
// Check if its time to re-read config
|
||||||
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
||||||
m_ScriptEngine.RefreshConfigFilens)
|
m_ScriptEngine.RefreshConfigFilens)
|
||||||
|
@ -150,7 +165,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
m_ScriptEngine.ReadConfig();
|
m_ScriptEngine.ReadConfig();
|
||||||
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
|
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust number of running script threads if not correct
|
// Adjust number of running script threads if not correct
|
||||||
if (m_ScriptEngine.m_EventQueueManager != null)
|
if (m_ScriptEngine.m_EventQueueManager != null)
|
||||||
|
@ -168,11 +183,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
|
||||||
Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
|
Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
|
||||||
|
{
|
||||||
|
MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
|
||||||
// LOAD / UNLOAD SCRIPTS
|
// LOAD / UNLOAD SCRIPTS
|
||||||
if (m_ScriptEngine.m_ScriptManager != null)
|
if (m_ScriptEngine.m_ScriptManager != null)
|
||||||
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
|
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,8 @@ msgformat = "PRIVMSG {0} : {3} - {1} of {2}"
|
||||||
; Refresh ScriptEngine config options (these settings) every xx seconds
|
; Refresh ScriptEngine config options (these settings) every xx seconds
|
||||||
; 0 = Do not refresh
|
; 0 = Do not refresh
|
||||||
; Set it to number of seconds between refresh, for example 30.
|
; Set it to number of seconds between refresh, for example 30.
|
||||||
; Will allow you to change ScriptEngine settings while server is running just by editing this file.
|
; Will allow you to change ScriptEngine settings while server is running just by using "CONFIG SET" on console
|
||||||
; For example to increase or decrease number of threads.
|
; For example to increase or decrease number of threads: CONFIG SET NumberOfScriptThreads 10
|
||||||
; NOTE! Disabled for now. Feature does not work.
|
; NOTE! Disabled for now. Feature does not work.
|
||||||
RefreshConfig=0
|
RefreshConfig=0
|
||||||
|
|
||||||
|
@ -184,14 +184,6 @@ NumberOfScriptThreads=2
|
||||||
; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
|
; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
|
||||||
ScriptThreadPriority=BelowNormal
|
ScriptThreadPriority=BelowNormal
|
||||||
|
|
||||||
; Should the script threads be private for each region?
|
|
||||||
; true: Each region will get <NumberOfScriptThreads> dedicated to scripts within that region
|
|
||||||
; Number of threads will be <NumberOfScriptThreads>*<NumberOfRegions>
|
|
||||||
; false: All regions share <NumberOfScriptThreads> for all their scripts
|
|
||||||
; Note! If you run multiple script engines based on "OpenSim.Region.ScriptEngine.Common" then all of them will share the same threads.
|
|
||||||
; *** This setting will not work until you restart OpenSim
|
|
||||||
PrivateRegionThreads=false
|
|
||||||
|
|
||||||
; How long MAX should a script event be allowed to run (per event execution)?
|
; How long MAX should a script event be allowed to run (per event execution)?
|
||||||
; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
|
; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
|
||||||
; There is also a small speed penalty for every kill that is made
|
; There is also a small speed penalty for every kill that is made
|
||||||
|
@ -222,11 +214,22 @@ ScriptsPerAppDomain=1
|
||||||
; How long load/unload thread should sleep if there is nothing to do
|
; How long load/unload thread should sleep if there is nothing to do
|
||||||
; Higher value makes it respond slower when scripts are added/removed from prims
|
; Higher value makes it respond slower when scripts are added/removed from prims
|
||||||
; But once active it will process all in queue before sleeping again
|
; But once active it will process all in queue before sleeping again
|
||||||
ScriptLoadUnloadLoopms=30
|
|
||||||
|
|
||||||
; Loading and unloading of scripts is queued and processed by a separate thread.
|
|
||||||
; This thread can either be shared among all regions, or private (one thread per region)
|
; MaintenanceLoop
|
||||||
PrivateScriptLoadUnloadThread=false
|
; How often to run maintenance loop
|
||||||
|
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
|
||||||
|
MaintenanceLoopms=50
|
||||||
|
|
||||||
|
; How many maintenanceloops between each of these.
|
||||||
|
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
|
||||||
|
; Script loading/unloading
|
||||||
|
MaintenanceLoopTicks_ScriptLoadUnload=1
|
||||||
|
|
||||||
|
; Other tasks
|
||||||
|
; check if we need to reload config, adjust running config and enforce max execution time
|
||||||
|
MaintenanceLoopTicks_Other=10
|
||||||
|
|
||||||
|
|
||||||
; Maximum number of items in load/unload queue before we start rejecting loads
|
; Maximum number of items in load/unload queue before we start rejecting loads
|
||||||
; Note that we will only be rejecting load. Unloads will still be able to queue.
|
; Note that we will only be rejecting load. Unloads will still be able to queue.
|
||||||
|
|
Loading…
Reference in New Issue