Skip to content

Use 3cpio for unmkinitramfs/lsinitramfs if available

Benjamin Drung requested to merge bdrung/initramfs-tools:3cpio into debian/latest

Since Ubuntu 23.10 the initrd consists of 4 embedded cpio:

  • amd microcode
  • intel microcode
  • firmware + kernel modules
  • rest (compressed)

There is no archive size header for cpio, so unmkinitramfs has to parse headers of each entry in uncompressed archives.

Use 3cpio in case it is installed.

Benchmark results on 2025-06-05:

$ sudo hyperfine "./unmkinitramfs --list /boot/initrd.img" "./unmkinitramfs-old --list /boot/initrd.img"
Benchmark 1: ./unmkinitramfs --list /boot/initrd.img
  Time (mean ± σ):      71.4 ms ±   1.4 ms    [User: 2.3 ms, System: 19.0 ms]
  Range (min … max):    68.9 ms …  74.7 ms    40 runs

Benchmark 2: ./unmkinitramfs-old --list /boot/initrd.img
  Time (mean ± σ):      91.1 ms ±   2.0 ms    [User: 92.7 ms, System: 120.0 ms]
  Range (min … max):    88.8 ms …  98.1 ms    32 runs

Summary
  ./unmkinitramfs --list /boot/initrd.img ran
    1.28 ± 0.04 times faster than ./unmkinitramfs-old --list /boot/initrd.img
$ sudo hyperfine -p "rm -rf /tmp/initrd" "./unmkinitramfs /boot/initrd.img /tmp/initrd" "./unmkinitramfs-old /boot/initrd.img /tmp/initrd"
Benchmark 1: ./unmkinitramfs /boot/initrd.img /tmp/initrd
  Time (mean ± σ):      92.3 ms ±   1.7 ms    [User: 5.0 ms, System: 60.7 ms]
  Range (min … max):    89.9 ms …  98.1 ms    26 runs

Benchmark 2: ./unmkinitramfs-old /boot/initrd.img /tmp/initrd
  Time (mean ± σ):     201.0 ms ±   2.1 ms    [User: 119.9 ms, System: 220.9 ms]
  Range (min … max):   197.0 ms … 203.0 ms    13 runs

Summary
  ./unmkinitramfs /boot/initrd.img /tmp/initrd ran
    2.18 ± 0.05 times faster than ./unmkinitramfs-old /boot/initrd.img /tmp/initrd

Note: Extracting the initramfs to disk is slower, but the performance difference stays the same.

LP: #2059976

Merge request reports

Loading