Skip to content

Commit

Permalink
v1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
K9spud LLC committed Mar 11, 2021
1 parent 858613d commit 5a6ef77
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ By keeping the processes pipelined in this fashion, we can keep all 4 cores of t

As a side benefit, this tool also ends up automatically throttling back emerge builds whenever you're busy using your computer for other tasks. Sure, your builds will take longer to complete, but at least they won't completely fail or prevent you from being able to use your computer at all, like they would otherwise.

What's New in v1.0.6
What's New in v1.0.7
====================

Still found trouble with an unwatched process getting stuck in the stopped
state. Now instead of trying to maintain a list of "never stop" processes
like "as," I've re-written the code to just always continue any proccesses
found in the STOP state that aren't known compilation processes.
Ran into a deadlocked build of Chromium where a couple "aarch64-unknown"
processes were in the "D" state (waiting on disk I/O), but were
actually apparently waiting on the other pair of stopped "aarch64-unknown"
processes to finish doing whatever.

Added a workaround so that "Draining The Swamp" will not count
"aarch64-unknown" processes in the "D" state towards the "allowed to run"
process count. This is kind of a hack, but it's working for me so far.

Finished compiling Chromium 90.0.4427.5 after five days or so on my RPi4
with 4GB RAM, zswap enabled, and 4GB of swap space on an external USB HDD
partition. I did, however, spend a bit of time during those 5 days at "-1"
process limiting, so that I could safely browse the web or play MegaGlest
while the build continued cranking along in the background... Yay for
dynamic adjustment of build parallelism!

Changed the "ps" external process starting code to wait indefinitely for "ps"
to finish. Previously the QProcess class was defaulting to a 30 second
time-out, which ordinarily is plenty of time for "ps" to finish executing,
but I guess if your system is heavily swamped, it might actually take longer.
This might solve sibercat's report of getting "QProcess::start: Process is
already running" warning messages.

Requirements
============
Expand Down
8 changes: 3 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

#include <unistd.h>
#include <signal.h>
#include <QProcess>
#include <QStringList>
#include <proc/sysinfo.h>

QProcess exec;
QStringList args;

int main(int argc, char* argv[])
Expand All @@ -38,7 +36,7 @@ int main(int argc, char* argv[])
QString watchUser = "portage";
int i = 0;

printf("Draining The Swamp v1.0.6b\n");
printf("Draining The Swamp v1.0.7\n");

bool stayAtOne = false;
bool stayAtTwo = false;
Expand Down Expand Up @@ -106,7 +104,7 @@ Command line options:
return 0;
}
sleepTime = 500000;
printf("%c est:%ldMB sum:%ldMB %.1f%% Free A1(%d stopped, %d running, %d swamped) \r",
printf("%c est[%ld/%ld MB] %.1f%% Free A1(%d stopped, %d running, %d swamped) \r",
bounce[i], womper.lastBigSize / 1024, estimatedSum / 1024, percentFree,
womper.stopped, womper.running, womper.swamped);
i++;
Expand Down Expand Up @@ -150,7 +148,7 @@ Command line options:
sleepTime = 1000000;
}

printf("%c est:%ldMB sum:%ldMB %.1f%% Free A%c(%d stopped, %d running, %d swamped) \r",
printf("%c est[%ld/%ld MB] %.1f%% Free A%c(%d stopped, %d running, %d swamped) \r",
bounce[i], womper.lastBigSize / 1024, estimatedSum / 1024, percentFree,
allowWhich, womper.stopped, womper.running, womper.swamped);
i++;
Expand Down
12 changes: 6 additions & 6 deletions womper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void Womper::scan()
pids.clear();
biggestRunning = 0;

process->waitForFinished();
process->waitForFinished(-1);
QString stat;
QString data = process->readAllStandardOutput();
QStringList lines = data.split('\n');
Expand Down Expand Up @@ -177,7 +177,7 @@ void Womper::allowOne()
{
if(compilers.contains(pi.cmd))
{
if(pi.status == 'R' || pi.status == 'T' || pi.status == 'D')
if(pi.status == 'R' || pi.status == 'T' || (pi.status == 'D' && pi.cmd != "aarch64-unknown"))
{
foundFirst = true;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ void Womper::allowTwo()
{
if(compilersRunning == 0)
{
if(pi.status == 'R' || pi.status == 'T' || pi.status == 'D')
if(pi.status == 'R' || pi.status == 'T' || (pi.status == 'D' && pi.cmd != "aarch64-unknown"))
{
sizeOfFirst = pi.rss;
compilersRunning++;
Expand All @@ -246,7 +246,7 @@ void Womper::allowTwo()
{
// running process is not very big and not estimated to be big,
// allow the next biggest to run
if(pi.status == 'R' || pi.status == 'T' || pi.status == 'D')
if(pi.status == 'R' || pi.status == 'T' || (pi.status == 'D' && pi.cmd != "aarch64-unknown"))
{
compilersRunning++;
}
Expand All @@ -261,7 +261,7 @@ void Womper::allowTwo()
// running process is big, allow the next to only be medium sized
if(pi.rss < 500000)
{
if(pi.status == 'R' || pi.status == 'T' || pi.status == 'D')
if(pi.status == 'R' || pi.status == 'T' || (pi.status == 'D' && pi.cmd != "aarch64-unknown"))
{
compilersRunning++;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ bool Womper::suspendToOne()
}
else
{
if(pi.status == 'R' || pi.status == 'D')
if(pi.status == 'R' || (pi.status == 'D' && pi.cmd != "aarch64-unknown"))
{
foundFirst = true;
}
Expand Down

0 comments on commit 5a6ef77

Please sign in to comment.