As I said in my previous post I’ve decided to use BusyBox to strip down a Gentoo system to a bare minimum for the device I’m working on right now. This actually allows for a lot of things to be merged into a single package, but at the same time it has another very interesting side effect.
One of the reasons why systemd has been developed is that the traditional init systems for Unix use shell scripts for starting and stopping the services, which is slow both due to the use of bash (which is known to be slow and bloated for the task) and the use of fork/exec model for new commands. While we’ve had some work done to get the init scripts reduced and working with alternative shells, namely dash, what I’m using now is a slightly different variation: everything is done through BusyBox.
This has more than just the advantage of its shell scripting being faster: when using a “fat” build of busybox, which includes most of the utilities used in Linux, including coreutils, which and so on so forth, the execution of commands such as cut
, sed
, and the like is no longer happening through fork/exec, but rather through internal calls, as BusyBox is a multi-call binary. And even if the call is so complex it has to fork for it (which doesn’t happen so often for what I can tell), the binary is already well in memory, relocated and all.
Up to now I only found one issue in OpenRC when booting this way, related to the sysctl
init script, so I submitted a patch which is already in OpenRC now. I’m not yet done with removing the separate packages, so there might be more issues, and of course I’m only using a very small subset of init scripts, so I wouldn’t be able to tell whether it would work on a full desktop system.
But this would for sure be a worthy experiment for somebody at some point.