Commit 1d9e1277 authored by Simon Persson's avatar Simon Persson
Browse files

Make the indexing and saving processes very nice, both cpu and io-wise.

Only do it on linux for now, happy to accept tested patches for other OSs.
parent 0c273a6a
......@@ -25,6 +25,19 @@
#include <QTimer>
#ifdef Q_OS_LINUX
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/resource.h>
static void makeNice(int pPid) {
// See linux documentation Documentation/block/ioprio.txt for details of the syscall
syscall(SYS_ioprio_set, 1, pPid, 3 << 13 | 7);
setpriority(PRIO_PROCESS, pPid, 19);
}
#else
static void makeNice(int) {}
#endif
BupJob::BupJob(const BackupPlan *pBackupPlan, const QString &pDestinationPath, QObject *pParent)
:KJob(pParent), mBackupPlan(pBackupPlan), mDestinationPath(pDestinationPath)
{
......@@ -62,10 +75,15 @@ void BupJob::startIndexing() {
}
connect(&mIndexProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(slotIndexingDone(int,QProcess::ExitStatus)));
connect(&mIndexProcess, SIGNAL(started()), SLOT(slotIndexingStarted()));
mIndexProcess.start();
emit description(this, i18nc("@info:progress", "Checking what has changed since last backup..."));
}
void BupJob::slotIndexingStarted() {
makeNice(mIndexProcess.pid());
}
void BupJob::slotIndexingDone(int pExitCode, QProcess::ExitStatus pExitStatus) {
if(pExitStatus != QProcess::NormalExit || pExitCode != 0) {
setError(1);
......@@ -85,10 +103,15 @@ void BupJob::slotIndexingDone(int pExitCode, QProcess::ExitStatus pExitStatus) {
}
connect(&mSaveProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(slotSavingDone(int,QProcess::ExitStatus)));
connect(&mSaveProcess, SIGNAL(started()), SLOT(slotSavingStarted()));
mSaveProcess.start();
emit description(this, i18nc("@info:progress", "Saving changes to backup destination..."));
}
void BupJob::slotSavingStarted() {
makeNice(mSaveProcess.pid());
}
void BupJob::slotSavingDone(int pExitCode, QProcess::ExitStatus pExitStatus) {
if(pExitStatus != QProcess::NormalExit || pExitCode != 0) {
setError(1);
......
......@@ -36,7 +36,9 @@ public:
protected slots:
void startIndexing();
void slotIndexingStarted();
void slotIndexingDone(int pExitCode, QProcess::ExitStatus pExitStatus);
void slotSavingStarted();
void slotSavingDone(int pExitCode, QProcess::ExitStatus pExitStatus);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment