MAKEOPTS

From Gentoo Wiki
Jump to:navigation Jump to:search

MAKEOPTS is a variable that defines how many parallel make jobs can be launched from Portage. It can be set in the /etc/portage/make.conf configuration file.

Tip
As a rule of thumb, MAKEOPTS jobs should be less than or equal to the minimum of the size of RAM/2GB or CPU thread count.

The parallel jobs entry ensures that, when make is invoked, it knows how many parallel sessions it is allowed to trigger (when parallel sessions are possible of course). This is completely within the scope of that make command and has no influence on parallel installations (which is triggered through emerge with --jobs=X option). The recommended value is the number of logical processors in the CPU.

On a system with one Intel Core i7 CPU the following command shows the numbering of the available logical CPUs.

root #lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              8
On-line CPU(s) list: 0-8
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1

To take other tasks that are running on the system into account, make supports --load-average, to limit the creation of parallel tasks based on the system's current load average. Since the load average is a damped value, it is sensible to set the load-average limitation slightly above the number of available CPUs.

In this example 8 logical CPUs are available, 4 physical cores each with 2 threads, hence one could set the MAKEOPTS variable to:

FILE /etc/portage/make.conf
MAKEOPTS="--jobs 8 --load-average 9"

But another item to consider is RAM usage. Recent gcc versions have been known to take 1.5 GB to 2 GB of RAM per job. If the system has the 8 logical CPUs from the previous example, but only 4 GB RAM, the MAKEOPTS value should be lowered to -j2. This is so that the system has RAM to run the basics as well as compile without hitting swap very often slowing things down.

For example, to measure the time needed to compile the package app-misc/mc with 4 threads one can run:

root #time MAKEOPTS="-j4" emerge app-misc/mc

MAKEOPTS on a per-package basis

Packages can be emerged with different MAKEOPTS values on a per-package basis. See /etc/portage/package.env for details.

See also

  • EMERGE_DEFAULT_OPTS — a variable that defines entries to be appended to the emerge command line.

External resources