RPi-Distro / pi-gen

Tool used to create the official Raspberry Pi OS images
BSD 3-Clause "New" or "Revised" License
2.52k stars 1.58k forks source link

Make use of multiple CPU cores and/or generally profile the build #731

Open jeffmakes opened 7 months ago

jeffmakes commented 7 months ago

Hi,

I'm trying to develop a custom RPi image, and it's going to take a large number of build-test cycles to get everything working right. Building a stage 2 image from a clean state takes about 40 minutes on a Github Actions runner (2 cores, 7GB RAM), an AWS t3.2xlarge (8 cores, 32GB) and a c5a.8xlarge (32 cores 64GB RAM).

Looking in htop I can see that, when the build is maxing out a whole core it is almost always just one. Most of the time it's using much less. What's really strange is that some steps take a really long time, like "update-initramfs: Generating /boot/initrd.img-6.1.0-rpi6-rpi-v8", but hardly use any CPU, memory, network or disk bandwidth. What is it doing for all this time?

It would be really great if you could do some profiling and see if there are some things that could be run in parallel. I'm sure the Pi Foundation developers would benefit from a quicker build as much as the customers.

Running a build without CLEAN takes about 11 minutes, so that's a big improvement. I'm currently working to get Github Actions to cache the /work folder between runs so I can get an 11 minute build every time.

It would be really great to be able to rent a ludicrously powerful cloud compute instance for a week or two while I work on my build, but there's no point at present - no matter how much resource you throw at it, pi-gen takes 40 minutes.

Cheers Jeff