use less threads on cache

By using one thread per logical CPU thread, we seemed to completely saturate
the CPU which would kill the performance of the main/GUI thread (despite the
other threads being low priority). We now use half of the logical threads, which
still sees good CPU usage and minimal performance impact while allowing the
main thread to respond to user actions.
This commit is contained in:
itsmattkc
2020-01-17 04:37:47 +11:00
parent 653709dc84
commit 0bc176fd62
6 changed files with 17 additions and 11 deletions
+4 -4
View File
@@ -29,14 +29,14 @@ void AudioRenderBackend::SetParameters(const AudioRenderingParams &params)
void AudioRenderBackend::ConnectViewer(ViewerOutput *node)
{
connect(node, SIGNAL(AudioChangedBetween(const rational&, const rational&)), this, SLOT(InvalidateCache(const rational&, const rational&)));
connect(node, SIGNAL(AudioGraphChanged()), this, SLOT(QueueRecompile()));
connect(node, &ViewerOutput::AudioChangedBetween, this, &AudioRenderBackend::InvalidateCache);
connect(node, &ViewerOutput::AudioGraphChanged, this, &AudioRenderBackend::QueueRecompile);
}
void AudioRenderBackend::DisconnectViewer(ViewerOutput *node)
{
disconnect(node, SIGNAL(AudioChangedBetween(const rational&, const rational&)), this, SLOT(InvalidateCache(const rational&, const rational&)));
disconnect(node, SIGNAL(AudioGraphChanged()), this, SLOT(QueueRecompile()));
disconnect(node, &ViewerOutput::AudioChangedBetween, this, &AudioRenderBackend::InvalidateCache);
disconnect(node, &ViewerOutput::AudioGraphChanged, this, &AudioRenderBackend::QueueRecompile);
}
bool AudioRenderBackend::GenerateCacheIDInternal(QCryptographicHash &hash)
@@ -61,7 +61,6 @@ OpenGLTexturePtr OpenGLBackend::GetCachedFrameAsTexture(const rational &time)
if (cached_frame != nullptr) {
master_texture_->Upload(cached_frame);
return master_texture_;
}
@@ -28,7 +28,6 @@ OpenGLFramebuffer::OpenGLFramebuffer() :
buffer_(0),
texture_(nullptr)
{
}
OpenGLFramebuffer::~OpenGLFramebuffer()
@@ -48,7 +47,7 @@ void OpenGLFramebuffer::Create(QOpenGLContext *ctx)
context_ = ctx;
connect(context_, SIGNAL(aboutToBeDestroyed()), this, SLOT(Destroy()));
connect(context_, &QOpenGLContext::aboutToBeDestroyed, this, &OpenGLFramebuffer::Destroy);
// Create framebuffer object
context_->functions()->glGenFramebuffers(1, &buffer_);
@@ -57,7 +56,7 @@ void OpenGLFramebuffer::Create(QOpenGLContext *ctx)
void OpenGLFramebuffer::Destroy()
{
if (context_ != nullptr) {
disconnect(context_, SIGNAL(aboutToBeDestroyed()), this, SLOT(Destroy()));
disconnect(context_, &QOpenGLContext::aboutToBeDestroyed, this, &OpenGLFramebuffer::Destroy);
context_->functions()->glDeleteFramebuffers(1, &buffer_);
+1 -1
View File
@@ -20,7 +20,7 @@ bool RenderBackend::Init()
return true;
}
threads_.resize(QThread::idealThreadCount());
threads_.resize(qMax(1, QThread::idealThreadCount() / 2));
for (int i=0;i<threads_.size();i++) {
QThread* thread = new QThread(this);
+8 -2
View File
@@ -5,6 +5,7 @@
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QStandardPaths>
#include "common/filefunctions.h"
#include "config/config.h"
@@ -15,7 +16,7 @@ DiskManager::DiskManager() :
consumption_(0)
{
// Try to load any current cache index from file
QFile cache_index_file(QDir(GetMediaCacheLocation()).filePath("index"));
QFile cache_index_file(GetCacheIndexFilename());
if (cache_index_file.open(QFile::ReadOnly)) {
QDataStream ds(&cache_index_file);
@@ -43,7 +44,7 @@ DiskManager::~DiskManager()
ClearDiskCache();
} else {
// Save current cache index
QFile cache_index_file(QDir(GetMediaCacheLocation()).filePath("index"));
QFile cache_index_file(GetCacheIndexFilename());
if (cache_index_file.open(QFile::WriteOnly)) {
QDataStream ds(&cache_index_file);
@@ -172,3 +173,8 @@ qint64 DiskManager::DiskLimit()
// Convert gigabytes to bytes
return qRound64(gigabytes * 1073741824);
}
QString DiskManager::GetCacheIndexFilename()
{
return QDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("diskindex");
}
+2
View File
@@ -36,6 +36,8 @@ private:
qint64 DiskLimit();
static QString GetCacheIndexFilename();
struct HashTime {
QString file_name;
QByteArray hash;