Sungju's Slow Life

Personal journal

Fast Linux Kernel Compile

Compiling Linux Kernel is a boring job. It takes really long period of time. In my laptop, it took more than an hour.

Fortunately, there’s option you can make it faster. Actually, it’s not Kernel’s option. It is provided by ‘make’ command.

To speed up the compile, you can create more than one thread for commands in make with ‘-jX’ option. You can specify how many threads you want to launch after -j with the thread count.

For example, in my laptop, it has two cores. Look at the following command with -j option and without it.

$ time make -j4
real	41m5.329s
user	56m39.896s
sys 	13m5.226s

$ time make
real	75m7.275s
user	55m49.704s
sys 	12m56.468s

Before each test, I flushed out cache with the following command:

echo 3 > /proc/sys/vm/drop_pages

Even though user and sys times are similar, total time to execute the command shows very different number. It’s because most of the time is consumed to save the result to the disk. So, use multiple threads really can help speed up the compile time.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Me

A software engineer who loves any technologies that makes life easier. That’s why I love Linux and Mac at the same time.


%d bloggers like this: