The boot speed to login prompt is currently 17 seconds. Things to try:
I think at this stage we're paying a lot for compression and probing hardware before we get to the login shell.
Xogium's done some work optimizing the bootloader, which has saved at least 0.56 seconds. So the current theoretical boot is around 7.5 seconds. The kernel itself reaches init at around 1.9 seconds from power on. So the remaining work will probably have to starting the shell within two seconds from systemd start, to get the 4 second boot we want.
So over the past while Xogium has spent some time trying to reduce boot speed with the goal of booting to whatever shell we make and being able ready to play or record audio in under 4 seconds. There's a lot of obstacles here, such as checking filesystems, mounting filesystems, probing devices using udev, logging things to storage, etc. A lot of it can be done in parallel.
But unfortunately it looks like systemd isn't the right tool for the job here. systemd really wants to read all units at boot, which wastes a second. The earliest we can run a unit is around 3 seconds, with actual login happening around 8 seconds in to boot. In theory maybe we could save a second if systemd fixes the 'read all units at boot' bug. But even then the system is spending a lot of IO on systemd-journald and feels a bit sluggish.
Looking at alternative boot systems, OpenRC takes longer and isn't an improvement. busybox and runit have shown promise in the ability to tune what happens at boot. Mounting the root filesystem and opening a shell takes 1.7 seconds, with device probing and networking done afterwards in the background.
However, we're hitting problems with this setup:
The large one is especially trouble as it requires pivoting to a new root. All stock boot options I can find (systemd, busybox) require restarting all system services when pivoting, which negates any benefit of parallel startup. It's a missed opportunity since ideally we could start the shell, a logging daemon, start probing devices all while we set up the rootfs.
Ideally the system management would go like this:
This might be doable with shell scripts and a modified runit. It would go like this:
Some specific implementation snags and how to fix:
As a prototype we might be able to avoid modifying runit by having a bit more code in the 'run' files that:
If this turns out to work well it might be a better idea to roll this in to our own custom init written in Lua that can handle all this properly.
Okay, so after doing some prototyping with runit I found out that it's slow to do something basic like start a getty.
I also spent a while trying to re-clock the SDMMC2 speed to 104mhz to see if that would help with DDR52. It didn't seem to do anything.