Skip to content

Add support for LZ4 compression

Ghost User requested to merge (removed):hc-hmk/lz4-compression into master

The LZ4 compression algorithm offers worse compression ratios than gzip, xz (lzma) and zstd, but provides WAY faster decompression speeds, which is useful for some systems. As an example, the speeds on my work laptop is initramfs-virt.cpio : 10271768 -> 6898249 (1.489), 8.5 MB/s, 3750.8 MB/s when compressing initramfs-virt.cpio stolen from a stock Alpine 3.15 x86_64 VM.

Requirements:

  • The running kernels kconfig should have CONFIG_RD_LZ4=y, which is default on Alpine.
  • The system executing mkinitfs should have lz4 (APKBUILD) installed

Arguments given to the compressor at runtime:

  • -z force compression
  • -l compress using Legacy format (Linux kernel compression)
  • --best same as -12, highest compression ratio
  • --favor-decSpeed compressed files decompress faster, but are less compressed

HMK Bilcon A/S already uses these changes to mkinitfs in production for our embedded devices, and have done so since around 2019. This works, and offers a noticeably faster boot on low-power devices with flash storage. We would like to upstream these changes, as we see them as stable and think they would benefit the rest of the community.

Merge request reports