YEngine, change default number of exec threads to 2 of priority Normal. Let the threads priority a option on ini files

0.9.1.1
UbitUmarov 2019-11-22 07:01:17 +00:00
parent d5f918f945
commit 943d0935a6
4 changed files with 57 additions and 13 deletions

View File

@ -207,8 +207,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(!m_Enabled) if(!m_Enabled)
return; return;
numThreadScriptWorkers = m_Config.GetInt("NumThreadScriptWorkers", 1); numThreadScriptWorkers = m_Config.GetInt("NumThreadScriptWorkers", 2);
string priority = m_Config.GetString("Priority", "Normal");
m_TraceCalls = m_Config.GetBoolean("TraceCalls", false); m_TraceCalls = m_Config.GetBoolean("TraceCalls", false);
m_Verbose = m_Config.GetBoolean("Verbose", false); m_Verbose = m_Config.GetBoolean("Verbose", false);
m_ScriptDebug = m_Config.GetBoolean("ScriptDebug", false); m_ScriptDebug = m_Config.GetBoolean("ScriptDebug", false);
@ -250,9 +250,31 @@ namespace OpenSim.Region.ScriptEngine.Yengine
return; return;
} }
ThreadPriority workersPrio = ThreadPriority.Normal;
switch (priority)
{
case "Lowest":
workersPrio = ThreadPriority.Lowest;
break;
case "BelowNormal":
workersPrio = ThreadPriority.BelowNormal;
break;
case "Normal":
workersPrio = ThreadPriority.Normal;
break;
case "AboveNormal":
workersPrio = ThreadPriority.AboveNormal;
break;
case "Highest":
workersPrio = ThreadPriority.Highest;
break;
default:
m_log.ErrorFormat("[YEngine] Invalid thread priority: '{0}'. Assuming Normal", priority);
break;
}
m_SleepThread = StartMyThread(RunSleepThread, "Yengine sleep", ThreadPriority.Normal); m_SleepThread = StartMyThread(RunSleepThread, "Yengine sleep", ThreadPriority.Normal);
for(int i = 0; i < numThreadScriptWorkers; i++) for(int i = 0; i < numThreadScriptWorkers; i++)
StartThreadWorker(i); StartThreadWorker(i, workersPrio);
m_log.InfoFormat("[YEngine]: Enabled, {0}.{1} Meg (0x{2}) stacks", m_log.InfoFormat("[YEngine]: Enabled, {0}.{1} Meg (0x{2}) stacks",
(m_StackSize >> 20).ToString(), (m_StackSize >> 20).ToString(),

View File

@ -56,13 +56,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
} }
} }
public void StartThreadWorker(int i) public void StartThreadWorker(int i, ThreadPriority priority)
{ {
Thread thd; Thread thd;
if(i >= 0) if(i >= 0)
thd = Yengine.StartMyThread(RunScriptThread, "YScript" + i.ToString(), ThreadPriority.BelowNormal); thd = Yengine.StartMyThread(RunScriptThread, "YScript" + i.ToString(), priority);
else else
thd = Yengine.StartMyThread(RunScriptThread, "YScript", ThreadPriority.BelowNormal); thd = Yengine.StartMyThread(RunScriptThread, "YScript", priority);
lock(m_WakeUpLock) lock(m_WakeUpLock)
m_RunningInstances.Add(thd.ManagedThreadId, null); m_RunningInstances.Add(thd.ManagedThreadId, null);
} }

View File

@ -933,17 +933,12 @@
; PriceGroupCreate = 0 ; PriceGroupCreate = 0
[YEngine] [YEngine]
;; experimental engine
;; implements non preemptive microthreading, so fixing problems like llSleep or long events handlers ;; implements non preemptive microthreading, so fixing problems like llSleep or long events handlers
;; but those will suffer from timeslicing, so will be slower. ;; but those will suffer from timeslicing, so will be slower.
;; warning: scripts state is lost on TP or cross to Xengine regions (cars stop, etc) ;; warning: scripts state is lost on TP or cross to Xengine regions (cars stop, etc)
;; ignore its extensions (subset of original XMRengine), those are still undefined. ;; ignore its extensions (subset of original XMRengine), those are still undefined.
Enabled = false ; Enabled = false
ScriptStackSize = 256
ScriptHeapSize = 256
UseSourceHashCode = true
MinTimerInterval = 0.1
;ScriptBasePath="ScriptEngines"
[XEngine] [XEngine]
;# {Enabled} {} {Enable the XEngine scripting engine?} {true false} true ;# {Enabled} {} {Enable the XEngine scripting engine?} {true false} true

View File

@ -1750,6 +1750,33 @@
; MeshModelAllowTextureToInventory = true ; MeshModelAllowTextureToInventory = true
[YEngine]
;; implements non preemptive microthreading, so fixing problems like llSleep or long events handlers
;; but those will suffer from timeslicing, so will be slower.
;; warning: scripts state is lost on TP or cross to Xengine regions (cars stop, etc)
;; ignore its extensions (subset of original XMRengine), those are still undefined.
;Enabled = false
; maximum stack a script can use in KB
;ScriptStackSize = 2048
; maximum heap memory a script can use in KB
;ScriptHeapSize = 1024
; number of threads to execute script. Too many threads can have negative impact on other region operations
;NumThreadScriptWorkers = 2
; Priority of those threads (Lowest, BelowNormal, Normal, AboveNormal or Highest). Higher priorit can have negative impact on other region operations
;Priority = Normal
; to reuse binary compare sources using a hash codes of them or full text
UseSourceHashCode = true
MinTimerInterval = 0.1
; scripts states and cache parent folder location
;ScriptBasePath="ScriptEngines"
[XEngine] [XEngine]
; Enable this engine in this OpenSim instance ; Enable this engine in this OpenSim instance