From 6a66d74e19f4397f6a9371a1d0a5005ddd4320c5 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 8 Feb 2016 23:45:04 -0800 Subject: [PATCH] Limit the number of concurrent file parsing threads --- interface/src/Application.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ef0c2a588e..efc482a3b4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -12,13 +12,13 @@ #include "Application.h" #include - #include #include #include #include #include +#include #include #include #include @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -419,6 +420,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _maxOctreePPS(maxOctreePacketsPerSecond.get()), _lastFaceTrackerUpdate(0) { + // FIXME this may be excessivly 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(2); + thread()->setPriority(QThread::HighPriority); thread()->setObjectName("Main Thread"); setInstance(this); @@ -1287,6 +1296,9 @@ void Application::initializeUi() { } void Application::paintGL() { + + + // paintGL uses a queued connection, so we can get messages from the queue even after we've quit // and the plugins have shutdown if (_aboutToQuit) { @@ -4762,8 +4774,11 @@ void Application::updateDisplayMode() { foreach(auto displayPlugin, standard) { addDisplayPluginToMenu(displayPlugin, first); // This must be a queued connection to avoid a deadlock - QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, - this, &Application::paintGL, Qt::QueuedConnection); + QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, [=] { + postEvent(this, new LambdaEvent([=] { + paintGL(); + }), Qt::HighEventPriority); + }); QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) { resizeGL();