Hey Android: you fixed the lag issue, did Marshmallow fix your battery?
Ask anyone what they would improve about their smartphone and you’ll probably come up with two answers very near the top: faster performance, and better battery life. Some argue that their phone or tablet is “faster” than another because of the operating system it runs. Other’s swear that the batteries in devices from one manufacturer outlast those of its competition. A lot of this comes down to comparing apples to oranges. For example, you can’t easily compare a quad-core CPU clocked at 2.0 GHz with a hex-core CPU clocked at 1.8 GHz – there are simply too many differences between the processors’ innards to make absolute comparisons. How then can we compare battery capacities between devices that are so drastically different from each other?
To address both of these concerns (faster performance and better battery life), Google has been working on a few projects.
Project Butter is an initiative Google undertook to help the Android operating system respond quicker and behave smoother. “Smooth as butter” is the cliché Google was chasing here. Some of the loudest critics of Android chant the mantra that Android “lags” or has otherwise poor performance as evidenced by “choppy responsiveness”. The truth of the matter was that Android (like most other mobile operating systems today) utilizes a concept called “preemptive multitasking”.
Multitasking is pretty much what it sounds like – the ability for the operating system to run multiple tasks simultaneously. Application code is split into “threads”. These threads, when woven together, knit the fabric of the application itself. Each thread can run (somewhat) independently of the others. Thanks to multi-core processors, these threads (strings of instructions written in code) can be spread across the available cores . This results in multiple threads being executed concurrently. What’s more, multiple applications can run alongside each other. As one thread is processed and completed, the core moves on to the next thread in queue, handling each as it was requested (more or less).
Some threads have higher priority than others. Others are larger and take more time to process. The take-home here is that every app (including pieces of the operating system itself) can run alongside each other. That’s multitasking: walking and chewing gum at the same time.
Preemptive multitasking means that the operating system can “preempt” a task. Using some collection of rules and/or logic, the OS can decide the time to allocate to any task before giving another task a turn to use the operating system – cutting the first one off. The “lag” that people complained of was simply a differing opinion of when tasks should be preempted from that which the OS decided upon.
Project Butter was Google’s attempt to redefine the preemption logic and rules to make the operating seem to run more smoothly – or, put another way, to put end-user’s expectations in-line with the manner in which Android handled preemption. Of course there’s a lot more to consider with Project Butter (VSync, increased frame rates, better touch-responsiveness, and predictive interactions, for example), but for the purposes of this article, that will suffice.
Project Butter was initially introduced in Android 4.1 Jelly Bean, but it wasn’t until subsequent improvements were made in Android 4.2 and later versions that the true benefits of Project Butter were felt. On modern Android deices, lag is pretty much a thing of the past.
Next on deck was Project Volta, introduced in Android L (later called Android Lollipop), with the aim of extending battery life by understanding and improving upon how apps were operating and consuming resources.
Regardless of how much power each task required, in the aggregate, the resulting power consumption when tasks were run individually was alarming. Project Volta schedules and groups tasks across the operating system more efficiently than running each task individually. It brought new APIs for developers to leverage the same approach in their apps and thereby reduce the overall number of activities needed for their apps to work.
One of the major advances was the inclusion of a new network activity awareness API. This API allowed apps to know if the cellular radio was active (for example), and “piggyback” its data requests on that connection instead of waking up the phone and the radio later on. The theory here was that two tasks running on the same wake-request consumed less power than two separate wake- and data-requests.
Like Project Butter, the benefits of Project Volta weren’t immediately realized – it took time for app developers to use the new APIs. Nonetheless, some benefits were reaped right away, with some sites reporting up to an extra 90 minutes per charge thanks to this project from Google.
Now that Android Marshmallow is hitting a (very) limited number of devices, some of Project Volta’s more lofty goals are finally being seen in action, thanks, in part, to the new Doze Mode that was introduced with Android M (the developer preview of Android Marshmallow).
Doze Mode builds on the concepts of Project Volta in a few specific ways. First off, if your screen is off, it’s not charging, and the device isn’t moving, Android Marshmallow assumes that you’re not using. That’s a pretty safe bet. To that end, Android decides to focus on preserving battery rather then checking for new information.
Doze Mode delays some things, like Sync Adapters, Job Schedulers, and even the Alarm Manager. Notice that these aren’t disabled, just delayed. The jobs that would have run during that time are paused and queued up to run after your phone or tablet exists Doze Mode, like when you pick up your device.
If you haven’t picked up your device in quite a while, those batched jobs are executed periodically, so there’s not a huge rush of syncing when you pick up your phone – which would slow it down until those jobs complete.
Just in case something critical or time-sensitive comes through (an instant message or chat notification, for example), that task can be triggered during Doze Mode to make sure that you get timely information when you need it. The idea here is that if the notification is important enough for the user to get up and walk across the room to check it, it should interrupt Doze Mode – if not, then the request is delayed and queued for later.
Doze Mode, in addition to the time Project Volta has had to mature, means that devices that previously ran Android Lollipop should get noticeably better battery life after upgrading to Android Marshmallow.
Now it’s your turn! Are you running Android Marshmallow? Have you experienced noticeably better battery life? Go ahead and answer our poll, then head down to the comments and share your experiences!