From 73b20c2ca25e5ee6f1b6673ef764c4da40625ec3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Nov 2016 12:58:43 +0000 Subject: [PATCH] XEngine: make calls to gc.collect on region startup scripts loading a configurable option, since it is very slow operation --- .../Region/ScriptEngine/XEngine/XEngine.cs | 12 +++++------ bin/OpenSim.ini.example | 7 +++++++ bin/OpenSimDefaults.ini | 21 +++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 30389152f0..e12f8509bc 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -110,6 +110,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private int m_ScriptFailCount; // Number of script fails since compile queue was last empty private string m_ScriptErrorMessage; private bool m_AppDomainLoading; + private bool m_CompactMemOnLoad; private Dictionary m_ScriptErrors = new Dictionary(); @@ -301,8 +302,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; - m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", true); - + m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", false); + m_CompactMemOnLoad = m_ScriptConfig.GetBoolean("CompactMemOnLoad", false); m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; @@ -1278,10 +1279,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - // do not load a assembly on top of a lot of to release memory - // also yield a bit - // only if logins disable since causes a lot of rubber banding - if(!m_Scene.LoginsEnabled) + // optionaly do not load a assembly on top of a lot of to release memory + // only if logins disable since causes a lot of rubber banding + if(m_CompactMemOnLoad && !m_Scene.LoginsEnabled) GC.Collect(2); ScriptInstance instance = null; diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 4b83751daf..dce32bf07a 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -925,6 +925,13 @@ ;; by scripts have changed. ; DeleteScriptsOnStartup = true + ;# {CompactMemOnLoad} {} {compacts memory on each script load at startup?} {true false} false + ;; forces calls to memory garbage collector before loading each script DLL during region startup. + ;; Peek memory usage is reduced and region starts with a more compacted memory allocation. + ;; But this costs a lot of time, so region load will take a lot longer. + ;; it is more usefull if there are no previously compiled scripts DLLs (as with DeleteScriptsOnStartup = true) + ;CompactMemOnLoad = false + ;# {DefaultCompileLanguage} {Enabled:true} {Default script language?} {lsl vb cs} lsl ;; Default language for scripts ; DefaultCompileLanguage = "lsl" diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index e846e73e0e..cb320a260d 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1696,14 +1696,23 @@ ; this may only be a problem if regions stay alive for a long time with lots of scripts added or edited. ; at this time some mono versions seem to have problems with the true option ; so default is now false until a fix is found - AppDomainLoading = false + ; AppDomainLoading = false - ; Controls whether previously compiled scripts DLLs are deleted on sim restart. If you set this to false - ; then startup will be considerably faster since scripts won't need to be recompiled. However, then it becomes your responsibility to delete the - ; compiled scripts if you're recompiling OpenSim from source code and internal interfaces used - ; by scripts have changed. - ; DeleteScriptsOnStartup = false + ; Controls whether previously compiled scripts DLLs are deleted on sim restart. + ; If you set this to false then startup will be considerably faster since scripts won't need to be recompiled. + ; It should be true on first run after updating opensim binary version + ; after first run you can change to false. + ; You can also set it to false and delete the script DLLs by hand + ; This does not delete cached scripts state. + ; DeleteScriptsOnStartup = true + ; CompactMemOnLoad forces calls to memory garbage collector before loading each script binary + ; forces calls to memory garbage collector before loading each script DLL during region startup. + ; Peek memory usage is reduced and region starts with a more compacted memory allocation. + ; But this costs a lot of time, so region load will take a lot longer. + ; it is more usefull if there are no previously compiled scripts DLLs (or DeleteScriptsOnStartup = true) + ; CompactMemOnLoad = false + ; Controls whether scripts are stopped by aborting their threads externally (abort) ; or by co-operative checks inserted by OpenSimulator into compiled script (co-op). ; co-op will be more stable as aborting threads can cause instability.