Put compressed kernel modules and firmware in an uncompressed cpio
initramfs-tools decompresses kernel modules and firmware files before putting them into the initramfs. This has several drawbacks:
- The compressed kernel modules and firmware files might be compressed with a higher level. So recompressing them in the initramfs can increase the size.
- Decompressing and compressing these files during mkinitramfs will take time.
- The size of the decompressed initramfs will be bigger. That size is needed in memory during boot.
So put compressed kernel modules and firmware files in an uncompressed cpio instead. To make this change have an impact the files need to be shipped compressed.
Benchmark results on Ubuntu
The benchmarks were done either on an AMD Ryzen 7 5700G with schroot and overlay on tmpfs or on the hardware mentioned. All tests were running the Ubuntu mantic development release in July 2023.
- minimal: schroot with linux-image-generic initramfs-tools zstd
- full: minimal + busybox-initramfs cryptsetup-initramfs isc-dhcp-client kbd lvm2 mdadm ntfs-3g plymouth plymouth-theme-spinner
- nvidia: full + linux-headers-generic nvidia-driver-525
- nvidia fw: nvidia + compressed /lib/firmware/nvidia/525.125.06/
- VisionFive 2: VisionFive 2 RISC-V board
- RPi Zero 2: Raspberry Pi Zero 2 ARM board (running armhf)
"next" means using kernel and firmware packages from a PPA that ship the
files compressed with zstd -19
plus initramfs-tools with this patch.
test | build time | size in bytes | size in MiB | uncompressed size in bytes | ... in MiB |
---|---|---|---|---|---|
minimal | 4.30 s | 66701818 | 63.6 | 224087608 | 213.7 |
minimal next | 4.54 s | 59935186 | 57.2 | 67738810 | 64.6 |
full | 7.15 s | 118007038 | 112.5 | 387976843 | 370.0 |
full next | 7.29 s | 106937908 | 102.0 | 128610985 | 122.7 |
nvidia | 7.04 s | 209200523 | 199.5 | 513554279 | 489.8 |
nvidia next | 7.21 s | 195246287 | 186.2 | 235288174 | 224.4 |
nvidia fw next | 7.16 s | 191329102 | 182.5 | 213078234 | 203.2 |
VisionFive 2 | 142.9 s | 121895035 | 116.2 | 411160836 | 392.1 |
VisionFive 2 next | 126.7 s | 111651453 | 106.5 | 134120804 | 127.9 |
RPi Zero 2 | 109.5 s | 39803044 | 40.0 | 69592789 | 66.4 |
RPi Zero 2 ² | 103.5 s | 39804499 | 40.0 | 69592789 | 66.4 |
RPi Zero 2 next | 101.2 s | 31463352 | 30.0 | 41145762 | 39.2 |
² Updated initramfs-tools (but no compressed modules or firmware)
improvement | build time | size | uncompressed size |
---|---|---|---|
minimal | 105.6 % | 89.9 % | 30.2 % |
full | 102.0 % | 90.6 % | 33.1 % |
nvidia | 101.7 % | 91.5 % | 41.5 % |
VisionFive 2 | 88.7 % | 91.6 % | 32.6 % |
RPi Zero 2 | 92.4 % | 79.0 % | 59.1 % |
See https://lists.ubuntu.com/archives/ubuntu-devel/2023-July/042707.html
LP: #2028567