aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorAllen Kerensky2013-02-09 15:06:42 -0600
committerBlueWall2013-02-10 14:14:33 -0500
commit7524bd5a7ce332a9c63587423c79d6988e4c2896 (patch)
tree0ddf0c953342af7e6e0933d903adabab4b39b72c /OpenSim/Region
parentFix teleport/telehub issue: (diff)
downloadopensim-SC_OLD-7524bd5a7ce332a9c63587423c79d6988e4c2896.zip
opensim-SC_OLD-7524bd5a7ce332a9c63587423c79d6988e4c2896.tar.gz
opensim-SC_OLD-7524bd5a7ce332a9c63587423c79d6988e4c2896.tar.bz2
opensim-SC_OLD-7524bd5a7ce332a9c63587423c79d6988e4c2896.tar.xz
Additional ThreadPool worker and IOCP thread startup logic
Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/Application.cs45
1 files changed, 39 insertions, 6 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index 0f90d37..c3e7ec2 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -102,17 +102,50 @@ namespace OpenSim
102 m_log.InfoFormat( 102 m_log.InfoFormat(
103 "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset"); 103 "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");
104 104
105 // Increase the number of IOCP threads available. Mono defaults to a tragically low number 105 // Verify the Threadpool allocates or uses enough worker and IO completion threads
106 // .NET 2.0 workerthreads default to 50 * numcores
107 // .NET 3.0 workerthreads defaults to 250 * numcores
108 // .NET 4.0 workerthreads are dynamic based on bitness and OS resources
109 // Max IO Completion threads are 1000 on all 3 CLRs.
110 int workerThreadsMin = 500;
111 int workerThreadsMax = 1000; // may need further adjustment to match other CLR
112 int iocpThreadsMin = 1000;
113 int iocpThreadsMax = 2000; // may need further adjustment to match other CLR
106 int workerThreads, iocpThreads; 114 int workerThreads, iocpThreads;
107 System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads); 115 System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
108 m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads); 116 m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads);
109 if (workerThreads < 500 || iocpThreads < 1000) 117 if (workerThreads < workerThreadsMin)
110 { 118 {
111 workerThreads = 500; 119 workerThreads = workerThreadsMin;
112 iocpThreads = 1000; 120 m_log.InfoFormat("[OPENSIM MAIN]: Bumping up to worker threads to {0}",workerThreads);
113 m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads");
114 System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads);
115 } 121 }
122 if (workerThreads > workerThreadsMax)
123 {
124 workerThreads = workerThreadsMax;
125 m_log.InfoFormat("[OPENSIM MAIN]: Limiting worker threads to {0}",workerThreads);
126 }
127 // Increase the number of IOCP threads available.
128 // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
129 if (iocpThreads < iocpThreadsMin)
130 {
131 iocpThreads = iocpThreadsMin;
132 m_log.InfoFormat("[OPENSIM MAIN]: Bumping up IO completion threads to {0}",iocpThreads);
133 }
134 // Make sure we don't overallocate IOCP threads and thrash system resources
135 if ( iocpThreads > iocpThreadsMax )
136 {
137 iocpThreads = iocpThreadsMax;
138 m_log.InfoFormat("[OPENSIM MAIN]: Limiting IO completion threads to {0}",iocpThreads);
139 }
140 // set the resulting worker and IO completion thread counts back to ThreadPool
141 if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) )
142 {
143 m_log.InfoFormat("[OPENSIM MAIN]: Threadpool set to {0} worker threads and {1} IO completion threads", workerThreads, iocpThreads);
144 }
145 else
146 {
147 m_log.Info("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");
148 }
116 149
117 // Check if the system is compatible with OpenSimulator. 150 // Check if the system is compatible with OpenSimulator.
118 // Ensures that the minimum system requirements are met 151 // Ensures that the minimum system requirements are met