mirror of
https://github.com/opensim/opensim.git
synced 2026-05-15 11:25:39 +08:00
Optimizations
This commit is contained in:
@@ -73,9 +73,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
private bool m_InitialStartup = true;
|
||||
private int m_ScriptFailCount; // Number of script fails since compile queue was last empty
|
||||
private string m_ScriptErrorMessage;
|
||||
private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>();
|
||||
private bool m_AppDomainLoading;
|
||||
|
||||
// disable warning: need to keep a reference to XEngine.EventManager
|
||||
// alive to avoid it being garbage collected
|
||||
// disable warning: need to keep a reference to XEngine.EventManager
|
||||
// alive to avoid it being garbage collected
|
||||
#pragma warning disable 414
|
||||
private EventManager m_EventManager;
|
||||
#pragma warning restore 414
|
||||
@@ -201,6 +203,7 @@ 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_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
|
||||
m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
|
||||
@@ -470,6 +473,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
if (engine != ScriptEngineName)
|
||||
return;
|
||||
|
||||
// If we've seen this exact script text before, use that reference instead
|
||||
if (m_uniqueScripts.ContainsKey(script))
|
||||
script = m_uniqueScripts[script];
|
||||
else
|
||||
m_uniqueScripts[script] = script;
|
||||
|
||||
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource};
|
||||
|
||||
if (stateSource == (int)StateSource.ScriptedRez)
|
||||
@@ -590,14 +599,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
{
|
||||
lock (m_AddingAssemblies)
|
||||
{
|
||||
assembly = (string)m_Compiler.PerformScriptCompile(script,
|
||||
assetID.ToString(), item.OwnerID);
|
||||
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
|
||||
if (!m_AddingAssemblies.ContainsKey(assembly)) {
|
||||
m_AddingAssemblies[assembly] = 1;
|
||||
} else {
|
||||
m_AddingAssemblies[assembly]++;
|
||||
}
|
||||
linemap = m_Compiler.LineMap();
|
||||
}
|
||||
|
||||
string[] warnings = m_Compiler.GetWarnings();
|
||||
@@ -696,19 +703,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
|
||||
Evidence evidence = new Evidence(baseEvidence);
|
||||
|
||||
AppDomain sandbox =
|
||||
AppDomain.CreateDomain(
|
||||
m_Scene.RegionInfo.RegionID.ToString(),
|
||||
evidence, appSetup);
|
||||
/*
|
||||
PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||
AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||
PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||
PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||
CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||
sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||
sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||
*/
|
||||
AppDomain sandbox;
|
||||
if (m_AppDomainLoading)
|
||||
sandbox = AppDomain.CreateDomain(
|
||||
m_Scene.RegionInfo.RegionID.ToString(),
|
||||
evidence, appSetup);
|
||||
else
|
||||
sandbox = AppDomain.CurrentDomain;
|
||||
/*
|
||||
PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||
AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||
PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||
PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||
CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||
sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||
sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||
*/
|
||||
m_AppDomains[appDomain] = sandbox;
|
||||
|
||||
m_AppDomains[appDomain].AssemblyResolve +=
|
||||
@@ -905,9 +915,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
AppDomain domain = m_AppDomains[id];
|
||||
m_AppDomains.Remove(id);
|
||||
|
||||
AppDomain.Unload(domain);
|
||||
if (domain != AppDomain.CurrentDomain)
|
||||
AppDomain.Unload(domain);
|
||||
domain = null;
|
||||
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
||||
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user