From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.gentoo.org (smtp.gentoo.org [134.68.220.30]) by robin.gentoo.org (8.13.4/8.13.4) with ESMTP id j4V8lu2E024153 for ; Tue, 31 May 2005 08:47:57 GMT Received: from [72.9.236.50] (helo=sls-ce5p321.hostitnow.com) by smtp.gentoo.org with esmtp (Exim 4.43) id 1Dd2Po-0004KO-Vz for gentoo-dev@lists.gentoo.org; Tue, 31 May 2005 08:48:01 +0000 Received: from c-67-181-38-200.hsd1.ca.comcast.net ([67.181.38.200] helo=localhost) by sls-ce5p321.hostitnow.com with esmtpa (Exim 4.50) id 1Dd2Pm-0003kx-Lf for gentoo-dev@gentoo.org; Tue, 31 May 2005 03:47:58 -0500 Date: Tue, 31 May 2005 17:48:21 +0900 From: Chris White To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] Portage, Jobs, and Niceness Message-ID: <20050531174821.53e95fd3@localhost> Organization: Gentoo X-Mailer: Sylpheed-Claws 1.9.9 (GTK+ 2.6.7; i686-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary=Signature_Tue__31_May_2005_17_48_21_+0900_b7+kgXDcRD5rCxea; protocol="application/pgp-signature"; micalg=pgp-sha1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - sls-ce5p321.hostitnow.com X-AntiAbuse: Original Domain - gentoo.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - gentoo.org X-Source: X-Source-Args: X-Source-Dir: X-Archives-Salt: 140a24a2-9d5a-44c7-9c5f-3eb593cb7f20 X-Archives-Hash: 7e77fc7a2fcfcf0ed768ce1b364dd741 --Signature_Tue__31_May_2005_17_48_21_+0900_b7+kgXDcRD5rCxea Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi all, -- Niceness -- While waiting for kde to compile (read as hours), I decided to take a cha= nce and talk about niceness and jobs this time. Ok so, we'll start with ni= ceness first: if portage.settings.has_key("PORTAGE_NICENESS"): try: os.nice(int(portage.settings["PORTAGE_NICENESS"])) except SystemExit, e: raise # Needed else can't exit except Exception,e: print "!!! Failed to change nice value to '"+str(portage.se= tting s["PORTAGE_NICENESS"])+"'" print "!!!",e the setting PORTAGE_NICENESS in make.conf sets up the portage niceness. Th= is code gives you an idea of how it is done. if it sees PORTAGE_NICENESS, = it simply uses the os module's nice function to set the niceness. Now.. ni= ceness is kind of weird.. so let's demonstrate using American Idol(tm)! Al= right.. so you have your two wannabe singers here, ProcessPest and ProcessP= rincess. Now.. Simon is the cpu here, having to judge which singer he want= s more (it is safe to note here that one doesn't suck). Now, instead of sh= owing who he likes more, he shows who he hates less! So, we have something= like this: nice -n -19 ProcessPrincess nice -n 10 ProcessPest So Simon says to ProcessPrincess "You suck -19, which means I like you, you= get more cpu" So Simon says to ProcessPest "You suck 10, which means you suck, you get sc= rewed" Now back to our regularly scheduled technical form... Ok, so now that we kn= ow what's going on, niceness means how "nice" you are to other programs. T= he more "nice" you are, the more willing you are to share your cpu to other= programs. The less "nice" you are, the more you want to hog it to yoursel= f. Now, when a process is set niceness, it does it by INCREMENT, not setti= ng. This basically means that if you do this: PORTAGE_NICENESS=3D10 portage will increase your niceness from its original (normally 0 unless ni= ce was already applied to it) by 10, giving you 10 niceness. Now if you do= it negative: PORTAGE_NICENESS=3D-3 it increases by a negative number.. so it DECREASES portage niceness. In t= his case, it would be -3, which is generally an ok value. Note that the va= lues go from -20 to 20, and that while you can increase niceness no problem= , if you want to increases, you're probably going to need to be root. Note= to BE CAREFUL ABOUT NICENESS. Remember, the same niceness that portage ge= ts will be thusly applied to its child processes. That means if you're run= ning -j5 with PORTAGE_NICENESS=3D-19, subprocesses will all recieve -19 nic= eness too. That's a lot of programs trying to grab for the cpu (I can tell= you from experience that it can happen..)! Only try this if you have some= spectacular multi processor elite setup. So that's what you get with nice= ness. Now let's look at jobs: -- Jobs -- Then there's jobs. Now, this is extremly usefull for people that realized = "Oh crap, I'm in the middle of emerge-ing such and such package and I just = realized I need all my cpu for something more important (homework maybe?)".= No need to fear! Bash has this nice little deal called jobs. Let's take= a look: Scenario Ahh crud! My xorg-x11 compile is halfway through and I just n= oticed this security patch I need to get through asap! What to do! (or I'm= compiling kde and realize I missed an assignment at school!). Nice little= handy bash function called jobs can take care of this. To work with jobs,= simply press CTRL+Z during the compile. This stops the process as so: (please note I was lazy here and removed my japanese error messages.. now y= ou're not dreaming) making imake with BOOTSTRAPCFLAGS=3D and CROSSCOMPILEFLAGS=3D-DCROSSCOMPILE= DIR=3D"" in config/imake make[2]: Leaving directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/conf= ig/imake' rm -f ./config/makedepend/Makefile.proto ./config/imake/imake -I./config/cf -s ./config/makedepend/Makefile.proto -= f ./config/makedepend/Imakefile -DTOPDIR=3D../.. -DCURDIR=3D./config/makede= pend ./config/cf/Imake.tmpl:109 include=20 Imakefile.c:35 : ./config/cf/linux.cf:390: Warning: "BuildLibGlxWithoutPIC" redefined ./config/cf/site.def:44 include , ./config/cf/Imake.tmpl:46=20 Imakefile.c:35 : ./config/cf/host.def:63: Warning: this is the location of the previous defi= nition cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o boo= tstrap cd ./config/makedepend && make -f Makefile.proto bootstrap make[2]: Entering directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/con= fig/makedepend' make[2]: `bootstrap' make[2]: Leaving directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/conf= ig/makedepend' ./config/imake/imake -I./config/cf -s ./config/imake/Makefile.proto -f ./c= onfig/imake/Imakefile -DTOPDIR=3D../.. -DCURDIR=3D./config/imake -DBootStrap [1]+ Stopped emerge xorg-x11 And it stopped! Now that you've done your stuff, you'd like it to run agai= n. First off, we do a jobs listing like such: secures chris # jobs [1]+ Stopped emerge xorg-x11 Job 1 is listed here as our stopped emerge xorg-x11. Please note that jobs= are PER SESSION. This means you can't just pull another console up and ex= pect the current console's jobs to show up in it. One session, one job lis= t. So, you have two options: 1) fg 1 2) bg 1 the first puts the process in the foreground the second puts the process in the background Let's pull it to the foreground in this case: secures chris # fg 1 emerge xorg-x11 ./config/cf/Imake.tmpl:109 include=20 Imakefile.c:35 : ./config/cf/linux.cf:390: : "BuildLibGlxWithoutPIC" redefined ./config/cf/site.def:44 include=20 ./config/cf/Imake.tmpl:46 , Imakefile.c:35 : ./config/cf/host.def:63: : this is the location of the previous definition cd ./config/imake && make -f Makefile.proto bootstrapdepend make[2]: Entering directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/con= fig/imake' make[2]: `bootstrapdepend'=20 make[2]: Leaving directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/conf= ig/imake' cd ./config/imake && make -w -f Makefile.ini BOOTSTRAPCFLAGS=3D"" CC=3D"cc"= bootstrap make[2]: Entering directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/con= fig/imake' make[2]: `bootstrap'=20 make[2]: Leaving directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/conf= ig/imake' cd ./config/imake && make -f Makefile.proto imakeonly make[2]: Entering directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/con= fig/imake' make[2]: `imakeonly'=20 make[2]: Leaving directory `/var/tmp/portage/xorg-x11-6.8.99.8/work/xc/conf= ig/imake' + rm -f xmakefile.bak + mv xmakefile xmakefile.bak and viola! Our compile moves right on! Please note that jobs is NOT A PRO= GRAM, it's a part of the shell. I know bash does it.. I'm not sure if othe= rs do. That's it for now, hope this becomes usefull to some people. Chris White --Signature_Tue__31_May_2005_17_48_21_+0900_b7+kgXDcRD5rCxea Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCnCTaFdQwWVoAgN4RAitSAJ9sujCG6+30rykU2st9pTgPsCIlFQCg3WX2 py3HGB17PJBbaQ3nHZ/tMKY= =aJbx -----END PGP SIGNATURE----- --Signature_Tue__31_May_2005_17_48_21_+0900_b7+kgXDcRD5rCxea-- -- gentoo-dev@gentoo.org mailing list