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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Netcup eipower 1