Tuesday, 13 December 2011

Improving Battery Life in Ubuntu Precise 12.04 LTS

Part of my focus this cycle is to see where we can make power saving improvements for Ubuntu Precise 12.04 LTS. There has been a lot of anecdotal evidence of specific machines or power saving features behaving poorly over the past few cycles.   So, armed with a 6.5 digit precision multimeter from Fluke I've been measuring the power consumption on various laptops in different test scenarios to try and answer some outstanding questions:

* Is it safe to enable Matthew Garrett's PCIe ASPM fix?
* Are the power savings suggested by PowerTop useful and can we reliably enabled any of these in pm-utils?
* How accurate are the ACPI battery readings to estimate power consumption?
* Do the existing pm-utils power.d scripts still make sense?
* Which is better for power saving: i386, i386-pae or amd64?
* How much power does the laptop backlight really use?
* Does halving the mouse input rate really save that much more power?
* Should we re-enable Aggressive Link Power Management (ALPM)?
* Are there any misbehaving applications that are consuming too much power?
* What are the root causes of HDD wake-ups
* Which applications and daemons are creating unnecessary wake events?
* How much does the MSR_IA32_ENERGY_PERF_BIAS save us?

..and many more besides!

From some of the analysis and "crowd sourcing" tests it is clear that the PCIe ASPM fix works well, so we've already incorporated that into Precise.

Aggressive Link Power Management (ALPM) is a mechanism where a SATA AHCI controller can put the SATA link that connects to the disk into a very low power mode during periods of zero I/O activity and into an active power state when work needs to be done. Tests show that this can save around 0.5-1.5 Watts of power on a typical system. However, it has been known in the past to not work on some devices, so I've put a call for testing of ALPM out to the community so we can get a better understanding of the power savings vs reliability.

Some of the PowerTop analysis has shown we can save another 1-2 Watts of power by putting USB and PCI controllers of devices like Webcams, SD card controllers, Wireless, Ethernet and Bluetooth  into a lower power state.  Again, we would like to understand the range of power savings across a large set of hardware and to see how reliable this is, so another crowd sourced call for testing has been also set up.

So, if you want to contribute to the testing, please visit the above links and spend just a few tens of minutes to see we can extend the battery life of your laptop or netbook.  And periodically visit https://wiki.ubuntu.com/Kernel/PowerManagement to see if there any new tests you can participate in.

[UPDATE]

I've written some brief notes on power saving tweaks and also some simple recommendations for application developers to follow too.

The thread continues here (part 2)

28 comments:

  1. Thank you for your work on this! Improving battery life issues on Ubuntu will make it that much more appealing of an OS for both existing and new users.

    ReplyDelete
  2. Good Job!

    Saving energy is good for Mother Earth & for our wallet!

    ReplyDelete
  3. You might also want to have a look at
    https://github.com/linrunner/TLP/wiki/TLP-Linux-Advanced-Power-Management
    which is made for Thinkpads but runs well on other systems too. If there would be a gui integration for it in Ubuntu (and Kubuntu too) that would be great.

    ReplyDelete
  4. Thank you so much for the effort. The long awaited LTS release finally addressing an issue I'm actually passionate about.

    ReplyDelete
  5. HDD wakeups causing massive load cycle count increase (or ridiculously high temperatures of HDD if APM is lowered) is what keeps me from using Ubuntu or linux in general. I'm stuck with Windows 7 where it JUST WORKS. I hope you'll sort this bug out.

    ReplyDelete
  6. My battery life is 2-3 minutes because as soon as I unplug, Ubuntu thinks my battery is dead and goes to hibernate - even if I plug it back in time. It's be great if I can use my laptop again as a laptop.

    (https://bugs.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/838543)

    ReplyDelete
  7. Install Jupiter in Precise, problem solved.

    ReplyDelete
  8. Hopefully this release will not have Unity. If it does I'll go to another desktop.

    ReplyDelete
  9. @Anonymous 20:24

    If you don't like Unity... Use Gnome Shell, it's fantastic. I love it. Here's a screenshot.
    http://twitter.com/#!/RoatanCyberCafe/status/147220467445530624/photo/1

    install instructions here...
    http://www.howtoforge.com/install-gnome-3-with-mint-gnome-shell-extensions-or-mate-on-ubuntu-11.10-oneiric-ocelot

    ReplyDelete
  10. I had actually run across many posts about the power consumption of Ubuntu as it is, but on my laptop I don't think I experience it. Whereas my system has a "estimated life" of 3.5 hours, I can usually get 4 hours. Would these new changes affect me as well, or only certain systems that happen to have problems? I would NOT complain about more battery life!

    ReplyDelete
  11. Message has arrived!

    ReplyDelete
  12. Hi,

    Windows 7 having a longer battery life for most of the notebooks means a big deal for Ubuntu. Reverting this fact so that Ubuntu has superior battery life would be a huge thing.

    Cheers,
    Matyas

    ReplyDelete
  13. Power Management cannot be divorced from Suspend and Hibernate behavior. For each feature you turn on you must ensure that it has no impact on Suspend/Hibernate, otherwise it is useless.

    ReplyDelete
  14. What about more serious power consumption issue on Intel Sandy Bridge laptops?

    https://bugs.launchpad.net/ubuntu/+source/linux/+bug/818830

    ReplyDelete
    Replies
    1. It seemed like we had a fix for this for Precise however there are classes of Sandybridge hardware where the fix caused a hard lockup and the fix had to be reverted, see:

      http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ebbd857e6b9a92c0aff4aacd1b1d2361d888633e

      Meanwhile, users can use the workaround i915.i915_enable_rc6=1 for hardware where this works reliably.

      Delete
    2. Thanks Colin for your answer. i915.i915_enable_rc6=1 seems to work for mine, but is what you mean that the fix won't work for some models of Sandy Bridge?

      Delete
  15. thans, this very informatif post...


    (http://sandybridgelaptops.blogspot.com/)

    ReplyDelete
  16. I can't wait for the latest release for Ubuntu. Just tried it out a few days ago, and it is very impressive. Will use this on computers that have trouble booting Windows, etc., as well as for personal use.

    Also, have you ever heard of Disqus, the comment system? I suggest you really check it out. It is really great, and use it on my blog.
    www.disqus.com.

    ReplyDelete
  17. if they can fix the infamous ASPM overheat problem for notebooks, i will give Ubuntu another chance. I just cant take that bug on my machine, the Hard disk was dying so fast (parking a lot) that was a no no for me...

    ReplyDelete
  18. I've noticed a dramatic increase in battery life on my Thinkpad (t510, i5, Ubuntu 12.04 amd64) after installing Jupiter, uninstalling Flash (and just using Chrome when needed, which as I understand is going to be an inevitability for Linux users anyway), and installing an SSD; which has given me around 8-9 hours of idle time, and around 5-6 of continuous light use. I will try running some heavier weight applications (I do pro audio so that would consist of Ardour, Zynaddsubfx, Guitarix, Patchage, and other such apps) and see how well the battery performs using them.

    ReplyDelete
    Replies
    1. So, after installing jupiter and benchmarking that against a standard install on a Lenovo X220i laptop I found very minimal difference in power consumption. I've got some raw data and graphs from various different tests here: http://kernel.ubuntu.com/~cking/power-benchmarking/jupiter/power-management-jupiter-tests.ods

      Delete
  19. I have mixed results, on my ASUS 1015B AMD C60 netbook, I find around 10%-15% gains with Jupiter and Juipiter-Support-EEEPC installed but OTOH with my ASUS K53 icore5 laptop,the difference if any are negligible, the netbook runs 12.04LTS Xubuntu while the laptop runs latest 12.10 Quantal. Maybe that could be one factor but overall I get the impression that Jupiter works in some cases while on others the gains are negligible as is apparent from Colin's highly technical test.

    ReplyDelete
    Replies
    1. The main problem I face is that I read a lot of anecdotal evidence but I find a lot of results are based on data from tools like powertop which is based on the accuracy of the battery rather than on direct measurements. Also, there is a lot of variation on the hardware and use cases, so it is really hard to figure out what is the best overall optimal choices for the majority users without causing regressions. For example, we could turn on Aggressive Link Power Management by default which can save upto 1W on some hardware, but it has been known to cause regressions (data loss) on some hardware. So the default configuration can most likely be optimized for specific machines and use cases.

      Delete
  20. I also feel ultimately the BIOS and design of laptops have a lot or role in this. Laptops with discrete cards invariably consume more power even though programs like Bumblebee are trying to amend this. Also some laptops like the ASUS K53E on average consume less than their similar hardware counterparts.

    ReplyDelete
  21. Hi Colin, have you had a chance to test this, seems to be more transparent than Jupiter and uses the pm-utils as its backend. http://linrunner.de/en/tlp/tlp.html

    ReplyDelete
    Replies
    1. Thanks for the link Arup - very useful. I will try to find some time to analyse this at some point in the future.

      Delete
    2. Welcome Colin, anything to improve Ubuntu and bring it on par with the battery consumption of Windows. I will install this on my ASUS icore5 Sandy Bridge laptop and get back to you.

      Delete
  22. hi colin what is the best Gui For save power ? and jupiter no result on powersave mode ? or litle but not much ?

    ReplyDelete