Last active
August 23, 2023 10:55
-
-
Save versionsix/117888940c928feafe726859b4273f4c to your computer and use it in GitHub Desktop.
Compile linux 5.0 kernel benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mv /root/logs.txt /root/logs_`date +%s`.txt 2>/dev/null || true | |
exec &> >(tee -a "/root/logs.txt") | |
systemctl restart systemd-timesyncd | |
start_time=`date +%s` | |
export DEBIAN_FRONTEND=noninteractive | |
echo "===========================================" | |
echo " UPDATE SYSTEM" | |
echo "===========================================" | |
start_time_update=`date +%s` | |
time apt -q update 2>&1 | |
time apt -yq upgrade 2>&1 | |
end_time_update=`date +%s` | |
echo "===========================================" | |
echo " Install build deps" | |
echo "===========================================" | |
start_time_apt_install=`date +%s` | |
time apt -yq install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache flex bison libelf-dev jq fio ioping 2>&1 | |
end_time_apt_install=`date +%s` | |
echo "===========================================" | |
echo " Download kernel from cdn" | |
echo "===========================================" | |
start_time_download_kernel=`date +%s` | |
time wget -q -O linux-5.0.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.tar.xz 2>&1 | |
end_time_download_kernel=`date +%s` | |
echo "===========================================" | |
echo " Extract kernel" | |
echo "===========================================" | |
start_time_extract_kernel=`date +%s` | |
rm -rf linux-5.0 | |
time tar -xf linux-5.0.tar.xz 2>&1 | |
end_time_extract_kernel=`date +%s` | |
echo "===========================================" | |
echo " Configure kernel" | |
echo "===========================================" | |
start_time_configure_kernel=`date +%s` | |
pushd linux-5.0 | |
time (make defconfig ; make clean) 2>&1 | |
sed -i 's/CONFIG_STACK_VALIDATION=y/CONFIG_STACK_VALIDATION=n/' .config | |
sed -i 's/CONFIG_UNWINDER_ORC=y/CONFIG_UNWINDER_ORC=n/' .config | |
sed -i 's/# CONFIG_UNWINDER_FRAME_POINTER is not set/CONFIG_UNWINDER_FRAME_POINTER=y/' .config | |
end_time_configure_kernel=`date +%s` | |
echo "===========================================" | |
echo " Compile kernel" | |
echo "===========================================" | |
start_time_compile_kernel=`date +%s` | |
time make -s -j $(grep -c ^processor /proc/cpuinfo) 2>&1 | |
end_time_compile_kernel=`date +%s` | |
end_time=`date +%s` | |
runtime=$((end_time-start_time)) | |
echo "===========================================" | |
echo "Whole bench execution time: "$runtime" seconds" | |
echo "===========================================" | |
echo "===========================================" | |
echo " Verify compiled kernel" | |
echo "===========================================" | |
dd if=arch/x86/boot/bzImage bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' arch/x86/boot/bzImage | cut -d ':' -f 1) | zcat 2>/dev/null | grep -a 'Linux version' | |
echo "===========================================" | |
echo " Running disk benchmarks" | |
echo "===========================================" | |
dd_sequential_write_speed_64k=`(LANG=C dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'` | |
dd_sequential_write_speed_256k=`(LANG=C dd if=/dev/zero of=test_$$ bs=256k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'` | |
fio_bench_64k=`fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=test --bs=64k --iodepth=64 --size=4G --readwrite=randrw --time_based --runtime=60 --rwmixread=75 --output-format=json` | |
fio_bench_256k=`fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=test --bs=256k --iodepth=256 --size=4G --readwrite=randrw --time_based --runtime=60 --rwmixread=75 --output-format=json` | |
rm -f test | |
fio_read_iops_mean_64k=`echo $fio_bench_64k | jq '.jobs[].read.iops_mean'` | |
fio_write_iops_mean_64k=`echo $fio_bench_64k | jq '.jobs[].write.iops_mean'` | |
fio_read_iops_mean_256k=`echo $fio_bench_256k | jq '.jobs[].read.iops_mean'` | |
fio_write_iops_mean_256k=`echo $fio_bench_256k | jq '.jobs[].write.iops_mean'` | |
ioping_seek_rate=`ioping -DR -w 5 . | tail -n 1` | |
ioping_sequential_read=`ioping -DRL -w 5 . | tail -n 2 | head -n 1` | |
mv /root/bench.txt /root/bench_`date +%s`.txt 2>/dev/null || true | |
tee /root/bench.txt << EOF | |
Kernel_bench seconds | |
Update_system: $((end_time_update-start_time_update)) | |
Install_build_deps: $((end_time_apt_install-start_time_apt_install)) | |
Download_kernel: $((end_time_download_kernel-start_time_download_kernel)) | |
Extract_kernel: $((end_time_extract_kernel-start_time_extract_kernel)) | |
Configure_kernel: $((end_time_configure_kernel-start_time_configure_kernel)) | |
Compile_kernel: $((end_time_compile_kernel-start_time_compile_kernel)) | |
Total: $((end_time-start_time)) | |
Disk_bench: | |
Seq_write_speed_64k $dd_sequential_write_speed_64k | |
Seq_write_speed_256k $dd_sequential_write_speed_256k | |
Read_iops_mean_64k $fio_read_iops_mean_64k | |
Write_iops_mean_64k $fio_write_iops_mean_64k | |
Read_iops_mean_256k $fio_read_iops_mean_256k | |
Write_iops_mean_256k $fio_write_iops_mean_256k | |
Ioping_seek_rate $ioping_seek_rate | |
Ioping_seq_read $ioping_sequential_read | |
EOF |
Netcup eipower 1
Kernel_bench seconds
Update_system: 3
Install_build_deps: 110
Download_kernel: 2
Extract_kernel: 8
Configure_kernel: 8
Compile_kernel: 289
Total: 420
Disk_bench:
Seq_write_speed_64k 295 MB/s
Seq_write_speed_256k 465 MB/s
Read_iops_mean_64k 4075.025
Write_iops_mean_64k 1361.591667
Read_iops_mean_256k 1464.533333
Write_iops_mean_256k 489.233333
Ioping_seek_rate min/avg/max/mdev = 34.1 us / 60.3 us / 1.09 ms / 105.0 us
Ioping_seq_read generated 9.82 k requests in 5.00 s, 2.40 GiB, 1.96 k iops, 491.2 MiB/s
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AWS Ligstsail 5,00USD-1GB-1VCPU-40GSSD
Time till ssh: about 30 seconds
Azure PAYGO 93,41USD+-8GB-2VCPU-32GSSD (D2s-v3 + P4 SSD)
Time till ssh: 234 seconds
Hetzner Cloud 5,54USD-4GB-2VCPU-40GSSD (CX21)
Time till ssh: 15 seconds
Hetzner Cloud 5,54USD-4GB-2VCPU-40GSSD (CX21-CEPH)
Time till ssh: 20 seconds
Digital ocean: 40USD-4GB-2VCPU-25GSSD
Time till ssh: 30 sec