Does compiling a linux kernel make the OS faster?
Solution 1:
In general , no.
There are, however, some exceptions to "no". For example the liquorix kernel or Ubuntu kernel Flavors. These are generally performance tuning and can make a difference (the server kernel is faster for servers, and will not improve desktop performance).
With Ubuntu, if you are running the proper kernel flavor, you should be good to go.
Note: The Liquorix kernel also has some patches (in addition to performance tuning).
The other exception would be if you have some unusual hardware.
But in the vast majority of cases, performance is not a "standard" reason to compile a kernel.
See:
Ubuntu wiki compile kernel
Solution 2:
The most accurate answer is, as bodhi.zazen said, not usually but with a few exceptions. Most of those exceptions are hardware related, but some are just configuration issues. Justification for my answer follows.
I've compiled twenty-six kernels between two machines in the last month attempting to performance tweak. What I found:
- Changing cpu type in .config to the native architecture and removing options that support other architectures improved file I/O throughput by more than 10% in benchmarks (enough I can "feel the improvement") and reduced delay following user input in XFCE on Xubuntu 12.04 -32bit on my 1.8GHz (K8) Mobile Sempron 512MB RAM laptop. The same changes had no quantifiable or perceivable impact on my 1.73GHz Core2 Duo 2GB RAM laptop in Ubuntu 12.04 64-bit, but did cause one formerly stable application to become crash prone.
- Changing HZ in .config to 1000 dramatically improved responsiveness to user input when under high CPU load in both systems. It also made window focus changes in X instantaneous in all conditions.
- The BFS patch increased battery life in both systems by a few minutes. Just enough to be measurable and consist, but not enough to matter much. Benchmarks revealed no statistically significant performance changes, but both systems "feel" faster. I suspect this has to do with scheduling priority being more beneficial to the typical workloads on those specific machines.
- All other .config combinations tried resulted in decreased performance on both systems.
I spent ridiculous sums of time compiling and testing different configurations. For all that, only five kernels produced a desireable result, out of twenty-six attempted. Seven kernels were not even operable (either unbootable or failed to start X). I recently installed the Liquorix kernel from repository and netted all the above improvements plus a roughly 50% frame rate increase in both the Windows games I play through WINE on the Core2 system. That only took a few minutes, and nothing broke.
Is my OS better because I compiled my own kernel? Well, yeah a little. Until I find something that runs slower/breaks, because I failed to find it during testing. Is my OS faster? No.
Solution 3:
In my experience yes. But the benefits mainly come from eliminating unnecessary features, and selecting a few others, such as your processor type. Also, make it a ultra low latency for desktop use. I've been compiling the kernel for years and for me the difference is always noticeable. But there are other benefits. Boot times are also improved.
However, it's very time consuming to get to select only the options you need.