Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


Gentoo io-limiter for big upgrades (glibc)

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Author Message
Jay



Joined: 14 Nov 2004
Posts: 125
Location: NC, USA

Posted: Mon Aug 22, 2005 2:55 pm    Post subject: Gentoo io-limiter for big upgrades (glibc)  

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?
Back to top  
sednet



Joined: 17 Mar 2004
Posts: 106
Location: Europe

Posted: Mon Aug 22, 2005 3:24 pm    Post subject: Re: Gentoo io-limiter for big upgrades (glibc)  

Jay wrote: 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='[ =]' </proc/io_status`
[ $x -lt 100000 ] && kill -stop $PID
[ $x -gt 200000 ] && kill -cont $PID
sleep 5
done
Back to top  
Jay



Joined: 14 Nov 2004
Posts: 125
Location: NC, USA

Posted: Mon Aug 22, 2005 4:07 pm    Post subject:  

Okay... how would I implement that into my emerge then?
Back to top  
tierra



Joined: 06 Aug 2004
Posts: 157

Posted: Mon Aug 22, 2005 6:04 pm    Post subject:  

Jay wrote: 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.
Back to top  
Jay



Joined: 14 Nov 2004
Posts: 125
Location: NC, USA

Posted: Mon Aug 22, 2005 8:22 pm    Post subject: Re: Gentoo io-limiter for big upgrades (glibc)  

sednet wrote: Jay wrote: 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='[ =]' </proc/io_status`
[ $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.


Quote: 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.
Back to top  
sednet



Joined: 17 Mar 2004
Posts: 106
Location: Europe

Posted: Tue Aug 23, 2005 6:54 am    Post subject: Re: Gentoo io-limiter for big upgrades (glibc)  

sednet wrote:

The general idea was something like:

while true
do
$x = `awk '{print $6}' FS='[ =]' </proc/io_status`
[ $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='[ =]' </proc/io_status`

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.
Back to top  
erik.elmore



Joined: 17 Apr 2005
Posts: 45

Posted: Tue Aug 23, 2005 12:28 pm    Post subject:  

why not just do the build on your more powerful home pc and then upload the binary packages and then have portage install your binaries?

I made a HOWTO on this very subject ;)

http://www.linode.com/forums/viewtopic.php?t=1688
Back to top  
Jay



Joined: 14 Nov 2004
Posts: 125
Location: NC, USA

Posted: Tue Aug 23, 2005 3:50 pm    Post subject: Re: Gentoo io-limiter for big upgrades (glibc)  

sednet wrote: 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*
Back to top  
sednet



Joined: 17 Mar 2004
Posts: 106
Location: Europe

Posted: Tue Aug 23, 2005 5:07 pm    Post subject: Re: Gentoo io-limiter for big upgrades (glibc)  

Jay wrote: 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:
Code:
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='[ =]' </proc/io_status`
  if  [ $x -lt $low ]
    #space before '[' so this wont grab sshd, '[p]' to stop grep grepping grep.
    pids=`ps ax | grep [p]ts/$emergepts | awk '{print $1}' | tr '\n' ' ' `
    kill -STOP $pids && echo "frozen build (io_tokens = %x)"
  fi
  if [ $x -gt $high ]
    pids=`ps ax | grep [p]ts/$emergepts | awk '{print $1}' | tr '\n' ' ' `
    kill -CONT $pids && echo "continuing bulid (io_tokens = %x)"
  fi
  sleep $sleeptime
done


That should work but its totally untested and I guarantee nothing.
Back to top  
 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Page 1 of 1