Make your Android power efficient in any situation (for free!)

In the following post I will explain how to use cpu tuner, a completely free and open source app for android. All you need is root and some time. It's a follow up on and summary of my various related posts you can mostly see below ("related posts") on working with governors to increase power efficiency in Linux. This is of course something that a) Linux and b) Android and c) your phone manufacturer should already have done. But as they didn't...


0. Notice
CPU Tuner (CT) also includes setting "Min" and "Max" Frequencies. This is meant for devices with special firmware, which allows for overclocking and is not part of this post. All of these steps (tune governors, disable inactive interfaces) apply to any Linux device.
The following goes out especially to our dear US users (but also to every country with punitive damages):
CAREFUL, this tool may cause your phone to explode and other annoying things. You should especially never put your phone into a washing machine, or dryer or microwave or into a fire or do other completely and utterly stupid things with it! Use of this tool does not protect against lack of brain or thought!

1. What is...?
Now let me begin by explaining all the terms used in the program.

1.1. up_threshold: The CPU usage % at which the CPU frequency is scaled up. In the case of conservative this is X % higher than the current frequency. X is determined by the freq_step setting and defaults to 5 % in Linux and 20 % in my android and is not supported by CT atm. In the case of ondemand, (AFAIK!) it skips directly to the maximum frequency. That's why there's no freq_step in the case of ondemand.
1.2. down_threshold: As you may have thought already now, this is the CPU usage percentage where the frequency is reduced. This does not exist for the ondemand governor.
1.3. Triggers: Here you can tell CT that you want to use certian profiles in certain conditions. The most simple condition is battery usage. If battery usage is set to 100, then CT will set a certain profile whenever the battery is below 100%. Another important profile is Screen Off. This allows you to activate a certain profile once your screen is off.
1.4. Profiles: A profile is a combination of settings, e.g. Disable Wifi, Use Conservative Governor, etc. (see 2.1).
1.5. governor: This picks your CPU frequency according to an algorithm (a set of rules). There are different algorithms available:

1.5.1. performance: This stays at the maximum frequency all the time. Not power efficient at all. But great for testing if the problems you are experiencing are really caused by frequency scaling.
1.5.2. powersave: stays at the minimum frequency no matter what. I think this never makes sense. It will take a lot of time to get back out of this as any phone becomes very unresponsive once you set to this, so be careful and just avoid it! Oh, and then some devices just hang without return when you set this. It might possibly make sense when the screen is off. But most probably it'll just cause problems and annoy you. ;-)
1.5.3. userspace: This is if you want to set the frequency manually. Unless you have your brain directly connected with wires to the phone or your are trying something out you should avoid this one as well.
1.5.4. conservative and ondemand: You are probably just skipping through this, huh? ;-) See 1.1. above for the description of conservative and ondemand.


2. How to increase your energy efficiency
Note that I write increase the energy efficiency and not decrease the power usage. You could decrease the power usage easily: Just set up_threashold to 99 and down_threshold to 98. But that would most likely cause your phone to act very weird. And this is not what we're aiming for. We want a phone that works perfectly and just uses less energy. Of course this kind of general tuning is something your phone vendor should have done already. But trust me, I haven't seen a single phone where they actually did. And android mostly comes with Linux defaults, which are tweaked for 100 % performance and don't care much about high energy efficiency.

2.1. Quick&Easy: Interface Tuning
The easiest and first thing you can do is to set the general device settings. Easy power savers are to adjust active interfaces when the display is off:

2.1.1. Mobiledata: 2G only. This could cause problems if you use VoIP software via 3G with the display off. This saves power twice: Firstly 2G takes less power than 3G in standby. Secondly, switching between 2G and 3G can take a lot of power. (The device will constantly try to find and "upgrade" to 3G networks.) Side-effects: It mostly means that incoming phone calls will be more likely to be in slightly lower quality, as 2G uses more lossy audio compression codecs. This could decrease your battery time if you're constantly downloading big files via 3G while the display is off. (Honestly, how would that work?).  (recommendation: 2G only).
2.1.2. Background Sync: disable. This can have various consequences, e.g. Gmail claims to rely on this. But I still get new email and Gtalk noticiations with this off somehow. It's a general setting that other programs might rely on as well. So just see if this works for you. (recommendation: disable)
2.1.3. Wifi: Disable. I don't use this. Because if you use Voip software with your phone it usually detects if your ear is close to the headset and then turns off the display, which makes sense to save energy. Also sooner or later your display may turn off during a call anyway. Then a Voip connection or even streaming radio and other services via Wifi would be disconnected. That's why I prefer to use this setting with other programs. It would be cool if Wifi was disabled automatically after x minutes without usage or when out of range. But that's really something for other tools than CPU tuner. (At least then, the tool should be renamed to something like power tuner). (recommendation: leave unchanged)
2.1.4. Bluetooth: Disable. Side effects: If you use bluetooth headsets etc. they will be disconnected. Hence it only makes sense if you don't really use bluetooth. But then you will probably never have it switched on anyway, so there would be little point in switching it from off to off automatically... Useful if you sometimes use it or play with it and then forget to turn it off again. (recommendation: leave unchanged)
2.1.5. GPS: Disable. This usually saves quite a lot of power. Side effects: When switching back on, it will often take some time to find your location again. (Samsung Galaxy 3, you're annoying me here even with gpsopt...). Also, if you use a navigation software and switch off when the display turns off, this means you will at least lose your precise GPS location and your navigation software will either stop working entirely or start giving very imprecise (and thus often useless) advice: "Go sort of left, but also a bit right, one of the next or previous streets...". Sounds like me giving directions. This only works when the app is installed as a system app (no method does not work universally, also try root explorer and copy the apk to /system/apps).

2.2. Governor Tuning -- Step by Step
This is the most tricky part, but it's worth it: These settings can save you power even if your phone is not in use. If can also increase your phones responsiveness and interactivity while you use it. And it can do both. And it could even decrease power use in both situations. Always start with your vendors default settings. (Assumption: The current/default settings don't cause any mp3 playback gaps, etc. for you; otherwise: Start with 70 up, 40 down; otherwise: start with 40 up; 20 down.)

2.2.1. Make one change at a time: e.g. increase the up threshold by 10 or 20 %. Then listen to music for about 10 minutes with that setting. Check if you run into any problems (see "Signs of Trouble" below). If you notice problems, go back to the setting before, then add a smaller percentage, e.g. 5 %.

2.2.2. Rinse and repeat until you get a fluffy paste. (Once one change works, try another, e.g. first try increasing the up threshold, then try increasing the down threshold.)

2.2.3. Signs of Trouble
The most notable and annoying problem for me is that music playback stutters. (Attention, if you like , noise is probably part of the audio track and not an issue.) This also means that you the other person will hear glitches in skype and other voip softwares. The second, less annoying, likely effect is that the user interfaces will become less responsive, animations will stutter and won't look as pretty etc. These are all things you should watch out for during the governor tuning explained below.


2.3. Putting it all together
Once you find your preferred settings, I recommend creating two profiles for the start: one for screen off and one of screen on. While screen off is a trigger, to use a profile whenever the screen is on just select battery below 100 %. I'd prefer the ondemand scheduler when the screen is on as it's the most responsive in my experience. But as it stands I use only the conservative governor.

3. Causes
In my experience so far, the down threshold is much more likely to cause problems than the up threshold. It seems Linux makes its calculations of when to send new data to the sound card based on the current frequency and doesn't adjust them (soon enough) when the frequency is reduced. (Note to self: File a bug about this to the overflowing android bugzilla, which mostly seems disregarded by developers.) This causes problems especially for the ondemand governor, which is much more prone to create noise during playback in my experience than the conservative one, as it switches back down to the lowest frequency almost immediately.

3.1. Don't rely on Skype as a measure, as skype can often cause problems even if you use the governor to "performance", which effectively disables frequency scaling. I hope they will improve skype, which reportedly works quite well on iPhone, but not on MyPhone. Generally you should check if problems disappear with the performance governor. Because if they don't they're not related to the CPU frequency scaling at all. Hence they are highly unlikely to be related to CPU tuner. In my experience CSipSimple works pretty well, try calling an echo service or answering machine to check how flaky the connection is -- of course you need a stable network (wifi with all stripes!) connection to ensure that it doesn't cause the glitches. You would also notice that they don't disappear with the performance governor then, of course.

4. If all fails
If everything starts to be buggy all out of a sudden, just disable CT and check if it disappears. If you've got no idea what you changed, reset CPU tuner to defaults and repeat more carefully.

5. Feedback
If you've managed to find the perfect settings for your device, please report them in the comments here. Make sure to include your phone device and which firmware you use (as exact as possible please). This may save other people from listening to hours of music to find the perfect settings for their phone. I officially invite to flamewars about what exactly the perfect and absolutely ideal settings for all and any situations, people and devices are. ;-) Once we've found them we can adjust CT to come with them preinstalled and then get them into android as default.

My settings right now are:
Screen on:
conservative, up 50, down 30;
2g/3g
Screen off:
conservative, up 90, down 50.
2g only.

The End.

If you liked this article, you might want to link to it and subscribe to the RSS feed so you won't miss the next one. In any case, check the related articles below. Maybe I'm just having a really bad day and normally I write much more interesting articles about theses subjects. Of maybe you'll only understand what I mean once you read all my other posts on the topic. ;-)

13 comments:

  1. I don't see any option to set up/down thresholds in CPU Tuner. I just see options for setting Min and Max frequencies.

    ReplyDelete
  2. Thank you for taking the time to write this page (I'm a noob).
    Very helpful.

    ReplyDelete
  3. This is really useful info. Thank you.
    I used to have three profiles, On Charge, Batt Saver (under 50%) and super batt saver (under 15%), but then i just found my phone unusable. Im going to try out your set up and see how that goes. Thanks again

    ReplyDelete
  4. I have also set the max CPU frequency at 480 mhz in screen off mode.. So i am sure it stays low....
    HTC Aria - Liberated Aria

    Any suggestions to save more battery in screen off mode???
    Thanks!

    ReplyDelete
  5. I might also note that in terms of switching bluetooth off; bluetooth can be and often is very insecure and so keeping the bluetooth off is standard habit for me.

    ReplyDelete
  6. ... after working with CPU Tuner for some time, it broke. Simply spoken. Even unsinstalling, deleting temporary data, fresh install, reboots etc. won't help. It always freezes once I try to load a profile. Any chance I can get that fixed? Regards,... Marco

    ReplyDelete
  7. Thanks, Hyydrox24,
    Have you contacted the author about this, mordortia? I can imagine that the app saves data on the sdcard as well? Or you use a different version now?

    ReplyDelete
  8. Nicola, as I think i wrote, disabling 3G mode, wifi, etc on display off can save lots, probably more power than tuning down the CPU mhz.

    ReplyDelete
  9. I cant set 2g/3g mode in whatever trigger/profile is. Do I nêed a mod rom ?

    ReplyDelete
  10. Thanks for this guide, helped point out a few things I wasn't sure about.

    At the moment I've got a strong power saver when the screen is off, that drops my Nexus 4 down to 300mhz and turns off 3 cores. Streaming music from youtube with screen off and locked doesn't seem to cause any playback issues. So either the app doesn't need that much power or CPU Tuner isn't doing what it claims.

    Is there a way to see a history of cpu speed and usage? Also perhaps how much my battery is consuming during the day in mAh? That would be great.

    Thanks again for the guide

    ReplyDelete
  11. CPU Tuner is pretty reliable about doing what it claims I think. You can manually look in /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table or a similar file to see statistics about which frequencies were used...

    I'm not aware of a total mAh statistic. You might find that in another app. I'm not the developer of Cpu Tuner! ;)

    ReplyDelete
  12. Um I have the Galaxy S4 SGH-I337M canadian version by Bell, and I don't have the conservative setting.

    ReplyDelete

I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.