Applying the same fix here that dan lake applied to master -- unfortunately I can't cherry-pick because that commit has 2 parents...

cpu-performance
Diva Canto 2013-07-18 07:52:14 -07:00
parent c685cc1799
commit 553d9cc5d2
2 changed files with 8 additions and 3 deletions

View File

@ -1779,10 +1779,12 @@ namespace OpenSim.Framework
FireAndForget(callback, null); FireAndForget(callback, null);
} }
public static void InitThreadPool(int maxThreads) public static void InitThreadPool(int minThreads, int maxThreads)
{ {
if (maxThreads < 2) if (maxThreads < 2)
throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
if (minThreads > maxThreads || minThreads < 2)
throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads");
if (m_ThreadPool != null) if (m_ThreadPool != null)
throw new InvalidOperationException("SmartThreadPool is already initialized"); throw new InvalidOperationException("SmartThreadPool is already initialized");
@ -1791,6 +1793,7 @@ namespace OpenSim.Framework
startInfo.IdleTimeout = 2000; startInfo.IdleTimeout = 2000;
startInfo.MaxWorkerThreads = maxThreads; startInfo.MaxWorkerThreads = maxThreads;
startInfo.MinWorkerThreads = 2; startInfo.MinWorkerThreads = 2;
startInfo.MinWorkerThreads = minThreads;
m_ThreadPool = new SmartThreadPool(startInfo); m_ThreadPool = new SmartThreadPool(startInfo);
} }
@ -1865,7 +1868,7 @@ namespace OpenSim.Framework
break; break;
case FireAndForgetMethod.SmartThreadPool: case FireAndForgetMethod.SmartThreadPool:
if (m_ThreadPool == null) if (m_ThreadPool == null)
InitThreadPool(15); InitThreadPool(2, 15);
m_ThreadPool.QueueWorkItem((cb, o) => cb(o), realCallback, obj); m_ThreadPool.QueueWorkItem((cb, o) => cb(o), realCallback, obj);
break; break;
case FireAndForgetMethod.Thread: case FireAndForgetMethod.Thread:

View File

@ -86,6 +86,7 @@ namespace OpenSim
IConfig startupConfig = Config.Configs["Startup"]; IConfig startupConfig = Config.Configs["Startup"];
IConfig networkConfig = Config.Configs["Network"]; IConfig networkConfig = Config.Configs["Network"];
int stpMinThreads = 2;
int stpMaxThreads = 15; int stpMaxThreads = 15;
if (startupConfig != null) if (startupConfig != null)
@ -112,12 +113,13 @@ namespace OpenSim
if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
Util.FireAndForgetMethod = asyncCallMethod; Util.FireAndForgetMethod = asyncCallMethod;
stpMinThreads = startupConfig.GetInt("MinPoolThreads", 15);
stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15); stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15);
m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) "); m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) ");
} }
if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
Util.InitThreadPool(stpMaxThreads); Util.InitThreadPool(stpMinThreads, stpMaxThreads);
m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
} }