What are your kernel compile times?

So, for a chance for us to brag about our system performance I thought it might be cool to do this little benchmark :laughing:

So, the steps are the following:

  • Get a copy of the 5.8.3 kernel from kernel.org
  • Start by running a make mrproper and make defconfig (if not using a x64 system specify in your post as the defconfig will be different for different architectures)
  • Finally, run time(make -j$(nproc)) and post the output here along with your hardware specs!

My result? Well, not the most scientific as I had this window open typing this post up while listening to music, but still pretty impressive I think…

real	1m11.555s
user	21m2.367s
sys	    2m48.127s

Hardware?

CPU: 3900x
GPU: 2080S
RAM: 16GB @ 3200MHz

@alenbasic
I have the Ryzen 3800X with Amd RX590 & 32 GB memory. So how do i do this as i have never compiled a kernel. So i download the kernel from kernel.org. Do i put it in a different directory? Then explain what i do and when i’m all done what then?

Well, we’re not going to do anything with this kernel when compiled, you can just delete it afterwards since it’s just for performance benchmark reasons. In terms of what to do more step by step:

  • Open a terminal
  • cd into a directory where you’ll want to download the file
  • wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.3.tar.xz
  • once it’s finished downloading, run tar -axf linux-5.8.3.tar.xz to extract the files and cd linux-5.8.3/
  • from there, run the commands I mentioned above: make mrproper, followed by make defconfig and finally time(make -j$(nproc))
  • once it’s finished you can just delete the files.
2 Likes

I guess i only need make to do this? So i don’t need any other tools?

If you have base-devel installed you’ll have everything you need.

1 Like

Do i have any bragging rights?

Kernel: arch/x86/boot/bzImage is ready (#1)

real	1m33.061s
user	20m9.783s
sys	2m1.149s
[ricklinux@eos-xfce linux-5.8.3]$ 

AMD Ryzen 7 3800X (8 core 16 thread)
AMD RX590
32 GB Memory 3200Mhz

2 Likes

Not bad compared against your 3900X

Figured add in a bit lower end of a system, so did this on my Inspiron 5485 laptop. With, as alenbasic had, this window open and listening to some music…

real    8m4.016s
user    48m28.400s
sys     4m38.127s

Hardware:
CPU: 3500u
GPU: AMD Vega 8 IGP
RAM: 16GB @2666 MHz

2 Likes

Thanks for showing me this. Once you have compiled the kernel then what can you do with it? Install it? Or is there more?

$ time make -j$(nproc)
...
2310.30s user 314.48s system 5160% cpu 50.859 total

:face_with_hand_over_mouth:

(I had to fire up a work server for that, though)

2 Likes

Shit, I’ve got a few dozen cores free I could try that!! How many cores/threads/ram did you throw at it? Given I’m the only one at work that actually KNOWS how to manage the Nutanix appliances…noone would even realize it…

Only 128 cores and 512GB RAM. Noone is on at 2am on a Saturday so noone noticed. :grin:

4 Likes

A long long time ago I dared to write a script and with a lot of support from a forum the automatic kernel building worked (v4).
Now IDK the correct path in arch (calling stat for ‘/boot/config-5.8.3-zen1-1-zen’ is not possible: file or directory not found) or if other things are needed.
Maybe someone wants to fix it or is inspired to program a completely improved version.
I have not searched the net if something like this already exists :slight_smile:

Because it was/is a german forum the texts are also in german, sorry :wink:

diy_kernel                                                                                                                                             
Let's go.
CA certificate "/etc/ssl/certs/ca-certificates.crt" was loaded
2020-08-23 02:43:17 URL:https://www.kernel.org/ [16609/16609] -> "-" [1]
Latest stable kernel is: 5.8.3
Current running kernel is: 5.8.3-zen1-1-zen
Download approved
Working folder is: /home/sgs/kernel_build
--2020-08-23 02:43:23-- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.3.tar.xz
CA certificate "/etc/ssl/certs/ca-certificates.crt" was loaded
Resolving the host name cdn.kernel.org (cdn.kernel.org)... 151.101.1.176, 151.101.65.176, 151.101.129.176, ...
Connection setup to cdn.kernel.org (cdn.kernel.org)|151.101.1.176|:443 ...
HTTP request sent, waiting for response ... 200 OK
Length: 114473912 (109M) [application/x-xz]
Is stored in "linux-5.8.3.tar.xz".

linux-5.8.3.tar.xz 100%[=========================================================================>] 109.17M 6.39MB/s in 17s     

2020-08-23 02:43:40 (6.38 MB/s) - "linux-5.8.3.tar.xz" stored [114473912/114473912].

The file linux-5.8.3.tar.xz is unpacked.
Change to the folder /home/sgs/kernel_build/linux-5.8.3
The .config is created from the existing config-5.8.3-zen1-1-zen
/home/sgs/.local/bin/diy_kernel: Line 156: ../kernel_gcc_patch/*.patch: file or directory not found
No *.patch in /home/sgs/kernel_build/kernel_gcc_patch available, no problem, continue
cp: calling stat for '/boot/config-5.8.3-zen1-1-zen' is not possible: file or directory not found
/home/sgs/.local/bin/diy_kernel: Error creating the .config
#!/bin/bash
# - 07.03.2018 -
#---- diy_kernel ---- Do it yourself_Kernel ----
#Script aus https://www.linuxmintusers.de/index.php?topic=47468.0
#Ermöglicht durch NeXxGeN, Nessie, Spartacus, PeLi, CLImate
#*Hoffentlich habe ich niemanden vergessen*
#Tutorial: "Kernel selbst kompilieren"
#https://www.linuxmintusers.de/index.php?topic=46911.msg662513#msg662513
#
# ${0##*/} Programname
# ${0%/*} Verzeichnis = verz=“${0%/*}“

Hilfe(){
  echo "${0##*/} ist Dein automatisierter Kernelbauer. "
  echo "Hilfe für ${0##*/} gibt es bei https://www.linuxmintusers.de"
  exit
}
test "${1}" = "-h" -o "${1}" = "-help" -o "${1}" = "--help" && Hilfe

Exit(){
    echo "$0: $2" >&2
    exit "$1"
}

if ! zenity --question \
	--title "- DIY Kernel -"  \
	--width='700' \
	--ok-label="Ja"  \
	--cancel-label="Nein" \
	--icon-name='system-software-update' \
	--text "Dein *DIY-Kernel* setzt voraus, dass du weißt was du tust.\\n\\n\
<span color='#ff0000'><b>Benutzung auf eigene Gefahr.</b></span>\\n\\n\
<a href='https://www.linuxmintusers.de/index.php?topic=47468.0'>Hilfe</a>\\n\\n\
<a href='https://www.linuxmintusers.de/index.php?topic=46911'>\
Tutorial: Kernel selbst kompilieren</a>\\n\\n\\n
<span size='small'>\"Niemand weiß, was er kann, bis er es probiert hat...\"</span>\\n\\n\\n\\n\
<span size='xx-large'><span  color='#ff0000'><b>Weiter?</b></span></span>" 2>/dev/null
	then
		exit 0
	else
		echo "Weiter geht's."
fi

url_kernelinfo='https://www.kernel.org/'

wget_timeout=10

workdir="$HOME/kernel_build"

patchdir="$workdir/kernel_gcc_patch"

ak=$(uname -r)

if ! kernelinfo="$( wget -nv -T $wget_timeout "$url_kernelinfo" -O- )"
then
    Exit 1 'Fehler beim Download der Kernelinfos'
fi

if ! version="$( grep -A 1 'id="latest_link"' <<< "$kernelinfo" | grep -Po '(?<=\.tar\.xz">)[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(?=</a>)' )"
then
    Exit 2 'Fehler beim Ermitteln der Versionsnummer'
fi

echo "Neuester stabiler Kernel ist: $version"

echo "Aktuell laufender Kernel ist: $ak"

current_kernel="${ak//-*/}"

if (( $( printf "%d%02d%02d" ${current_kernel//./ } ) >= $( printf "%d%02d%02d" ${version//./ } ) ))
	then
	if ! zenity --question \
	--width='700' \
	--timeout='30' \
	--ok-label="Ja" \
	--cancel-label="Nein" \
	--icon-name='system-help' \
	--title "Aktuell installiert - $ak" \
	--text "<b>Aktueller geht nicht.\\n\\n\
Latest stable, auf kernel.org, ist $version.\\n\\n\
Abbruch des Scripts erfolgt in 30 Sekunden. \
\\n\\n<span color='#ff0000'>                                        \
<span size='xx-large'>Download dennoch starten?</span></span></b>" 2>/dev/null
	then
				exit 0
	else
				echo 'Download genehmigt'
	fi
fi

if ! [ -d "$workdir" ]
then
    if ! mkdir "$workdir"
    then
        Exit 3 'Fehler beim Erzeugen eines Arbeitsordners'
    fi
fi

if ! [ -d "$patchdir" ]
then
    if ! mkdir "$patchdir"
    then
        Exit 31 'Fehler beim Erzeugen des Patchordners'
    fi
fi

if ! cd "$workdir"
then
    Exit 4 'Fehler beim Wechsel in den Arbeitsordner'
fi

echo "Arbeitsordner ist: $workdir"

if ! zenity --question \
		--width='700' \
		--ok-label="Ja" \
		--cancel-label="Abbruch" \
		--title "Aktuell installiert - $ak" \
		--text "\\n\\n<b>Download von Kernel $version starten?</b>" 2>/dev/null
		then
				exit 0
fi

if ! wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-"$version".tar.xz
then
	Exit 5 'Fehler beim Download der Kernels'
fi

echo "Die Datei linux-$version.tar.xz wird entpackt."

if ! tar xf linux-"$version".tar.xz
then
	Exit 6 "Fehler beim entpacken  von linux-$version.tar.xz"
fi

echo "Wechsel in den Ordner $PWD/linux-$version"

if ! cd "$workdir/linux-$version"
then
	Exit 7 "Fehler beim Wechsel in den Ordner $PWD/linux-$version"
fi

echo "Die .config wird aus der vorhandenen config-$ak erstellt"


if ! zenity --question \
		--ok-label="Ja" \
		--cancel-label="Abbruch" \
		--title "Aktuell installiert - $ak" \
		--text "\\n\\n<b>Option:\\n\\nWenn der Kernel gepatcht werden soll muss der Ordner    \\n\\n\
$patchdir  \\n\\neine *.patch Datei enthalten.\\n\\nMit oder ohne patch weiter?</b>" 2>/dev/null
		then
				exit 0
fi

if ! patch -p1 < ../kernel_gcc_patch/*.patch
then
	echo "Kein *.patch in $patchdir vorhanden, kein Problem, weiter"
	else
    echo 'Kernel wird gepatcht'
fi

if ! cp /boot/config-"$ak" .config
then
	Exit 8 'Fehler beim Erzeugen der .config'
fi

if ! zenity --question \
		--width='700' \
		--ok-label="Ja" \
		--cancel-label="Abbruch" \
		--title "Aktuell installiert - $ak" \
		--text "\\n\\n<b>Kernel $version bauen?</b>" 2>/dev/null
		then
				exit 0
fi

if ! sed -i 's/CONFIG_DEBUG_INFO=y/CONFIG_DEBUG_INFO=n/g' .config
then
	Exit 9 'Fehler, .config konnte nicht erstellt werden'
fi

if ! yes '' | make oldconfig
then
	Exit 10 'Fehler: make oldconfig fehlgeschlagen'
fi
#make menuconfig
d=$(printf %02d ${version//./ })

if ! make clean
then
	Exit 11 'Fehler: Konnte nicht durchwischen'
fi

if ! make -j '$(nproc) bindeb-pkg LOCALVERSION='-$d
then
		Exit 12 'Kernel backen fehlgeschlagen'
fi

if ! cd '$workdir'
then
    Exit 13 'Fehler beim Wechsel in den Arbeitsordner'
fi

if ! zenity --question \
		--width='700' \
		--timeout='30' \
		--ok-label='Ja' \
		--cancel-label='Nein' \
		--title 'Aktuell installiert - $ak' \
		--text '<b>Kernel linux-image-'$version-$d'-1 installieren?</b>' 2>/dev/null
		then
				exit 0
fi

echo "Stop on line 215, for do not install kernel"

exit 0

if ! gksudo --message 'Für die Installation des Kernel werden Rootrechte benötigt.Passwort eingeben oder [Abbrechen] drücken.' -- tee '${launcher}'
		then
				exit 0
		else
				dpkg -i linux-headers-* linux-image-*
fi

I gotta check how many cores I actually have available. Probably not enough to compete, I think I’m only around 60 cores unused.

You can install it, but probably not worth it as it’s not nearly as streamlined/optimized as the arch kernel provided. If you wanted something more suited to your system you’d probably wanna run make localyesconfig instead of make defconfig. This will only build the modules your system has currently loaded (so you’d wanna attach usb devices and things like that you’d normally use to make sure they’re present in the kernel image before running this) and will be more streamlined. Lastly, to make it easier to replace and update you’d wanna make your own PKGBUILD for it which is easy enough if you take the Arch one as the blueprint for yours. Could at the very least make for a fun project even if you don’t end up keeping it.

As mentioned above, probably modifying the default arch PKGBUILD would be easier if you wanted to go down this route. Could make for a fun learning experience :slight_smile:

2 Likes

Good to have a bit of variety. Here’s my media server

CPU: AMD R5 3600
RAM: 16GB @ 2133MHz
GPU: N/A

real 1m55.406s
user 19m29.849s
sys 1m37.744s

…and my lappy while connected to power (Dell XPS 15):

CPU: i7 9750
RAM: 16GB @ 2666MHz (I think)
GPU: GTX 1650

real 3m53.772s
user 38m29.810s
sys 3m48.048s

@alenbasic
I tried this on my Intel but it didn’t give me the times. I got this at the end.

ld: arch/x86/boot/compressed/head_64.o: warning: relocation in read-only section `.head.text'
ld: warning: creating DT_TEXTREL in a PIE
  ZOFFSET arch/x86/boot/zoffset.h
  OBJCOPY arch/x86/boot/vmlinux.bin
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Setup is 13884 bytes (padded to 14336 bytes).
System is 8831 kB
CRC a0c127cc
Kernel: arch/x86/boot/bzImage is ready  (#1)
[ricklinux@eos-xfce linux-5.8.3]$ 

Probably forgot to wrap the make in time(), i.e. time(make -j$(nproc))

Actually i tried it again and used @jonathon command without the double brackets and it worked?

Intel i7-8086K 6 core 12 thread
Nvidia GTX1060
32 GB DDR4 2666

Kernel: arch/x86/boot/bzImage is ready (#1)

real	2m18.382s
user	23m17.767s
sys	2m13.214s
[ricklinux@eos-xfce linux-5.8.3]$ 
1 Like

yeah, you don’t need them per se; force of habit for me :laughing: