From fcd59ea94f122c8644bf5a95cc7246cbf5ff382d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 12 Jul 2016 17:44:23 -0700 Subject: [PATCH] Update target number of processing threads to be based on system --- interface/src/Application.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5d5bf45dcf..d97dee6fd1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -169,7 +169,12 @@ static QTimer identityPacketTimer; static QTimer pingTimer; static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; -static const int PROCESSING_THREAD_POOL_SIZE = 6; + +// For processing on QThreadPool, target 2 less than the ideal number of threads, leaving +// 2 logical cores available for time sensitive tasks. +static const int MIN_PROCESSING_THREAD_POOL_SIZE = 2; +static const int PROCESSING_THREAD_POOL_SIZE = std::max(MIN_PROCESSING_THREAD_POOL_SIZE, + QThread::idealThreadCount() - 2); static const QString SNAPSHOT_EXTENSION = ".jpg"; static const QString SVO_EXTENSION = ".svo"; @@ -514,12 +519,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : PluginContainer* pluginContainer = dynamic_cast(this); // set the container for any plugins that care PluginManager::getInstance()->setContainer(pluginContainer); - // FIXME this may be excessively conservative. On the other hand - // maybe I'm used to having an 8-core machine - // Perhaps find the ideal thread count and subtract 2 or 3 - // (main thread, present thread, random OS load) - // More threads == faster concurrent loads, but also more concurrent - // load on the GPU until we can serialize GPU transfers (off the main thread) QThreadPool::globalInstance()->setMaxThreadCount(PROCESSING_THREAD_POOL_SIZE); thread()->setPriority(QThread::HighPriority); thread()->setObjectName("Main Thread");