From 5a6ef77c5b996b5eafba6d8786fa1d65059df539 Mon Sep 17 00:00:00 2001 From: K9spud LLC Date: Thu, 11 Mar 2021 10:23:18 -0700 Subject: [PATCH] v1.0.7 --- README.md | 28 +++++++++++++++++++++++----- main.cpp | 8 +++----- womper.cpp | 12 ++++++------ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ac46ec9..e8687bd 100644 --- a/README.md +++ b/README.md @@ -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 ============ diff --git a/main.cpp b/main.cpp index c79ebc1..fe41675 100644 --- a/main.cpp +++ b/main.cpp @@ -21,11 +21,9 @@ #include #include -#include #include #include -QProcess exec; QStringList args; int main(int argc, char* argv[]) @@ -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; @@ -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++; @@ -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++; diff --git a/womper.cpp b/womper.cpp index 29b8a42..14af746 100644 --- a/womper.cpp +++ b/womper.cpp @@ -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'); @@ -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; } @@ -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++; @@ -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++; } @@ -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++; } @@ -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; }