Analyze and optimize Android apps power consumption
-
Upload
droidcontlv -
Category
Technology
-
view
107 -
download
0
description
Transcript of Analyze and optimize Android apps power consumption
Intel® Energy Profiler power analysis for Android* Alexander Weggerle
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
CPU C-States / P-States
Intel Confidential 2
C1
C2
C3
C4
C5
C6
Pn
P1
P0 CPU
Active
CPU
Sleep
P0 - CPU active at highest frequency (HFM)
Pn - CPU active at lowest frequency (LFM)
C0 - CPU active (In any P-state)
C0
C1 - Core clock is Off
C3/C4 - Reduced Voltage, Partial L2 cache flush
C6 - Core Off, L2 cache flush, state saved to SRAM
The deeper the sleep state
more power saving
but longer to wake up
Po
we
r H
igh
er
La
ten
cy
Gre
ate
r
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
CPU Sleep States
• Flexible C-States to Select Idle Power Level vs. Responsiveness
Core voltage*
Core clock
PLL
L1 caches
L2 cache
Wakeup time*
Idle power*
C0 C1 C3 C4
off
Active state
off
flushed
off
off
flushed
off
partial flush
active
* Rough approximation
C6
off
off
off
off
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Processor Power and Processor Frequency
9
59
109
159
209
259
309
359
0 0,5 1 1,5 2 2,5 3 3,5
Po
we
r (w
)
Frequency (GHz)
Power vs. Frequency Curve for Single Architecture
Copyright © 2004 Intel Corporation. All rights reserved. 5
Small Increases in Processor Speed
Results in Large Increases in Power
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Components of power analysis Idle vs. Active
Do nothing efficiently
Hurry up and get idle.
e.g. Multi-threading (distributing work evenly across cores)
Optimize Sleep Behavior
Minimize sporadic wakeups.
Schedule all periodic activities from the app into same wakeup period.
What is waking h/w from low power states? Why?
Optimize Utilization
What is active? Why is it active?
Minimize Polling Loops. Use event driven framework when possible.
Turn devices off. Open devices can prevent the system from entering power saving state.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Why Minimize Wakeups?
Frequency of software activity makes big difference
Long uninterrupted
Idle period, is the key
7
4
5
6
7
8
9
10
11
12
0% 2% 4% 6% 8% 10%
Pla
tfo
rm P
ow
er
CPU Utilization
Solid Activity
Fragmented Activity
Co
nso
lid
ate
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Types of Analysis
Two flavors of SoCWatch use cases:
Expert analysis of results
Comparison of results by non-experts
Focus on area of expertise: • A specific SoC device • A specific driver module • A specific application • etc…
Look for differences: • Wakeup frequency • P/C state changes • etc…
Best to have a baseline for comparison in all cases
Power Analysis with VTune™ Amplifier for Systems
9
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Summary View
6/16/2014 11
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
C/P States Tab
6/16/2014 12
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
C - states
6/16/2014 13
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Analyze Wakeups
Intel Confidential 14
Find dominant wakeups
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
What C-State residency numbers tell you
Residency in the deepest C-state should be >95% @ idle
If you see high residency in C0 state
CPU is executing instruction
Next Step: Active Analysis
If you see high residency in the intermediate C-states
Frequent active/idle transition is keeping CPU from entering deepest C-state. Possible causes are:
Application scheduling periodic timer with short period activity Application waits for interrupts (from device, IPI) very frequently
15
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
CPU Power Analysis Use case: Collecting data from sensor
• Continuously collecting accelerometer data • Use power analysis to find out impact of sampling frequency
SENSOR_DELAY_FASTEST SENSOR_DELAY_NORMAL
Lowest Power consumption
High Power consumption
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Component Device States Find Components Wasting Power
17
Intel Device States:
DOi0 = On
DOi1-DOi2 = Intermediate
D0i3 = Off
Find:
• Which Devices are on/off?
• For this MP3 Playing video encoder is not used?
• When they got turned on/off?
• When a device is not in use… the software needs to turn it off
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Correlate Metrics to find patterns
19
See all the metrics at once
Find patterns
Find the cause
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Depends on which SoC
C-States
P-States (CPU frequency)
SOi States (System State)
Android Wakelocks
Temperature (Core, Skin, SoC, PMIC)
S(outh) C(luster) Device States
N(orth) C(luster) Device States
20
Potential Collections
Power Analysis Use Cases
21
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use cases: Idle
Comparison of system running at Idle with a system running at idle without the ability to go to sleep.
6/16/2014 22
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use cases: Idle
6/16/2014 23
Percentage of time in C6
Core 1: 62.7%
Core 0: 63.3%
Reasons for waking up
Kernel Timer: 4347
User Timer: 4120
IRQ 46: 570
IRQ 93: 557
Frequency is almost 100% at .8 GHz
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use case: Idle – No sleep
6/16/2014 24
We have forced the target to never
sleep!
If we don’t sleep we will not get good
battery performance
Minimizing wakeups is important but it is critical to
remember that if the system is not going to sleep in the first
place you won’t see the wakeups!
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use case: Video playback
1080p playback
6/16/2014 25
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice 26
Use Case: Video playback
Percentage of time in C6
Core 1: 2.4%
Core 0: 2.7%
Reasons for waking up
Kernel Timer: 1421
User Timer: 630
IRQ 46: 111
IRQ 93: 906
Frequency almost 58.9% at 2 GHz
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use case: Video playback
6/16/2014 27
Most of the time we spend in C0 during
video playback.
Video starts here, you can filter and only see wakeups during playback.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use case: AWS Fish tank test
6/16/2014 28
The Browser is actively drawing fish
only in the light green region.
Otherwise the frequency drops and we have a regular periods
where the processor is in
C6.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use case: AWS Fish tank test
6/16/2014 29
Percentage of time in C6
Core 1: 47%
Core 0: 48%
Reasons for waking up
Kernel Timer: 4347
User Timer: 4120
IRQ 46: 570
IRQ 93: 557
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use Case: AWS An3DBenchXL
6/16/2014 30
Dragon Flowers Walking
Man
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use Case: AWS An3DBenchXL
Compare OpenGL ES 1.1 with ES 2.0
6/16/2014 31
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Use Case: Audio playback Mp3 Audio playback scenario
Initial view Filtered and zoomed
Freq = 47ms
VTune Amplifier can help find causes for wakeups and their frequencies
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
mp3-nousb-screen-off mp3-screen-off
150 wakeups/sec 197 wakeups/sec
With no usb connection intel_pmu_driver can put platform in s0i3 state
Use Case: Audio playback Audio playback –Another scenario
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Check if these are within expected range are not
Expert Analysis Video Recording on CLT+ - Summary
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Why is display driver waking up both the CPUs ?
Use Case: Video recording Video Recording on CLT+ - Display Driver
Wakeups
Filter+Zoom
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons/Regression Tests
WAKEUPS
C6 Residency
Pn Residency
Wakelocks
VTune Amplifier Views
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Native Video Playback vs 3rd Party Application
Which is “Better”?
Native Video Playback
3rd Party Application
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Native Video Playback vs 3rd Party Application
Which is “Better”?
Native Video Playback
3rd Party Application
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Native Video Playback vs 3rd Party Application
Much more time spent in C0 for the 3rd part application
Native Video Playback
3rd Party Application
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Adding a new Kernel Driver
Note the Wake-up Counts
Idle Workload
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Adding a new Kernel Driver
Note the Wake-up Counts
New Driver
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Adding a new Kernel Driver
VTune Amplifier Comparison Feature
Reduce the kernel logging (printk) in driver void my_timer_callback( unsigned long data )
{
int i,j,ret;
for (i=0;i<5000000;i++) {
for (j=0;j<5000000;j++) {
sum=sum+i;
printk( "my_timer_callback called %d\n", count );
}}
// setup the timer again to fire 500ms
if (count <50) {
setup_timer( &my_timer, my_timer_callback, 0 );
ret = mod_timer( &my_timer, jiffies +
msecs_to_jiffies(500) );
if (ret) printk("Error in
my_timer_callback\n");
count++;
}
}
void my_timer_callback( unsigned long data )
{
int i,j,ret;
for (i=0;i<5000000;i++) {
for (j=0;j<5000000;j++) {
sum=sum+i;
//printk( "my_timer_callback called %d\n", count );
}}
// setup the timer again to fire 500ms
if (count <50) {
setup_timer( &my_timer, my_timer_callback, 0 );
ret = mod_timer( &my_timer, jiffies +
msecs_to_jiffies(500) );
if (ret) printk("Error in my_timer_callback\n");
count++;
}
else {
printk( "callback called %d times\n",count);
}
}
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Comparisons Adding a new Kernel Driver
VTune Amplifier Comparison Feature
Reduce the kernel logging (printk) in driver
Reduced total C0 time
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
References
https://lesswatts.org
6/16/2014 44
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice
Legal Disclaimer & Optimization Notice
INFORMATION IN THIS DOCUMENT IS PROVIDED “AS IS”. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO THIS INFORMATION INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products.
Copyright © 2014, Intel Corporation. All rights reserved. Intel, Pentium, Xeon, Xeon Phi, Core, VTune, Cilk, and the Intel logo are trademarks of Intel Corporation in the U.S. and other countries.
Optimization Notice
Intel’s compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.
Notice revision #20110804
45