July 13, 2011

Android wakelocks and the Linux power management controversy

As computing devices become increasingly mobile, software engineers are having to pay increasing attention to power management. Recently, I've been following a fascinating discussion about the intricacies of the subject, involving two communities of systems software engineers:

  • The mainstream Linux community, which comes from a heritage of servers, workstations, and notebook computers,
  • and the Android Linux community, which is primarily concerned with systems running on cellphones and tablet computers.

android linux

It turns out that these two communities of developers look at the same issue (power management) from vastly different perspectives:

  • From the desktop computer perspective, a computer is generally "on" when it is working, and it may offer certain features that allow unnecessary parts of the computer to be powered down if they aren't needed.
  • From the cellphone perspective, however, a phone's natural state is "asleep", and cellphone software engineers tend to look at things in terms of powering on only those parts of the cellphone that are necessary for the work at hand

At a suitably high level, one of these philosophies is a policy of exclusion: "turn off the things that you don't need"; whereas the other policy is a policy of inclusion: "only turn on those things that you do need". From that simple distinction, a variety of different approaches to operating system design emerge.

There is an excellent explanation of the issues, and of the varying approaches, in this article at lwn.net by Rafael Wysocki of the University of Warsaw; another take on the discussions can be found in this presentation by Matthew Garrett of RedHat. Those papers, in turn, provide many further links for study, as this is a deep subject with lots to think about; Wysocki has written an 18 page paper explaining many more details.

Of course, the reason we get to learn so much about this debate is that both Linux and Android are Open Source projects, and hence the discussions and proposals and objections and refutations and counter-proposals are all carried out on public mailing lists, with lots of input from all sides of the argument, indexed, archived, and made available for everyone to study and learn from. This is one of the most fascinating aspects of Open Source: we all get to learn about the issues and benefit from them.

I'm not sure when it will start to become important for me to consider power management issues in my day-to-day software writing, but when that time comes, I'll be better able to think about the issues, having watched others struggle with them before. As Isaac Newton said in his letter to Robert Hooke: "If I have seen further it is by standing on the shoulders of giants."