E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Compiling with Speed

  • No Related Post

Compiling With Speed

Since we’re well into the kernel configuration series, a tweak for compiling
your kernel seems in order. Don’t lose it - it will come in handy when we reach
the compile stage of the kernel configuration.

Linux offers the capability for the kernel to split up the tasks associated with

compilation. Used wisely, this can significantly speed up the time it takes to
compile your kernel. Potentially, though, there’s a trade-off. Split the process

into too many parallel processes, and you’ll actually slow compilation rather
than speed it up.

To use this tweak, you’ll add an option to the make bzImage command. Without the

option, the command looks like this:

    make bzImage

With the command, kernel compilation starts out looking like this:

    make bzImage -j4

The -jN (where N equals a number) is what splits the process into multiple
parallel processes. It’s also the point at which it’s easy to go astray in
attempting to speed up the compilation process.

To determine what that number (N) value should be, you’ll need to do a quick
calculation based on the RAM in Megabytes currently installed in your
machine:

    N = (RAM in Mb/8)+1

This formula will calculate the proper N value for the -jN option. In other
words, if your machine has 64 Mb RAM, your N value would be:

    (64/8)+1 = 9

In this example, your make command is:

    make bzImage -j9

On a machine with as little as 64 Mb RAM, a kernel recompile can be
painstakingly slow. Slow as in, “Go have yourself a leisurely dinner while the
computer crunches away. Maybe it’ll be done when you’re done.” By breaking the
overall process out into multiple processes, the -jN option can significantly
decrease this time.

Finally, it you have some doubt about whether this is actually working once the
compilation process starts, you can always use our old friend top. In
top, you’ll see multiple processes containing “c” or “cc”. They’ll likely be at
the head of the top report, as by default, top sorts processes by CPU usage in
descending (high to low) order. That’s your sign that the kernel compilation is
proceeding along speedy parallel paths.

What Do You Think?

 
35 queries / 0.343 seconds.