# Gentoo kernel compilation time low compared to other distres

## mattia29

Hi everyone,

I'm trying gentoo for the first time in virtual box and initially I was scared by the "famous" long compilation time of gentoo packages. But when it was the time to compile the kernel, I launched the common

```
time make & make modules_install
```

to have an estimate of the needed time. The result was like this:

real: about 9 minutes

Before Gentoo, I tried compiling the kernel on Arch both via AUR and in classical way, and on Ubuntu, also here both in the traditional way and creating the .deb package. On ubuntu I tried also with the vanilla kernel.

The results were about:

Arch (virtualbox): about 1 h 5 minutes   :Shocked: 

ubuntu (hard disk installation): about 42 minutes   :Shocked: 

There were no substantial difference between the compilation methods. Everytime I used the [/code]-j4[code] command to use all the cores and I set the kernel simply removing support to amd cpus and unused filesystems (I'm able to do only this at the moment).

The machine is a Macbook Pro 2011 with i5-2415m dual core + hyper threading, 4gb ram.

My question is: why so much difference?

Thank you

----------

## Logicien

Hello,

did you allow VirtualBox to use all your cpu cores with 100% of their resources in you machine configuration? What was the amount of memory you have allowed it to use compare to the host total? The compiling time would have been probably lower if done from the host.

One possible explanation is that your Gentoo kernel configuration is minimal compare to the ones of the Arch and Ubuntu. Usually, generic kernels have a very complete configuration specially to support the variety of devices they can boot on. So, they take a long time to compile compare a personnalised kernel with only needed support for one machine.

----------

## mattia29

Yes, I allow virtual box to always use all cores and for both gentoo and arch the available ram is 1 gb. Ubuntu was installed on hd so it had all 4gb available.

I followed the handbook to install the gentoo kernel (manually, not with genkernel). Do you think there could be so much difference?

----------

## NeddySeagoon

mattia29,

Thu first make will take a long time.  Second and subsequent builds are fast as make is lazy.

Each time it finds an output file it is being asked to make, it compares the timestamps of all the input files required to that of the output file.

If the output file is newer, make does nothing for that file. 

Run 

```
make clean

time make & make modules_install
```

and report your findings.

make clean removes any existing output files, which forces them to be built.

Incidentally.  make will only use 1 core.

```
make clean

time make -j7 & make modules_install
```

 will run 6 gcc jobs and make itself.

The kernel build can be massively parallel.  Do not use make -j with no limit.

----------

## desultory

Moved from Documentation, Tips & Tricks to Kernel & Hardware, though perhaps portage & Programming would fit as well.

----------

## Hu

Very long kernel compile times can be caused by building unneeded features.  Distribution kernels are often configured to support every likely user, which can mean shipping support for all the popular network cards, all the popular USB devices, all the popular video cards, etc.  This in turn means building a huge volume of code that, in aggregate across all users, is well used, but any particular user may run only a small part of it.  A custom configured kernel, whether or not from Gentoo, can include only the things that its operator wants, which can mean building a much smaller volume of code.

----------

## desultory

 *Hu wrote:*   

> Very long kernel compile times can be caused by building unneeded features.  Distribution kernels are often configured to support every likely user, which can mean shipping support for all the popular network cards, all the popular USB devices, all the popular video cards, etc.  This in turn means building a huge volume of code that, in aggregate across all users, is well used, but any particular user may run only a small part of it.  A custom configured kernel, whether or not from Gentoo, can include only the things that its operator wants, which can mean building a much smaller volume of code.

 I was thinking along the same lines, but when I re-read the post prior to moving it I thought that should have been controlled for already:

 *mattia29 wrote:*   

> Everytime I used the [/code]-j4[code] command to use all the cores and I set the kernel simply removing support to amd cpus and unused filesystems (I'm able to do only this at the moment).

 

Though that would depend on what was being removed from, the default configuration or make allmodconfig, or something else.

----------

## Hu

I considered that, but decided to interpret OP's statement as being that he removed support for AMD CPUs and unused filesystems as an exhaustive list of what he removed.  If so, then he said nothing about, and possibly never modified, any of the other top level trees, like device drivers, networking support, etc.  As you say, it depends on what his baseline was for each side.

----------

## mattia29

Sorry for the late reply, I've no time due to work. However I recompiled the kernel under Arch in VM (using 

```
make clean
```

 before and then 

```
time make -j4 && make modules_install
```

), and it took about an hour again. I paid attention to the output and saw a lot of "/drivers/wireless/..." et similia and modules which I didn't see with gentoo. So I think your answer is correct: there are a lot of enabled  features which are disabled under gentoo. 

Again the only things I've disabled were amd support and uncommon filesystems. I used the kernel 4.3 from kernel.org

Thank you

----------

