Monday 19 March 2018

Re: Supporting LZ4 as initramfs compressor

Last night I was trying to decrypt my laptop remotely. Work well
(after some research) and so on, but the point is I put Dropbear SSH
server inside initramfs and a faster decompress would be very
welcomed.

On Mon, Mar 19, 2018 at 2:19 PM, Balint Reczey
<balint.reczey@canonical.com> wrote:
> On Mon, Mar 19, 2018 at 3:12 PM, Julian Andres Klode
> <julian.klode@canonical.com> wrote:
>> On Mon, Mar 19, 2018 at 02:59:24PM +0000, Balint Reczey wrote:
>>> Hi,
>>>
>>> Initramfs-tools uses gzip compression by default which served us well
>>> for quite some time but LZ4 offers way faster decompression while
>>> making a only slightly bigger initramfs files.
>>>
>>> On my old laptop the initramfs extraction time decreased from ~1.2s to ~0.24s:
>>> (with lz4)
>>> kernel: [ 0.297726] Unpacking initramfs...
>>> kernel: [ 0.535061] Freeing initrd memory: 77940K
>>> kernel: [ 0.301637] Unpacking initramfs...
>>> kernel: [ 0.539109] Freeing initrd memory: 77940K
>>> (with gzip)
>>> kernel: [ 0.273748] Unpacking initramfs...
>>> kernel: [ 1.490066] Freeing initrd memory: 57140K
>>> kernel: [ 0.281729] Unpacking initramfs...
>>> kernel: [ 1.498493] Freeing initrd memory: 57140K
>>>
>>> The increase in the initrd.img size is ~14%:
>>> (lz4)
>>> -rw-r--r-- 1 root root 66709065 márc 19 14:24
>>> /boot/initrd.img-4.15.0-12-generic
>>> (gzip)
>>> -rw-r--r-- 1 root root 58510993 márc 19 12:57
>>> /boot/initrd.img-4.15.0-12-generic.bak
>>>
>>> Initramfs creation speed also improved a bit from ~24s to ~21s wall clock time:
>>> (lz4)
>>> update-initramfs: Generating /boot/initrd.img-4.15.0-12-generic
>>> 14.97user 6.31system 0:20.47elapsed 103%CPU (0avgtext+0avgdata
>>> 22368maxresident)k
>>> update-initramfs: Generating /boot/initrd.img-4.15.0-12-generic
>>> 15.18user 6.49system 0:20.48elapsed 105%CPU (0avgtext+0avgdata
>>> 22308maxresident)k
>>> (gzip)
>>> update-initramfs: Generating /boot/initrd.img-4.15.0-12-generic
>>> 18.23user 6.77system 0:23.61elapsed 105%CPU (0avgtext+0avgdata
>>> 22396maxresident)k
>>> update-initramfs: Generating /boot/initrd.img-4.15.0-12-generic
>>> 18.38user 6.83system 0:23.82elapsed 105%CPU (0avgtext+0avgdata
>>> 22292maxresident)k
>>
>> For me it was 16 -> 10 I think.
>>
>>>
>>> Base on the results I plan adding LZ4 compression support to
>>> initramfs-tools as requested in LP: #1488620 [1] in the next days
>>> without setting it as default
>>>
>>
>> +1
>>
>>> and I propose setting LZ4 as default for 18.10.
>>
>> We might have zstd support by that time (I hope), it might make sense
>> to use that then (better space/time tradeoff), but we'll have to see.
>
> That would also be an option, but I expect zstd to bring little speed
> advantage over LZ4 here while LZ4 support could be easily backported
> to releases with older kernels.
>
> The proposed patch enabling lz4 uses lz4 -9. I tried lz4's default
> compression, -1, but decompression speed difference was barely
> noticeable - most likely due to copying being the bottleneck.
>
> In fact I just realized that i copied the results created with lz4 -1,
> where the compressed initrd size was 77940K.
> The correct results for lz4 -9 are the following, taking the same
> ~0.24s to decompress:
>
> kernel: [ 0.285692] Unpacking initramfs...
> kernel: [ 0.518806] Freeing initrd memory: 65148K
> kernel: [ 0.289731] Unpacking initramfs...
> kernel: [ 0.522823] Freeing initrd memory: 65148K
>
> Cheers,
> Balint
>
> --
> Balint Reczey
> Ubuntu & Debian Developer
>
> --
> ubuntu-devel mailing list
> ubuntu-devel@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel

--
Marcos H. Alano
Linux System Administrator
marcoshalano@gmail.com

--
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel