If you use a GNU/Linux distro, and are capable of compiling your own Kernel, on this page you'll find how I modified my Kernel, and a script to facilitate Kernel configuration, and compilation.
Go to:
Introduction
Default config
Script usage
Performance
Source code
I'll start off by saying that I use the Gentoo Linux arrow_forward distro — it's a GNU/Linux distro where all packages (programs) are compiled from source, rather than simply install pre-built/pre-packages programs, that cannot be configured. This allows the user to choose which components of his system to compile, and which specific packages to install, in order to allow configurations that use not too many resources (even less than 100MB RAM usage!), totally functioning and very efficient. In fact, as you may have well understood, it's also possible to configure your own Kernel, and compile it later. On my laptop, ThinkPad T440p, I use the pf-sources arrow_forward Kernel, which includes Gentoo Kernel patches (genpatches), and many other patches which allow the Kernel to run way faster.
This Kernel is updated regularly, with continuous support for my laptop, ThinkPad T440p, removing features that aren't used nor necessary, like NUMA, NVIDIA, AMD, and so on. In this guide you'll see that you have to modify some options, like the directory that contains the Kernel source, etc. Also, if you use setups different from mine, you'll have to modify the Kernel config, especially the max number of CPUs (set to 8), max GPUs (set to 2), etc.
Make sure you cloned the repository:
Select a Kernel version to compile, based on the available versions. For example, I'll compile the 5.19_p1-pf Kernel:
Even if you don't have the exact version, you can modify the script to includere the version you want; for this example, I'll modify the file with the vim text editor, but you can use any editor you want:
To modify the version, take a look at the following variables:
KVER contains the Kernel's primary version (5.19), meanwhile PVER contains the patch version (_p1-pf). Together they make KERNVER, the Kernel's complete version (5.19_p1-pf). For example, if your custom version has the same primary version as my Kernel's (5.19), but a different patch version, for example _mykernel, then you have to set the variables like this:
In the script, build.sh, there's a variable, ARCHVER. This variable contains a number from 1 to 41; each number represents a different processor family. In the same file, there's a list that explains which number to use, depending on the processor's family.
In my config, this variable is set as follows:
ARCHVER is set to 24 because 24 represents the Intel CPU family Haswell.
I recommend you change this number, because the performance impact is notable. Here's the full list:
It's good practice to check the Kernel config before compiling it. In order to do so, the build.sh script allows you to modify the config, executing make menuconfig inside the Kernel directory, with the option to copy the included config, or to use your own.
Make sure you have administator rights before executing this command; if you are not admins, put sudo or doas before the command, according to whichever you use.
dangerous If you haven't undertood what's written above, stop immediately the Kernel configuration, to avoid making your system unusable. Even if the risk isn't high, it's better to prevent further problems. Continue at your own risk.
warning Make sure to save/copy the .config file after configuration!
After having applied CPU Optimisations and having re-checked the Kernel config, it's time to choose the settings to notably improve performance. Here's the options list:
flag Short flag
Long flag
Description
After having chosen which flags to apply, and after having chosen whether to copy the included .config file with the flag "-c", you're ready to compile the Kernel.
To establish which Kernel is the fastest, I ran 4 compilations with different flags, using the same Kernel configuration. These tests were ran on my laptop, ThinkPad T440p, with CPU Intel Core i7-4700MQ, 8GB RAM, Kernel Gentoo Linux 5.16.0-pf2. To find out which Kernel is the most performant (aka the fastest), I used every single Kernel with the XMRig program, running it for 5 minutes maximum, and looking at the max hashrate. Here's a list of the tested Kernels, from the most performing to the least:
settings Settings
schedule Compile time
Max H/s
Unsafe Fast Math, Clear Linux patches, Included patches
7m, 7s
1715
Unsafe Fast Math, Graphite, Clear Linux patches, Included patches
7m, 3s
1500
Clear Linux patches, Included patches
7m
1463
Included patches
7m
1460
This Kernel's source code is available on the Github repo arrow_forward