gentoo.LinuxHowtos.orgedit this article

nice and PORTAGE_NICENESS

Very simply put, the Linux kernel has a (process) scheduler that selects which process to run next in your system. One factor influencing the scheduler's decision about which process to assign CPU time to, is the priority of a process. Processes with a high priority will run before those with a lower priority, and processes with the same priority will take turns in running, one after the other and over again.

Better have a look at it for yourself: Run top from a terminal on your host and pay special attention to the PR and NI columns:

Sample top output

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 
 8005 root      20   0 85188  33m  57m R  3.3  6.7   8:43.77 X 
 8148 tobias    20  10 25624 2376  24m S  0.3  0.5   0:00.60 xscreensaver 
    1 root      20   0  2476  552 2304 S  0.0  0.1   0:00.31 init 
    2 root      39  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0 
    3 root      15  -5     0    0    0 S  0.0  0.0   0:00.09 events/0

The PR column indicates the priority level of a process, the value in the NI column displays the so-called nice value of process, which allows you to adjust the priority of a running process. Possible values range from -20 (very high priority), via 0 (standard priority) to 20 (very low priority). In our little example the xscreensaver process has a higher nice value than X, which indicates that X has a higher priority than xscreensaver.

Now, how do we make this work to our advantage when using Portage?

If you keep using your computer while compiling packages you will notice that your box is much less responsive as usal. This is caused by having two "groups" of processes with the same nice priority: your usual running tasks on one side, and emerge (and its child processes) on the other. Now, if you could renice emerge and its children to a higher nice (i.e. lower priority!) value (default is 0), compiling would inevitably take somewhat longer, but you could use your workstation without noticing much difference to its usual performance. That's what the PORTAGE_NICENESS parameter in /etc/make.conf is for:

Code Listing 1: Put this in /etc/make.conf

PORTAGE_NICENESS="15"

You can generally "renice" individual processes from the commandline, (e.g. renice 0 -p 8148 to prioritize xscreensaver in the above example), but this will not work with emerge, as Portage reads the PORTAGE_NICENESS setting from /etc/make.conf once and executes all child processes with the specified nice value.

From http://www.gentoo.org/news/en/gwn/20041101-newsletter.xml


rate this article:
current rating: average rating: 1.4 (80 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back