]> granicus.if.org Git - icinga2/commitdiff
Make the ThreadPool spawn fewer threads
authorGunnar Beutner <gunnar@beutner.name>
Sat, 6 Dec 2014 18:21:30 +0000 (19:21 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 6 Dec 2014 18:23:27 +0000 (19:23 +0100)
lib/base/threadpool.cpp
lib/base/threadpool.hpp

index aee587e66f332b5f01a695ff95a9bb71b49bce63..2a814134fd9a106c78ace552845b6ccbb080081b 100644 (file)
@@ -265,18 +265,17 @@ void ThreadPool::ManagerThreadProc(void)
 
                                int tthreads = wthreads - alive;
 
-                               /* Make sure there is at least one thread per CPU */
-                               int ncput = std::max(static_cast<unsigned int>(Application::GetConcurrency()) / QUEUECOUNT, 4U);
-                               if (alive + tthreads < ncput)
-                                       tthreads = ncput - alive;
+                               /* Make sure there is at least one thread per queue */
+                               if (alive + tthreads < 1)
+                                       tthreads = 1 - alive;
 
-                               /* Don't kill more than 8 threads at once. */
-                               if (tthreads < -8)
-                                       tthreads = -8;
+                               /* Don't kill more than 2 threads at once. */
+                               if (tthreads < -2)
+                                       tthreads = -2;
 
                                /* Spawn more workers if there are outstanding work items. */
                                if (tthreads > 0 && pending > 0)
-                                       tthreads = 8;
+                                       tthreads = 2;
 
                                if (m_MaxThreads != UINT_MAX && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads)
                                        tthreads = m_MaxThreads / (sizeof(m_Queues) / sizeof(m_Queues[0])) - alive;
index afae6c0b840d6c434588f221bddac52140eacb69..04faa19ecef7a56cef2176e085bdacd44ac3088c 100644 (file)
@@ -30,7 +30,7 @@
 namespace icinga
 {
 
-#define QUEUECOUNT 4
+#define QUEUECOUNT 4U
 
 enum SchedulerPolicy
 {