how to minimize your app’s power consumption
DESCRIPTION
Get an overview of Qualcomm Technologies, Inc.'s power and performance profiling tools, and how these tools can help you create more efficient apps. Covered topics include using profiling tools to determine whether your app exhibits behavior that causes excessive power consumption, how to resolve the top five power-related problems and more. Watch this presentation on YouTube: https://www.youtube.com/watch?v=9Uc0qpMzfw0TRANSCRIPT
1
How to minimize the power consumption of your app
Rick Schwartz, Senior Product Manager Qualcomm Technologies, Inc.
3
Mobile trends
4
Mobile trends resulting in increased power consumption
High end processor speeds increased from 1.5 GHz to 2.3 GHz over a 16 month period
The number of cores in mobile devices have increased 3 of the past 4 years
Mobile displays are getting larger and higher in resolution − HD (1280x720) > FHD (1920x1080) > QHD (2560x1440)
Some mobile devices now designed to work 24/7 − Tracking location − Listening for voice commands − Integrated step counters track movement
A single mobile processor can replace several discrete chips
Source: Qualcomm Technologies, Inc. data
5
Processor speed and number of cores has changed dramatically Processor specs for flagship Android devices by year
Number of Cores
3 8
7
6
5
4
3
2
1
2.5
2
1.5
1
0.5
0
Frequency (GHz)
Cores
Frequency 80% increase in processor speeds
2012 2013 2014
Source: Qualcomm Technologies, Inc. data 2012 – Samsung Galaxy S III - Snapdragon S4 SoC featuring a dual-core 1.5 GHz; 2013 – Samsung Galaxy S4 - Qualcomm Snapdragon 600 APQ8064AB quad-core 1.9 GHz; 2014 – Samsung Galaxy S5 - Qualcomm Snapdragon 801 (8974) 2.5 GHz quad-core
6
Battery capacity hasn’t kept up Processor specs for flagship Android devices by year
Number of Cores
3 8
7
6
5
4
3
2
1
2.5
2
1.5
1
0.5
0 2012 2013 2014
Frequency (GHz)
Cores
Frequency 80% increase in processor speeds
33% increase in battery power
Battery
Source: Qualcomm Technologies, Inc. data 2012 – Samsung Galaxy S III - Snapdragon S4 SoC featuring a dual-core 1.5 GHz; 2013 – Samsung Galaxy S4 - Qualcomm Snapdragon 600 APQ8064AB quad-core 1.9 GHz; 2014 – Samsung Galaxy S5 - Qualcomm Snapdragon 801 (8974) 2.5 GHz quad-core
7
Mobile displays are getting larger Larger screens with higher pixel densities often require more power
47 46 42 29
48 116
156 193 2
9
51
185
1
8
2009 2010 2011 2012
5.0 – 5.9 in
4.0 – 4.9 in
3.0 – 3.9 in
Less than 2.9 in
Number of Smartphone models with given display size1
Smart phones, Worldwide, units (%) by screen size, Q1 2014;
This year 34% of all smartphones have screens that are larger than 5 inches2
1 Source: Yankee Group, 2013 2 Source: Canalsys
8
Location services designed to track movement in the background Taking a GPS fix consumes power
Source: Google Location History
9
Listening apps are becoming more popular Continuous listening for a phrase that wakes-up the device consumes power
Good morning.
Say help me for a list of commands
Speak now…
Screen images simulated
10
Qualcomm® Snapdragon™ processors designed to do many things
Qualcomm® Izat™ GNSS with support for three
GPS constellations
Support for up to 2560x2048 display Miracast 1080p HD support
21MP with dual ISP
Ultra HD Capture and Playback DTS-HD and Dolby Digital Plus audio
Expanded Gestures
Integrated Qualcomm® Gobi™ 4G LTE World Mode
1, 802.11ac
1, USB 3.0 and BT 4.0 offers
broad array of high speed connectivity
Qualcomm® Hexagon™ QDSP6 for ultra low power applications and custom programmability
Qualcomm® Adreno™ 330 for advanced graphics
Krait™ 400 CPU features 28HPm process technology superior 2GHz+ performance
Low-power Snapdragon Sensor Core increases sensor accuracy and
efficiency
1 Available only in select processors
Qualcomm IZat is a product of Qualcomm Atheros, Inc.
Qualcomm Snapdragon, Krait, Qualcomm Adreno, Qualcomm Hexagon, Qualcomm Gobi and Snapdragon Sensor Core are products of Qualcomm Technologies, Inc.
11
Processors are getting more efficient, but power demands are increasing Over a two-year period power consumption doubled or tripled in some areas
Source: MICROWAVE JOURNAL - NOVEMBER 2012 – Technical Feature by Matthew Hubbard
Function 2009 2011 % Change
Display 300 mW 900 mW 300%
Peripherals 400 mW 1500 mW 275%
Processor 800 mW 1620 mW 200%
Audio 300 mW 400 mW 30%
RF 1200 mW 1330 mW 11%
Total 3000 mW 5750 mW 92%
Power consumption changes for different functions over two years
12
The problem
13
Battery life is very important to consumers
Consumers rank phone battery life as the most important factor in their smartphone buying decision. Q: For your next smartphone/mobile phone purchase, which of the following features would drive your decision to select one phone over others?
Importance of Smartphone Features Among Smartphone Buyers1
38%
42%
44%
46%
46%
48%
52%
72%
Display / screen resolution
Memory / storage
4G or LTE connectivity
Screen / display type / quality
Screen / display size
Touchscreen
WiFi speed / quality
Battery life
1 Source: Qualcomm Brand Tracker, Market Research Group. United States, January 2014
Top 10 Smartphone Purchase Drivers2
Android vs. iOS Windows vs.
Battery Life
Ease of Use
Operating System Android, Symbian,
webOS, Windows Mobile
Touch Screen
Screen size
56% 49% 53%
33% 39% 38%
37% 32% 40%
34% 34% 37%
37% 22% 34%
2 Source: IDC's ConsumerScape 360 by IDC Michael DeHart
14
“High-risk” apps can waste power and mobile data List of “high risk” apps that drain the battery faster than normal typically highlighted
Over 70% of these apps are chart toppers in Google Play
Some of these apps can cause the battery to drain 2 to 5 times faster than normal
Some of these apps can cause unexpected data usage (up to 2.2GB a month)
Source: Descriptions taken from Verizon’s High-risk App site. April 2014
15
Heavy battery usage is a top reason consumers uninstall apps
76%
59%
71%
55% 53%
Freezes Slow responsiveness Crashes Heavy battery usage Too many ads
What causes users to delete and app? What causes users to delete an app?
Source: Fierce Developer Survey – Exploring the reasons users complain about apps (Nov. 2012)
#1 #2
#3 #4 #5
16
Does your app consume too much power?
17
Measuring power consumption using hardware Monsoon Power Monitor
Displays overall current, voltage and power usage
Can display averages over a specific time period
Off-target - Attaches directly to the battery in a mobile device
18
Measuring power consumption using software Option 1: PowerTutor
Displays power usage for CPU, LCD, Wi-Fi, 3G, GPS and Audio Estimates power usage based on system state model
Available on Google Play
Runs on all Android devices
19
Measuring power consumption of individual apps Using Trepn™ Profiler - Starter Edition to measure power consumption
Restart your device and make sure nothing is running in the background
Source: Trepn Profiler screenshots | Trepn is a product of Qualcomm Technologies, Inc.
“Profile App” or “Profile System”
Launch Trepn, go to Settings, and select the Battery Power data point
Check “Acquire Wakelock while Profiling” keep your processor awake
1 2 3 4
3.3x more power than idle
5x more power used than idle 53% more than another game
Screen off after 2 min
20
Measuring per-rail power consumption Using Trepn Profiler to view per-rail delta power measurements
This software is preinstalled on Snapdragon MDP hardware
The Snapdragon 805 MDP/T has rails for Battery power, CPU, Camera, Digital Core, Graphics, Internal Memory, LCD Backlight, SD Card and WLAN/BT
Power Delta Before Photo Taken Power Delta After Photo Taken
Source: Trepn Profiler Premier Edition screenshots
21
Identifying the cause of power spikes in your code Inserting markers in your code can help identify the cause of power spikes
Source: Trepn Profiler screenshots
22
Common causes of excessive power consumption
1. Preventing the processor
(or other hardware subsystems) from
going to sleep
3. Inefficient use of the cellular radio
and Wi-Fi network
2. Keeping the display lit too long
4. Taking too many GPS location fixes
23
Do your apps have any of these problems?
24
Does your app prevent the processor from going to sleep? Using Wakelock Detector (WLD) to identify processor sleep problems (Android 4.3 and earlier)
To test, unplug your device and run it for at least 2-3 hours
A large number of short wakelocks or wakeup triggers can have a negative impact on battery usage because a phone takes time to wake and go back asleep
CPU Wakelocks Wakeup Triggers
25
Sometimes there are good reasons to keep the processor awake. How can you tell? Trepn plug-in shows which wake locks are needed by correlating them to other system events
Source: Trepn plug-in screenshot
26
Why keeping the screen awake is a problem The display is the single biggest consumer of system power
Full wakelocks – Keep your screen from turning off
Using wakelocks for extended periods will significantly increase battery consumption
Full wakelocks are less of a problem than partial wakelocks because they are much more obvious
27
Many apps do not use the network efficiently Multiple apps acting independently can create network signaling congestion
Apps can pull notifications, updates, and message users – even when the phone not actively used
Many news and social networking apps wake up your device at least 4x an hour
28
Connected (Idle) 8-15 seconds
Current (m
A)
Connected (Active)
Time (seconds)
<10mA
250-300 mA
~150 mA
Why this is a problem
A dormant cellular radio consumes less than 10 mA
When data is sent or received, the radio comes up and goes into an active state, consuming 250-300mA
When not sending data, the radio drops down to idle, but still consumes about 150mA
After a timeout of 8 to 15 seconds, the radio finally goes back to a dormant state
29
How to tell if your app is using the cellular radio efficiently Trepn plug-in shows cellular radio and Wi-Fi network state, amount of data transmitted and the name of apps sending data
See mobile network state and mobile data usage by app
Source: Trepn plug-in
30
Does your app use GPS efficiently?
Many apps take GPS fixes when they are not needed
Utilities like AT&T’s ARO and Trepn plug-in show GPS fixes
31
One way to tell if your app is CPU bound Trepn Profiler’s real-time overlays show CPU and GPU utilization
Source: Trepn
32
How to address excessive power consumption
33
How to avoid preventing your device from going to sleep Expert advice how to use wakelocks more efficiently
1. Do not acquire PowerManager.Wakelocks unless you really need them − Device battery life will be significantly affected by the use of this API
2. Use the minimum levels needed
3. Be sure to release wakelocks as soon as possible
4. To keep the screen lit when your app is in the foreground, use FLAG_KEEP_SCREEN_ON instead
Source: http://developer.android.com/reference/android/os/PowerManager.html#PARTIAL_WAKE_LOCK
34
How to efficiently use your cellular radio and Wi-Fi network
1. Connect less often – After you transmit data, the radio stays on for an additional 10 to 12 sec
2. Push, don’t poll – Specify how often items are delivered
3. Use analytics wisely − Capture data locally and group transmissions to your server. Extend the time between transmissions
4. Offer ad-free versions of apps – Apps without ads connect to the network much less often
5. Don’t continuously scan − Create timeouts appropriately when scanning for Wi-Fi networks or GPS signals
6. Don’t continuously stream – Download streams in chunks
7. Offload to Wi-Fi – It uses significantly less battery than 3G or 4G
Source: AT&T “Tips to Increase Battery Life Handout”
35
Bundling traffic can reduce overhead-to-data ratio
Ta Tb Tc
The amount of overhead to eac data burst is high
Bundling data results in shorter connection time and less overhead
Td
Td
Td < Ta+ Tb + Tc
Bundling or gating reduces the number of times the device connects to the network, which reduces signaling and power consumption
Data from different apps
Overhead (Radio on duration)
Overhead transmission continues (based on dormancy timer) before terminal goes back to idle
Source: The Smartphone Challenge: Signaling Congestion and Power Consumption - Gerardo Giaretta – Qualcomm Technologies Inc.
36
The benefit of using your radio more efficiently Bundling data results in significant power savings
~9000mA
~5000mA Nearly half the power!
300
150
10
2 minutes 1 minute 3 minutes
2 minutes 1 minute 3 minutes
300
150
10
Power (m
A)
Power (m
A)
Source: Qualcomm Technologies, Inc. data
37
Using WifiLocks more efficiently Here’s what Google says about the use of WifiLocks
1. The Wi-Fi radio will only turn off if no WifiLocks are held by any application
2. Before using a WifiLock, consider if your app requires Wi-Fi access, or could function of the mobile network
3. Large file downloads should hold a WifiLock to ensure the download will complete
Source: http://developer.android.com/reference/android/net/wifi/WifiManager.WifiLock.html
38
How to save power when using the GPS
1. Make sure you don’t take a GPS fix when it’s not needed – AT&T’s ARO and Trepn plug-in show when GPS fixes occur
2. Use coarse GPS fixes when possible because they require less power
3. Make the user aware when location tracking is active
4. Make it easy for users to disable location tracking without crippling their device
39
Recap of power saving tips
Use wakelocks only when necessary, use the minimum levels possible and release them as soon as possible. Use KEEP_DISPLAY_ON instead
Close TCP sockets when done. Otherwise, you unnecessarily bring up the network just to tear down. This simple fix can reduce network power up to 20%
Group network activity when possible; Be flexible in your ping times
Review Best Practices for detailed solutions to power and performance-related problems
Turn off functions like GPS, camera, accelerometer and other sensors when they are no longer required
40
Summary
Long battery life is very important to consumers
There is no excuse for bad power management – Free software is available that makes it easy to locate and fix problems with excessive power consumption
Better battery life can give your app an advantage over the competition, which could result in more positive reviews
41
developer.qualcomm.com
Augmented reality
Context awareness
Peer to peer
Wireless health
Graphics & gaming
Computer vision
Android applications
App development SDKs & tools
Marketing opportunities
Case Studies & Tutorials
News & Information
Hardware development platforms
Forums & technical support
Tools & resources to help developers build, integrate, and optimize
Qualcomm Developer Network
42
For more information on Qualcomm, visit us at: www.qualcomm.com & www.qualcomm.com/blog
Thank you
FOLLOW US ON:
© 2013-2014 Qualcomm Technologies, Inc. and/or its affiliated companies. All rights reserved. Qualcomm, Snapdragon, Adreno, Gobi, Trepn and Hexagon are trademarks of Qualcomm Incorporated, registered in the United States and other countries. Uplinq, Krait, and Izat are trademarks of Qualcomm Incorporated. All trademarks of Qualcomm Incorporated are used with permission. Other product and brand names may be trademarks or registered trademarks of their respective owners. References in this presentation to “Qualcomm” may mean Qualcomm Incorporated, Qualcomm Technologies, Inc., and/or other subsidiaries or business units within the Qualcomm corporate structure, as applicable. Qualcomm Incorporated includes Qualcomm’s licensing business, QTL, and the vast majority of its patent portfolio. Qualcomm Technologies, Inc., a wholly-owned subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of Qualcomm’s engineering, research and development functions, and substantially all of its product and services businesses, including its semiconductor business, QCT.