Sunday 10 June 2012

Linux Power Usage

I have been obsessed by the power usage of Linux on my Lenovo T400 ever since I first installed it. The reason is that I still can't get over the fact that in Linux the same hardware consumes more power than in Windows, leading to a shorter battery life as a result. The funny thing is that now that my laptop is 3.5 years old, its battery has lost 40% of its original capacity, bringing the time on battery from impressive 6-7 hours to the usual 3-4. Yet I tend not to notice this drastic deterioration but instead continue to fight with the fact that in Linux my laptop works 15 minutes less than running Windows. It is a matter of principle now, I guess.

In any case. Up until very recently I've been running Arch Linux and have been a very happy camper about that. Yet, when Kubuntu 12.04 came out I couldn't help but write it to a USB flash and boot up to see what progress has been made. What I did notice is that a fresh Kubuntu consumes less power than my Arch setup for which I had carefully enabled every possible power-saving feature. I compared the system in the idlest possible mode: hard drive was stopped, all powertop tweaks enabled, the brightness on 50%, wireless killed. With these parameters my Arch showed consumption of 12.8-12.9 Watts, yet Kubuntu yielded 11.8. One Watt difference is indeed impressive and enough to get me started.

First thing to note is that in the example above Kubuntu is loaded from a live USB flash, a completely bare system with no extra software installed. Arch, on the other hand, has been in constant use for quite a while and has a number of additional software installed. While I took care to exit any active applications (such as Firefox, Skype, Kopete, etc.) that might influence the test, I understand that a number of services might still have been running. My primary suspect is VMWare - even though there were no virtual machines running, powertop showed that some power has been consumed by running vmware daemons. Of course, it means that such a comparison can not be a clean one, yet it makes sense to take not of these values for future reference.

My next step (out of sheer curiosity) was to compare the same idle consumption of other flavors of Ubuntu to see how desktop environments influence it. I have also tried Chakra Linux running KDE which is the closest one can get to a clean Arch install without having to spend a week setting it up from scratch. Also, Windows is included as a sort of a sad point of reference. Here are the results. As above, all measurements were taken with killed wireless, brightness at 50%, installed powertop with all tweaks enabled and suspended hard drive:
Kubuntu - 11.8
Ubuntu - 11.9
Xubuntu - 11.6
Chakra - 12.0
Windows - 10.5

The results are rather self-explanatory. It appears that Ubuntu developers have really put a lot of thought into the power saving features of their distribution. Yet it is the XFCE flavour that can utilize them best, apparently due to the much "lighter" nature of the desktop environment which does not use any hardware-accelerated effects unlike Unity and KDE's Plasma. But otherwise Ubuntu results are all within statistical deviation. Chakra does slightly lag behind Kubuntu with a difference of 0.2 Watts, but it is hardly a noteworthy difference. And of course, one can only dream to achieve a Windows result of 10.5 Watts in Linux.

I understand that such a method of testing power consumption where the system is put into its maximum idle state is hardly the best, and is distant from the real-life use patterns. Yet it is the only way I thought of that would put all of the systems in the same conditions, thus allowing for a comparison.

After seeing these results I thought I would give Kubuntu a go as a permanent installation and see how it deals with real-life tasks. I archived my Arch partition and installed Kubuntu and the same set of software that I have been running on Arch. Now, running the same test as above gives me a result of 12.5-13.0 Watts, which is exactly comparable to what I have had in Kubuntu. It thus appears that a loaded system, even with all the visible applications turned off, still consumes about 0.8 Watts more power than a clean one loaded from a live USB. To sum up:
Clean Kubuntu: 11.8
Used Kubuntu: 12.5-13 (difference of 0.7 or more)
Chakra (i.e. clean Arch): 12.0
Used Arch: 12.8-12.9 (difference of 0.8 or more).

It is thus visible that the difference between the two systems is indeed negligible with Arch consuming the same amount of power as Kubuntu when tested with loaded configurations. Subjectively though, it seems that Kubuntu is using less power under normal use, or at least "calms down" to a lower consumption after load faster than Arch had, but that might only be an impression and there is no way to measure this for sure. I am still anxious to see the power consumption of a clean Arch installation (not Chakra, which is deemed somewhat bloated by some) and I hopefully will, the next time I install Arch.

Finally, another small experiment in this series of tests yielded a rather strange result. Instead of disabling wireless, quitting all the running apps, etc. I decided to see how much power the systems consume right after startup, without any modifications whatsoever. The conditions are as follows: all applications running (Skype, Kopete, qBittorrent), wireless is connected and transmitting something (though nothing in particular is being downloaded). The only tweaks I've done was to set brightness to 50% and suspend the hard drive. The Windows setup essentially runs the same set of similar applications, so a comparison can be made. Results:

Used Kubuntu in the max idle state: 12.5-13
Used Kubuntu in the untouched state: 12.4-12.6
Used Windows in the max idle state: 10.5
Used Windows in the untouched state: 12.5

These results are indeed interesting. It is easy to see that disabling wireless and all running applications makes no difference to Linux whatsoever (while I surely did expect disabling wireless alone to save at least 0.5 Watts of power). In Windows, however, it brings the consumption down by 2 Watts. This leads me to believe that there are some techniques in use in Windows that allow the system to go to a deeper state of sleep once there is nothing to do. For some reason, Linux is incapable of doing the same. However, under normal usage for everyday tasks it seems that both Windows and Linux consume a rather similar amount of power, with Windows' benefit being its ability to go into deeper states of sleep after a high load. Linux seems to be doing it slower and never goes as far down as 10-11 Watts achievable in Windows.

It's difficult to draw any conclusions from these findings. Comparing power consumption of different Linux distributions is a difficult task when the differences are in tenths of a Watt. Comparing Windows and Linux is more difficult still. For now at least, it appears that all Linux systems consume a similar amount of power, however, there is an approximately 0.8 Watt difference between a bare system and a system that has been used for a while and thus has more daemons running. Power consumption under Windows is still the lowest possible, being approximately 1-2 Watts lower than Linux in idle states. Under normal workload however, it seems that the consumption of both systems is similar.

No comments:

Post a Comment