Good example of slow compilation is the invocation of make bzImage when you try to build the Linux kernel. Depending on the chosen kernel configuration parameters and the machine specs, the actual compilation can easily take more than 1 hour.
Recently I found out that we can use the magical option -j which speeds up the compilation process by running individual jobs in separate threads. Here is what the manual says:
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.
So, if you have multi-core processor and you know that on hardware level your machine can handle 4 parallel threads, you can run the following command:
make bzImage -j 4
The above command will speed up the overall compilation process approximately 4 times which is huge performance improvement! You can take a look at one real life example here:
The make -j invocation in the above example automatically figures out the number of available processors (i.e. CPU cores) and provides this number as value for the -j parameter.