Major Android updates always come with a host of new features and functionality, but there are countless other changes taking place behind the scenes that set the stage for more significant improvements down the road. Among the additions in Android 11, most of us will probably never care about rebooting userspace, but it may be a first step for several other bigger enhancements to come.

Most people will have heard the term 'soft reboot,' but that still probably doesn't mean much to anybody outside of some power users and software engineers. The simplest way to describe rebooting userspace is to say it's a partial shutdown and restart of the higher level software that makes up most of what we actually interact with, but the low level software goes untouched.

Image: Platform architecture

To get a bit more technical, userspace is basically everything that lives above the kernel in the diagram above. This includes the apps, services, and system UI that we interact with directly, all of the frameworks, runtimes, and native libraries that are loaded at startup time, and some of the hardware drivers that aren't part of the kernel. After all of these things have been shut down, the system starts up again as it would during a normal boot.

So, why would anybody want to do this? The most common reason for end users is speed. A reboot of userspace is usually several seconds faster, which makes it valuable in server environments where uptime is critical. Most desktop/server operating systems support soft reboots, but only through a command line or system API, or it may be done automatically if a full reboot isn't needed.

It's already possible to reboot userspace in Android 11 with this command: adb reboot userspace. In a quick test of a fresh Android 11 install on a Pixel 2 XL, the speeds weren't too remarkable. Results varied across several tests, but soft reboots only averaged about 15% faster than a full reboot — that means you're only shaving off 2-4 seconds.

https://gfycat.com/unlawfulquestionablekoi

Those times aren't going to make much of a practical difference in day-to-day use, but it never hurts to have slightly faster reboot times after installing security patches and other small updates. Of course, we can't even be certain that Google will begin initiating soft reboots even if they would be viable.

This begs the question, what other reasons are there for rebooting userspace? No specific explanations are given, but there are possible reference points in the wild, so a little guesswork raises some possibilities. For example, it could be part of a faster or more streamlined update process like that of the KUP update mechanism for Instant OS that is able to perform updates without wiping memory. Given that fastboot moved to userspace just last year (with Android 10), this seems even more plausible.

Soft reboots can also be used in some dual-boot scenarios, fast user switching, and automated testing. In some implementations, the kernel can also be instructed to leave memory intact, which allows for loading tools for diagnostics and analysis. And yes, it may turn out to be useful to your favorite ROM devs, as well.

Android 11 may already support some additional capabilities through the use of rebooting userspace, but nothing specific has been announced yet. The specific code was added back in October, and quite a few things have been moved or changed in relation to kernelspace and userspace since then. There may already be more to discover, or this could just be laying the groundwork for future versions of Android.

Via: Mishaal Rahman

Source: Android Open Source Project