unmkinitramfs is very slow on initrd from ubuntu 23.10+, solution proposed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
initramfs-tools (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Since 23.10 the initrd consists of 4 embedded cpio:
- amd microcode
- intel microcode
- firmware + kernel modules
- rest (compressed)
Previously it was:
- amd microcode
- intel microcode
- rest (compressed)
There is no archive size header for cpio, so unmkinitramfs has to parse headers of each entry in uncompressed archives.
> time unmkinitramfs 23.04/{
real 0m3.625s
user 0m1.595s
sys 0m3.467s
> time unmkinitramfs 23.10/{
real 0m15.982s
user 0m20.174s
sys 0m6.995s
> for dir in 23.04/unpack/
23.04/unpack/early 5
23.04/unpack/early2 6
> for dir in 23.10/unpack/
23.10/unpack/early 5
23.10/unpack/early2 6
23.10/unpack/early3 2874
Here https:/
- bash instead of sh for bash's "read -N"
- xxd dump of initrd instead of raw binary data
I wonder, if the developers are interested in accepting my improvements into the code base?
> time unmkinitramfs-
real 0m2.209s
user 0m2.161s
sys 0m1.341s
> time unmkinitramfs-turbo 23.10/{
early .. +
early2 .. +
early3 .. +
main .. +
real 0m1.973s
user 0m2.094s
sys 0m1.244s
All tools in the repo, even the classic one, feature -s/--scan option. With it, the tools only dump offset + size for embedded archives, nothing is unpacked. It can be used to measure parsing speed.
In the repo there are three tools:
- unmkinitramfs-
- unmkinitramfs-
- unmkinitramfs-
Thank you for taking the time to report this bug and helping to make Ubuntu better. Speed improvements are welcome. Please submit those changes (preferred in the smallest possible chunks).
Maybe we should rewrite splitinitramfs (or the complete script) in C.