From a2cae5c288724124f78853ceb7ce732105543a90 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 16 Nov 2011 22:53:18 +0100 Subject: [PATCH] Slightly tweak algorithm to automatically set the number of instances: Instead of restricting the number of instances to 4, we now use '(cpu_cores / 2) + 2' instances for more than 4 CPU cores. For at most 4 CPU cores, we still use 'cpu_cores' instances. This way we can use more than 4 instances on CPU's with more than 4 cores, but the number of instances won't grow linearly with the number of CPU cores - should help a bit to avoid HDD thrashing. --- src/Dialog_Processing.cpp | 9 ++++----- src/Global.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index b6482c68..326b33a8 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -68,9 +68,6 @@ //Maximum number of parallel instances #define MAX_INSTANCES 16U -//Maximum number of CPU cores for auto-detection -#define MAX_CPU_COUNT 4U - //////////////////////////////////////////////////////////// #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \ @@ -126,6 +123,8 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel //Init progress indicator m_progressIndicator = new QMovie(":/images/Working.gif"); + m_progressIndicator->setCacheMode(QMovie::CacheAll); + m_progressIndicator->setSpeed(50); label_headerWorking->setMovie(m_progressIndicator); progressBar->setValue(0); @@ -361,7 +360,7 @@ void ProcessingDialog::initEncoding(void) if(maximumInstances < 1) { lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(); - maximumInstances = qBound(1U, static_cast(cpuFeatures.count), MAX_CPU_COUNT); + maximumInstances = (cpuFeatures.count > 4) ? ((cpuFeatures.count / 2) + 2) : cpuFeatures.count; } unsigned int parallelThreadCount = qBound(1U, maximumInstances, static_cast(m_pendingJobs.count())); @@ -965,4 +964,4 @@ bool ProcessingDialog::shutdownComputer(void) progressDialog.close(); return true; -} +} \ No newline at end of file diff --git a/src/Global.cpp b/src/Global.cpp index 521ef7b8..050eff40 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -616,7 +616,7 @@ lamexp_cpu_t lamexp_detect_cpu_features(int argc, char **argv) { GetSystemInfo(&systemInfo); } - features.count = systemInfo.dwNumberOfProcessors; + features.count = qBound(1UL, systemInfo.dwNumberOfProcessors, 64UL); #else GetNativeSystemInfo(&systemInfo); features.count = systemInfo.dwNumberOfProcessors;