general: use IdlePriority rather than LowPriority

Fixes a number of playback stuttering and general UI lag issues by setting all
background tasks to IdlePriority rather than LowPriority. While it was assumed
LowPriority tasks would always get scheduled below NormalPriority (e.g. main
thread) tasks, it turns out this is not always the case. If the background tasks
start consuming a lot of CPU cycles, the scheduler may use "dynamic scheduling"
to schedule them above the main thread regardless leading to UI lag. This is
apparently the case for all thread priorities apart from IdlePriority, which
is allegedly a special case where threads are *only* scheduled when other
threads aren't busy ensuring the main thread stays responsive.
This commit is contained in:
itsmattkc
2020-02-20 17:48:50 +11:00
parent 054281596e
commit 5a070f14de
5 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ void AudioManager::RefreshDevices()
QThread* thread = new QThread();
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start(QThread::LowPriority);
thread->start(QThread::IdlePriority);
AudioRefreshDevicesObject* refresher = new AudioRefreshDevicesObject();
connect(refresher, &AudioRefreshDevicesObject::ListsReady, this, &AudioManager::RefreshThreadDone);
+1 -1
View File
@@ -34,7 +34,7 @@ void TaskDialog::open()
}
// Create a separate thread to run this task in
thread_->start(QThread::LowPriority);
thread_->start();
// Move the task to this thread
task_->moveToThread(thread_);
+1 -1
View File
@@ -25,7 +25,7 @@ bool OpenGLBackend::InitInternal()
proxy_ = new OpenGLProxy();
proxy_->SetParameters(params());
QThread* proxy_thread = new QThread();
proxy_thread->start(QThread::LowPriority);
proxy_thread->start(QThread::IdlePriority);
proxy_->moveToThread(proxy_thread);
if (!proxy_->Init()) {
+1 -1
View File
@@ -35,7 +35,7 @@ bool RenderBackend::Init()
threads_.replace(i, thread);
// We use low priority to keep the app responsive at all times (GUI thread should always prioritize over this one)
thread->start(QThread::LowPriority);
thread->start(QThread::IdlePriority);
}
cancel_dialog_->SetWorkerCount(threads_.size());
+1 -1
View File
@@ -34,7 +34,7 @@ TaskManager::TaskManager() :
for (int i=0;i<threads_.size();i++) {
QThread* t = new QThread(this);
t->start(QThread::LowPriority);
t->start(QThread::IdlePriority);
threads_.replace(i, {t, false});
}
}