From 489d2e4ca50ecc3ecc3ece28304c352b4352a472 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 8 Jul 2016 15:33:11 -0700 Subject: [PATCH 1/2] Update max request limit and number of processing threads --- interface/src/Application.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 82cbaf93c2..5d5bf45dcf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -168,6 +168,9 @@ static QTimer locationUpdateTimer; static QTimer identityPacketTimer; static QTimer pingTimer; +static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; +static const int PROCESSING_THREAD_POOL_SIZE = 6; + static const QString SNAPSHOT_EXTENSION = ".jpg"; static const QString SVO_EXTENSION = ".svo"; static const QString SVO_JSON_EXTENSION = ".svo.json"; @@ -517,7 +520,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // (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(2); + QThreadPool::globalInstance()->setMaxThreadCount(PROCESSING_THREAD_POOL_SIZE); thread()->setPriority(QThread::HighPriority); thread()->setObjectName("Main Thread"); @@ -728,7 +731,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(&identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); identityPacketTimer.start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); - ResourceCache::setRequestLimit(3); + ResourceCache::setRequestLimit(MAX_CONCURRENT_RESOURCE_DOWNLOADS); _glWidget = new GLCanvas(); getApplicationCompositor().setRenderingWidget(_glWidget); From fcd59ea94f122c8644bf5a95cc7246cbf5ff382d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 12 Jul 2016 17:44:23 -0700 Subject: [PATCH 2/2] 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");