diff options
Diffstat (limited to 'OpenSim/Region/Application/Application.cs')
-rw-r--r-- | OpenSim/Region/Application/Application.cs | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 0f90d37..bf34419 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs | |||
@@ -102,34 +102,81 @@ 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 | // | ||
111 | // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores | ||
112 | int workerThreadsMin = 500; | ||
113 | int workerThreadsMax = 1000; // may need further adjustment to match other CLR | ||
114 | int iocpThreadsMin = 1000; | ||
115 | int iocpThreadsMax = 2000; // may need further adjustment to match other CLR | ||
116 | |||
117 | { | ||
118 | int currentMinWorkerThreads, currentMinIocpThreads; | ||
119 | System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads); | ||
120 | m_log.InfoFormat( | ||
121 | "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads", | ||
122 | currentMinWorkerThreads, currentMinIocpThreads); | ||
123 | } | ||
124 | |||
106 | int workerThreads, iocpThreads; | 125 | int workerThreads, iocpThreads; |
107 | System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads); | 126 | 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); | 127 | m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads); |
109 | if (workerThreads < 500 || iocpThreads < 1000) | 128 | |
129 | if (workerThreads < workerThreadsMin) | ||
130 | { | ||
131 | workerThreads = workerThreadsMin; | ||
132 | m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}",workerThreads); | ||
133 | } | ||
134 | if (workerThreads > workerThreadsMax) | ||
110 | { | 135 | { |
111 | workerThreads = 500; | 136 | workerThreads = workerThreadsMax; |
112 | iocpThreads = 1000; | 137 | m_log.InfoFormat("[OPENSIM MAIN]: Limiting max 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 | } | 138 | } |
116 | 139 | ||
140 | // Increase the number of IOCP threads available. | ||
141 | // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17) | ||
142 | if (iocpThreads < iocpThreadsMin) | ||
143 | { | ||
144 | iocpThreads = iocpThreadsMin; | ||
145 | m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads); | ||
146 | } | ||
147 | // Make sure we don't overallocate IOCP threads and thrash system resources | ||
148 | if ( iocpThreads > iocpThreadsMax ) | ||
149 | { | ||
150 | iocpThreads = iocpThreadsMax; | ||
151 | m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}",iocpThreads); | ||
152 | } | ||
153 | // set the resulting worker and IO completion thread counts back to ThreadPool | ||
154 | if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) ) | ||
155 | { | ||
156 | m_log.InfoFormat( | ||
157 | "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads", | ||
158 | workerThreads, iocpThreads); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect."); | ||
163 | } | ||
164 | |||
117 | // Check if the system is compatible with OpenSimulator. | 165 | // Check if the system is compatible with OpenSimulator. |
118 | // Ensures that the minimum system requirements are met | 166 | // Ensures that the minimum system requirements are met |
119 | string supported = String.Empty; | 167 | string supported = String.Empty; |
120 | if (Util.IsEnvironmentSupported(ref supported)) | 168 | if (Util.IsEnvironmentSupported(ref supported)) |
121 | { | 169 | { |
122 | m_log.Info("Environment is compatible.\n"); | 170 | m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator."); |
123 | } | 171 | } |
124 | else | 172 | else |
125 | { | 173 | { |
126 | m_log.Warn("Environment is unsupported (" + supported + ")\n"); | 174 | m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n"); |
127 | } | 175 | } |
128 | 176 | ||
129 | // Configure nIni aliases and localles | 177 | // Configure nIni aliases and localles |
130 | Culture.SetCurrentCulture(); | 178 | Culture.SetCurrentCulture(); |
131 | 179 | ||
132 | |||
133 | // Validate that the user has the most basic configuration done | 180 | // Validate that the user has the most basic configuration done |
134 | // If not, offer to do the most basic configuration for them warning them along the way of the importance of | 181 | // If not, offer to do the most basic configuration for them warning them along the way of the importance of |
135 | // reading these files. | 182 | // reading these files. |