Which compression algorithm to choose in mkinitcpio.conf?

I wanted to add some data to this discussion. We are talking about the boot process. So I benchmarked the boot time (systemd-analayze time) and the size of the initramfs files for the 5 compression algorithms gzip, xz, lz4, bzip2 and zstd. I used my endeavourOS virtualbox for that. 5 boot process per compression algorithm and I always discarded the slowest result in a series.

Here it is:

        absolut values      ratios
        time    size        time    size 
        [s]     [MB]        [%]     [%]
gzip    7,72    36,4        104     142
xz      7,78    25,6        104     100
lz4     7,44    53,0        100     207
bzip2   8,48    34,2        114     134
zstd    7,66    29,2        103     114

Conclusion:

  • bzip2 should not be used. I am taking it out of consideration.
  • best boot time is with lz4
  • best compression is with xz
  • taking out bzip2 the boot time variation is 3-4 %. That is not much.
  • taking out bzip2 the compression variation is up to 207 %. That is a lot.

For me personally xz is the winner. It boots in 7,78 s. This is just 0,33 s slower than the fastest algorithm lz4. But xz creates the smallest files which are half the size of what lz4 is doing.

We also need to keep in mind that these are really fast boot times because my virtualbox is lean with no extra services. In real life boot times would be longer because of all the service start activities. These extra seconds are more than compensating the performance gain of lz4.

5 Likes