[G2 Q&A, Help & Troubleshooting] bloof:
PERFORMANCE AND POWER CONSUMPTION BASICS​

And how to achieve same performance with less battery drain​

performance = how quickly things get done

power consumption = how much battery is used

Let's take a car as analogy. The performance (speed) would be represented by time to 100 kmph and time to travel 1 km, for example. Consumption would be total fuel consumed.

**************************************************************************************************************************************************

**************************************************************************************************************************************************

CPUs, GOVERNORS AND HOTPLUGS:

For cpus four things matter:

1. clock freq. We will assume that at double the frequency the task takes half the time.

2. how many cores are in use. This is from the hotplug.

3. scaling frequency. how does the governor ramp up the cpu freq and how long it takes to get to max freq.

4. thermal engine.

CPU power consumption = voltage^2 x frequency x capacitance

P = v^2 x f x c

P= power

v = voltage (can be modified by kernel, but not recommended if you don't know what you're doing)

f = frequency (can be modified by kernel)

c = capacitance (depends on actual physical build of the system)

See attached picture for a graph representation of CPU power consumption versus frequency and note the non-linear aspect. This is due to the voltage being a non-linear parameter in power consumption.

The picture is a bit misleading, at higher frequencies above 1400 MHz the voltage rises more quickly and power consumption increases more rapidly.

NOTE: undervolting can greatly help reduce power consumption, but it can be very bad for your cpus, it can fail to trigger cpu cycles and all sorts of other things, it is NOT GOOD unless you know what you are doing.

other assumption: your cores can have voltage distributed individually and at different voltages from each other.

Clock frequency:

Let's assume that double the clock freq means the task takes half the time. This might not be true of badly designed cpus, etc. But who cares.

The consumption is LINEAR with frequency, if you have double the clock speed you will use double the power. BUT THAT'S NOT TRUE FOR VOLTAGE!!!!

A cpu uses more voltage at higher frequencies, so the power consumption rises VERY QUICKLY with higher clock speeds.

So the question is: is it better to have multiple cores at lower frequencies or one core at high frequency?

Hotplug and multitasking:

If you are doing ONE task, and the application/system is good enough to use all the cores, then doubling the cores will lead to the task taking half the time.

But, if you are multitasking, some cores are doing something else and can't be used. So in practice having double the cores doesn't mean having double the available frequency.

The hotplug can be aggressive or not:

- as soon as more cores are needed it will wake all of them up and get things done. More performance, more consumption.

- it will wake up cores more slowly and keep them on for less time. Less performance, less consumption.

Scaling frequency:

Coming back to the car, if you want pure performance you floor the pedal and achieve the best results in terms of time to 100 kmph and time for traveling 1 km but you burnt all your fuel.

A governor that scales frequencies can do it in two ways:

- max power for a long time: same as flooring the pedal, jump straight to max freq and stay there until the end of the task. Some governors will stay there longer, expecting that you will do a task requiring max freq pretty soon after you've done it.

- scale freq over several steps with plateaus for a certain time. This is like setting speed limits on the race track: the car will accelerate more slowly, take longer to get to the destination but burn a LOT less fuel.

Thermal engine:

cpus get hotter at higher freq, to the point where you can PERMANENTLY DESTROY or DAMAGE them.

Hence, the kernel will have a thermal engine to regulate clock frequency depending on cpu temperature.

What this means is that for heavy tasks that take a long time, the maximum practical cpu frequency will be MUCH LOWER than the theoretical max frequency. For example, if you have max freq at 2547, your thermal engine might simply set the freq at 1190 during the task! That's a GOOD THING!

**************************************************************************************************************************************************

**************************************************************************************************************************************************

THE BIG QUESTIONS:

Should I use more cores at lower freq or not?

What is the difference between one core at high freq vs one core at lower frequency?

In a simple system, one task to do, let's have a look. I am using voltage/freq from OnePlus One phone, but I expect things are similar for everyone.

If the task is long and heavy, all the cores will work at reduced freq due to thermal engine, so it doesn't matter what you do. These results are only for quick tasks.

PS: don't ask about the units, this is relative comparison for ratios, so units don't matter.

The real drop in performance is not as much as the simple frequency reduction, it depends a lot on the cpu hardware. Some numbers I found (for different cpus):

- 31% frequency reduction = 26% performance reduction; 66% reduction in power consumption

- 20% frequency reduction = 13% performance reduction; 49% reduction in power consumption

But the numbers shown below are approximately correct.

Example 1: same task, 1 core vs 2 cores

1 core at 2547 Hz. Performance = 2572. Consumption = 3.084

2 cores at 1267 Hz. Performance = 1267x2 = 2534. Consumption = 0.88

=> Same time to complete task, the 2 cores at lower frequency consume one third of the power!

Example 2: same task, only 1 core.

1 core at 2547 Hz. Performance = 2572. Consumption = 3.084

1 core at 1958 Hz. Performance = 1958. Consumption = 1.75

For the same task, the core at 1958 needs to be ON for 2572/1958 = 1.3 times longer than core at 2547. So it will consume 1.75x1.3 = 2.3

=> the single core at 1958 will take 25-30% longer time but consume 25-30% less battery.

In practice the time taken will be shorter and the battery saving larger than these numbers.

Example 3: same task, only 1 core, different gov

Max freq = 2572

Start freq = 268

Freq scaling steps: 1 ms

1 core straight to 2572: Exxon governor

1 core at 1190 then 1574 then 2265 then 2572: greenpeace governor

=> answers: I have no idea, not calculating this.

- for very quick small tasks, the greenpeace gov might never reach the highest freq, and will consume insanely less power than the Exxon gov.

- for long heavy tasks, they will consume about the same and take about the same time since they will be throttled by the thermal engine.

- for medium tasks, the greenpeace gov will take longer to complete, maybe 20-30%, but consume about 40-50% less battery. This really depends on the governor, most good governors are pretty balanced and will fall somewhere in-between.

Example 4: hotplugs

I won't even get into this, but if you throw-in hotplugs in there the difference between an (aggressive hotplug + Exxon governor) and a (less aggressive hotplug + greenpeace governor) increases significantly to the point where you will actually notice applications taking longer to load, screens not rotating quickly at all, general annoyance at your phone behaving like a nokia vintage 1998.

You also understand why no-one in their right mind will calculate governors and hotplugs configurations for you and tell you which is best.

**************************************************************************************************************************************************

**************************************************************************************************************************************************

MY BIG QUESTION: ACHIEVING THE SAME PERFORMANCE WITH LESS BATTERY DRAIN

For the same expected performance, is it better to have a battery-saving governor + aggressive hotplug or an aggressive governor + battery-saving hotplug?

That's the big question.

We've already established that you should underclock your frequencies, if you didn't get that from everything I said then it's your life anyway, doesn't affect me.

From example 1, we can clearly see that theoretically more cores at lower frequency makes sense, especially since thermal engines will reduce clock speeds for super heavy tasks.

However, when multitasking comes into play as well as ****ty apps/systems not making full use of the fact that there are several cores to choose from, then the answer is not so clear cut.

I have found that for power consumption the hotplug seems to matter much more than the governor, but it could depend heavily on what you use your phone for.

Play around with your kernel, and test with user experience, not benchmarks. For example:

1. a very battery friendly governor with a very battery friendly hotplug, leaving theoretical max freq at 2572 or whatever.

dorimanx: alucard HP + max freq 2.3 + alucard govs

boeffla: zzmove native default HP + max freq 2.5 + zzmove battery extreme yank

2. very aggressive governors & HP:

dorimanx: MSM HP + max freq 2.8 + intelliactive/darkness

boeffla: zzmove native 2 cores min + max freq 2.8 + zzmove insane/intelliactive/ondemand

3. try this: aggressive HP + UC + semi-aggressive governor

dorimanx: MSM HP + max freq 1.7 (for all cores) + darkness/ondemand/impuls

boeffla: zzmove native 2 cores min (or Default HP) + max freq 1.7 + zzmove - performance

Try this even at 1.3 MHz, you might be surprised.

You will start noticing that you can't make the difference between crazy performance settings and more balanced ones, and

if you can't tell the difference then for goodness' sake stick to the battery friendly option

.

**************************************************************************************************************************************************

**************************************************************************************************************************************************

GPU:

The GPU is a major function of power use and performance, the more screen changes happening (scrolling, gaming, etc), the more it is used.

Controlling the GPU max freq can significantly help reduce battery consumption but will lead to issues with gaming especially (loss of Frames per Second, unresponsive game).

I would recommended underclocking the GPU unless you really need it. If that leads to issues for your daily phone use then scale back min/max frequency to default levels or even overclocking.

More importantly, if you kernel allows (Dorimanx, Boeffla do), then reduce min GPU frequency to 27 MHz. That is a large battery saving feature with no performance impact.

See attached picture for the relationship of power usage of GPU versus frequency. GPU freq index 0 to 3 is low to high frequency.

**************************************************************************************************************************************************

**************************************************************************************************************************************************

UNDERVOLTING:

Just a quick add to show tables of voltage versus frequencies and if you square the voltage times the frequency you will realize how quickly power consumption grows with frequency.

Example voltage versus frequency for Z2 (from here (credits [MENTION=3056043]Haldi4803[/MENTION]).

300mhz = 775mV

422mhz = 775mV

652mhz = 775mV

729mhz = 775mV

883mhz = 780mV

960mhz = 790mV

1036mhz = 810mV

1190mhz = 820mV

1267mhz = 850mV

1497mhz = 860mV

1574mhz = 880mV

1728mhz = 915mV

1958mhz = 975mV

2265mhz =1010mV

2457mhz =1010mV

Voltage OnePlusOne (credits [MENTION=947981]Lord Boeffla[/MENTION], at least that's where I take it from):

300mhz = 770mV

422mhz = 775mV

652mhz = 775mV

729mhz = 775mV

883mhz = 785mV

960mhz = 795mV

1036mhz = 805mV

1190mhz = 825mV

1267mhz = 835mV

1497mhz = 865mV

1574mhz = 875mV

1728mhz = 900mV

1958mhz = 945mV

2265mhz =1005mV

2457mhz =1040mV

2572mhz = 1095mV

2726mhz = 1125mV

2880mhz = 1155mV

**************************************************************************************************************************************************

**************************************************************************************************************************************************

Further Reading:

Qualcomm article on power consumption

Another Qualcomm article on battery & power

Integrated CPU-GPU Power Management for 3D Mobile Games

Wikipedia: Underclocking

An Analysis of Power Consumption in a Smartphone

Utilization-based Power Modeling of Modern Mobile Application Processor