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:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user