Gentoo io-limiter for big upgrades (glibc)
8 Replies
@Jay:
I know that someone posted a script for making gentoo not completely murder itself while doing major upgrades (like glibc) by limiting I/O … I can't find that now, anyone care to venture how to do this?
The general idea was something like:
while true
do
$x = `awk '{print $6}' FS='[ =]'
[ $x -lt 100000 ] && kill -stop $PID
[ $x -gt 200000 ] && kill -cont $PID
sleep 5
done
@Jay:
Okay… how would I implement that into my emerge then?
Well, you could go about it this way, but I'm sure there's plenty of other ways to do it as well…
First, you could change it to take $1 instead of $PID (or $PID = $1) to take the process ID from the first command line argument in your script, then when you run your emerge, the PID will be output if you toss it in the background ("emerge -u glibc &"), then you can type "./iopeyes ###" (replacing ### with the PID output from the last command) assuming you cleverly name your script the same way I would.
And if you wanted to take it a couple more steps, these couple ideas might give you a good reason to learn some BASH scripting and not have to ask that question again in the future:
1. Add output info to let you know when the process isn't found anymore (it finished), as well as when it's being stopped/started.
2. Add a break and quit when the process isn't found anymore so it takes care of itself cleanly and then you can toss that last command in the background as well and forget about it.
@sednet:
@Jay:I know that someone posted a script for making gentoo not completely murder itself while doing major upgrades (like glibc) by limiting I/O … I can't find that now, anyone care to venture how to do this?
The general idea was something like:
while true
do
$x = `awk '{print $6}' FS='[ =]'
[ $x -lt 100000 ] && kill -stop $PID[ $x -gt 200000 ] && kill -cont $PID
sleep 5
done
I threw that into a foo.sh file (i manually subbed in a PID) with the #!/bin/sh … it kept erroring out.
> First, you could change it to take $1 instead of $PID (or $PID = $1) to take the process ID from the first command line argument in your script, then when you run your emerge, the PID will be output if you toss it in the background ("emerge -u glibc &"), then you can type "./iopeyes ###" (replacing ### with the PID output from the last command) assuming you cleverly name your script the same way I would.
That doesn't work b/c it's really the child processes of emerge that cause all the IO pain.
@sednet:
The general idea was something like:
while true
do
$x = `awk '{print $6}' FS='[ =]'
[ $x -lt 100000 ] && kill -stop $PID[ $x -gt 200000 ] && kill -cont $PID
sleep 5
done
That third line should be:
x = `awk '{print $6}' FS='[ =]'
Further proof that perl warps your mind.
If you change the kill's to a loop that stops or conts everything with emerge or cc in its name it should do what you want.
I made a HOWTO on this very subject
@sednet:
If you change the kill's to a loop that stops or conts everything with emerge or cc in its name it should do what you want.
It would be nice if that code was just magically written, by some nice person
whistles innnocently
@Jay:
It would be nice if that code was just magically written, by some nice person
O-kay…
Open two ssh sessions, one for the control script and one for the emerge.
make a note of the pts doing the emerge stuff ( ie by typing w and looking for the pts running the w command. )
Run the following in bash in the control window:
emergepts= <the number="" of="" the="" pts="" running="" emerge="">#high and low points
low=100000
high=200000
sleeptime=10
while true
do
x = `awk '{print $6}' FS='[ =]'</the>
That should work but its totally untested and I guarantee nothing.