Skip to content

Build performance regression for bookworm+

I mentioned in other issues that I'm building images based on image-specs and I've noticed a huge bump in build time in the last few weeks. Today, I've finally spent some time reproducing that issue with the unpatched master branch in the image-specs repository, and confirmed the origin of this regression.

The point of this issue is mostly to let others know about this change. We could try and use dpkg-divert on update-initramfs to only run it once for real, at the very end, but I fear this kind of optimization might just break things; having a consistent, reliable build seems better than a quicker, maybe subtly broken one…

After investigation, it turns out that initramfs-tools is responsible for this, namely the upgrade from 0.142 to 0.142+deb12u1, which appeared via the 12.7 point release.

On a Pi 4, using a UASP device (so better I/Os than a SD card), within a bookworm chroot where both linux-image-arm64 and initramfs-tools are installed, a single update-initramfs -u -k 6.1.0-27-arm64 takes 29.5 seconds with the old version, versus 53.1 seconds with the new version.

(Each time run three times, standard deviation almost zero.)

Reverting f52ae2d3b8d13eb488eb1923980b4a54736d76e7 helps, getting down to 38.1 seconds. Additionally reverting 05e5fb9eef1caeb827169f2510c868a83ad4013f also helps, getting down to 30.0 seconds. That's almost the original number, but other changes are about adding a few more modules, so that seems pretty consistent.

This is absolutely not to say those commits are bad or unwelcome, they just happen to trigger a lot of extra fork/exec compared to the original version, which takes a little more time natively, but a lot more time when crossbuilding; to be honest, seeing all those realpath calls show up in ps/top while waiting for the builds to finish is the reason why I looked into those two commits specifically.

Building raspi_4_bookworm.img on my laptop (Intel, i7-12700H), the current state of bookworm requires 14 minutes and 11 seconds (± 15 seconds). Adding a repository with patched initramfs-tools/initramfs-tools-core packages (with both commits reverted) gets us back to the original, “under 10” numbers: 8 minutes and 12 seconds (± 8 seconds).