Switch to zstd for faster decompression/startup

This commit is contained in:
Mikhail Novosyolov 2021-05-03 18:21:14 +03:00
parent 464c5c81a4
commit 846f0d6a2f

View file

@ -99,6 +99,12 @@
# and it has not been adapted for kernel 5.10 (is not buildable) # and it has not been adapted for kernel 5.10 (is not buildable)
%bcond_with binary_shredder %bcond_with binary_shredder
# compress modules with zstd (zstd is good compression and fast decompression)
%bcond_without compress_modules
# Spend more resources on compression, but make resulting size less;
# decompression speed will not be affected.
%define zstd_cmd zstd -q --format=zstd --ultra -22
# Kernel flavour # Kernel flavour
%if %{with nickel} %if %{with nickel}
%define flavour nickel %define flavour nickel
@ -162,9 +168,6 @@
%define build_cpupower 0 %define build_cpupower 0
%endif %endif
# compress modules with xz
%define build_modxz 1
# End of user definitions # End of user definitions
# buildtime flags # buildtime flags
@ -173,19 +176,17 @@
%{?_without_debug: %global build_debug 0} %{?_without_debug: %global build_debug 0}
%{?_without_perf: %global build_perf 0} %{?_without_perf: %global build_perf 0}
%{?_without_cpupower: %global build_cpupower 0} %{?_without_cpupower: %global build_cpupower 0}
%{?_without_modxz: %global build_modxz 0}
%{?_with_doc: %global build_doc 1} %{?_with_doc: %global build_doc 1}
%{?_with_devel: %global build_devel 1} %{?_with_devel: %global build_devel 1}
%{?_with_debug: %global build_debug 1} %{?_with_debug: %global build_debug 1}
%{?_with_perf: %global build_perf 1} %{?_with_perf: %global build_perf 1}
%{?_with_cpupower: %global build_cpupower 1} %{?_with_cpupower: %global build_cpupower 1}
%{?_with_modxz: %global build_modxz 1}
%if %{build_modxz} %if %{with compress_modules}
%define kmod_suffix .xz %define kmod_suffix .zst
%else %else
%define kmod_suffix .gz %define kmod_suffix %{nil}
%endif %endif
%if !%{build_debug} %if !%{build_debug}
@ -402,6 +403,10 @@ BuildRequires: kernel-source-rosa-test-suite
BuildRequires: ccache BuildRequires: ccache
%endif %endif
%if %{with compress_modules}
BuildRequires: zstd
%endif
# might be useful too: # might be useful too:
Recommends: microcode Recommends: microcode
@ -1356,7 +1361,8 @@ popd
install -d %{temp_boot} install -d %{temp_boot}
install -m 644 System.map %{temp_boot}/System.map-%{kver_full} install -m 644 System.map %{temp_boot}/System.map-%{kver_full}
install -m 644 .config %{temp_boot}/config-%{kver_full} install -m 644 .config %{temp_boot}/config-%{kver_full}
xz -c Module.symvers > %{temp_boot}/symvers-%{kver_full}.xz %{zstd_cmd} Module.symvers
install -m 644 Module.symvers.zst %{temp_boot}/symvers-%{kver_full}.zst
%ifarch %{armx} %ifarch %{armx}
%make_build ARCH=arm64 V=1 INSTALL_DTBS_PATH=%{temp_boot}/dtb-%{kver_full} dtbs_install %make_build ARCH=arm64 V=1 INSTALL_DTBS_PATH=%{temp_boot}/dtb-%{kver_full} dtbs_install
@ -1503,7 +1509,7 @@ kernel_files=../kernel_files.%{flavour}
cat > $kernel_files <<EOF cat > $kernel_files <<EOF
%{_bootdir}/System.map-%{kver_full} %{_bootdir}/System.map-%{kver_full}
%{_bootdir}/symvers-%{kver_full}.xz %{_bootdir}/symvers-%{kver_full}.zst
%{_bootdir}/config-%{kver_full} %{_bootdir}/config-%{kver_full}
%{_bootdir}/vmlinuz-%{kver_full} %{_bootdir}/vmlinuz-%{kver_full}
%ifarch %{armx} %ifarch %{armx}
@ -1591,10 +1597,9 @@ fi
rm -f %{certs_verify_tmp} rm -f %{certs_verify_tmp}
# compressing modules # compressing modules
%if %{build_modxz} %if %{with compress_modules}
find %{target_modules} -name "*.ko" | %kxargs xz -6e # -T1 (one thread) because we run multiple zstd processes by xargs
%else find %{target_modules} -name "*.ko" | %kxargs %{zstd_cmd} --rm -T1
find %{target_modules} -name "*.ko" | %kxargs gzip -9
%endif %endif
pushd %{target_modules} pushd %{target_modules}