From 0fa303b1cf244b3066395413e640318b2122c19f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 20 Jun 2012 00:10:19 +0100
Subject: Log how many scripts are candidates for starting and how many are
actually started.
Adds DebugLevel infrastructure to XEngine though currently commented out and unused.
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 64 ++++++++++++++++++++++++--
1 file changed, 60 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index aedf2c1..3f623de 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -62,6 +62,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Control the printing of certain debug messages.
+ ///
+ ///
+ /// If DebugLevel >= 1, then we log every time that a script is started.
+ ///
+// public int DebugLevel { get; set; }
+
private SmartThreadPool m_ThreadPool;
private int m_MaxScriptQueue;
private Scene m_Scene;
@@ -216,9 +224,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
AppDomain.CurrentDomain.AssemblyResolve +=
OnAssemblyResolve;
- m_log.InfoFormat("[XEngine] Initializing scripts in region {0}",
- scene.RegionInfo.RegionName);
m_Scene = scene;
+ m_log.InfoFormat("[XEngine]: Initializing scripts in region {0}", m_Scene.RegionInfo.RegionName);
m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2);
m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
@@ -321,9 +328,42 @@ namespace OpenSim.Region.ScriptEngine.XEngine
"Starts all stopped scripts."
+ "If a is given then only that script will be started. Otherwise, all suitable scripts are started.",
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
+
+// MainConsole.Instance.Commands.AddCommand(
+// "Debug", false, "debug xengine", "debug xengine []",
+// "Turn on detailed xengine debugging.",
+// "If level <= 0, then no extra logging is done.\n"
+// + "If level >= 1, then we log every time that a script is started.",
+// HandleDebugLevelCommand);
}
///
+ /// Change debug level
+ ///
+ ///
+ ///
+// private void HandleDebugLevelCommand(string module, string[] args)
+// {
+// if (args.Length == 3)
+// {
+// int newDebug;
+// if (int.TryParse(args[2], out newDebug))
+// {
+// DebugLevel = newDebug;
+// MainConsole.Instance.OutputFormat("Debug level set to {0}", newDebug);
+// }
+// }
+// else if (args.Length == 2)
+// {
+// MainConsole.Instance.OutputFormat("Current debug level is {0}", DebugLevel);
+// }
+// else
+// {
+// MainConsole.Instance.Output("Usage: debug xengine 0..1");
+// }
+// }
+
+ ///
/// Parse the raw item id into a script instance from the command params if it's present.
///
///
@@ -825,8 +865,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
object[] o;
+
+ int scriptsStarted = 0;
+
while (m_CompileQueue.Dequeue(out o))
- DoOnRezScript(o);
+ {
+ if (DoOnRezScript(o))
+ {
+ scriptsStarted++;
+
+// if (scriptsStarted % 50 == 0)
+// m_log.DebugFormat(
+// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
+ }
+ }
+
+ m_log.DebugFormat(
+ "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
// NOTE: Despite having a lockless queue, this lock is required
// to make sure there is never no compile thread while there
@@ -1066,7 +1121,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
part.ParentGroup.RootPart.Name,
item.Name, startParam, postOnRez,
stateSource, m_MaxScriptQueue);
-
+
+// if (DebugLevel >= 1)
m_log.DebugFormat(
"[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
--
cgit v1.1