Impact of “Idle” Software on Battery Life

Manuj Sabharwal, Application Engineer Eunice Chang, Engineering Manager

Session ID: EBLS002 Agenda

• Importance of Battery Life • Role of Software in Battery Life

• Case Study: “Idle” Software Applications Overhead

• Tools for Analyzing Power Overhead

• Case Studies: Browser, Media Playback, Messaging

• Call to Action • Q/A

2 How Critical is Laptop Battery Life and the Impact of Software?

3 Top Mobile Computing Needs

Consumers’ Most Desired Laptop Configuration Improvements (Results when end-used named their top 3)

Consume Less Energy/Better Battery 66%

Better Performance/Improve Speed of … 60%

More Storage/Bigger Hard Drive 45%

Better Range of Wireless Internet … 40%

Make it Lighter 42%

Larger Screen/Display 22%

Better Appearance/Looks 15%

Make it Smaller 13%

Source: Internal Worldwide Market Research, 2010 Software Energy-Efficiency

• Platform hardware designed with aggressive power management especially when idle (e.g. ACPI, C/Pstates, PCIE ASPM, SATA LPM, etc.) • Software (OS, FW, Drivers) plays important role in platform energy efficiency

• Energy-efficient applications, when idle, should have minimal impact on platform power consumption – Ideally, application idle should consume no additional energy

A single ill-behaving application can thwart all of the power management benefits built into system.

5 A Case Study of “Idle” Software Apps

6 Case Study

The Measurement System

• Intel® Core2 Duo based Mobile Reference Platform • Core i5 T6600 (Dual Core, 2.2 GHz) • Windows* 7, 64-bit • Intel® Solid State Drive • Wired LAN • (Power) Fluke* NetDAQ

The Measured Applications

Select 25 common applications including: • 4 web browsers • 5 media playback applications • 5 messaging applications • 2 virus scanners

7 Study Results

5 Lower is Better Deep Dive #2

4

3 Deep Dive #3 Deep Dive #1

2

1 Power Over Baseline (Watts) Baseline Over Power

0 ChatMessaging PhotoPhoto VirusAnti-ProductivityProductivity PluginPlug-ins BrowsersBrowsersMediaPlayersMedia Players Virus

The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument . Results have been estimated based on internal Intel analysis 8 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Battery Life Impact

10

UltraThin, 56WHr, 6W Idle 9 Mainstream, 64WHr, 9W Idle 8 0.5W ~45Min 7

6 0.5W

Battery Life (Hours) ~20Min 2W 5 ~75Min 4 0 1 2 3 4 5 Additional Power (Watts)

Idle power increase has significant battery life impact

9 Deep Dive Detail Methodology

• Component Power (CPU, Chipset, HDD, LAN/Wifi)

• Software Tools: Hardware, Driver, , Software Timers, Memory Utilization, ... – Windows* Powercfg – Battery Life Analyzer – Windows* Performance Analyzer Toolkit (aka “xPerf”)

10 Windows* Powercfg

-line utility to control the power settings • Inbox with Windows* 7, Leverages ETW • Power Schemes, Hibernate, Standby, Wake Timer / Devices

• -ENERGY Option – Platform timers, changes to timers by the application process/dll – Processor Utilization per process – Power Management Settings in Hardware and OS – Needs to run in Administrator Mode, can output raw .etl traces

• Attend EBLS003 Mobile Platform Idle Power Optimization – Methodologies and Tools for demo and details

Quick & Easy to Identify Common Problems

11 Battery Life Analyzer

• New Tool written by Intel • Simple GUI interface

• Identify misbehaving drivers, processes, and hardware that prevent the platform from entering low power states

• Provides power impact estimate based on an algorithm for each offending piece of hardware/software

• Attend EBLS003 Mobile Platform Idle Power Optimization – Methodologies and Tools for demo and details

Identify, Analyze, and Summarize – All in one tool

12 Windows* Performance Toolkit - xPerf • Built by Microsoft, Available in Windows* 7 SDK • Leverage ETW (Event Tracing for Windows) Technology

• Wide range of OS performance analysis in a trace file – All processes/threads, User + kernel mode, DPCs and ISRs, Scheduling, Disk and file I/O, Memory, Network, …

• Some Issues xPerf can identify: – Responsiveness issues – Long delays in applications, Slow On/Off transitions – High CPU usage, High Disk usage

Feature-rich Tool for Detailed Power Performance Analysis

13 Analysis of Two Case Studies

14 Investigation #1 – A Browser Application

5 Other 4.6 7% 4 Chipset 33% CPU Deep Dive #1 3 2.7 60% 2.6 2.4 2.4 2.3 2.1 2.2 2 1.6 1.4 1.4

1 0.8 Power Over Baseline (Watts) Baseline Over Power 0 Chat/VoiPMessaging PhotoEditPhoto VirusScanVirus ProductivityProductivity BrowserBrowser MediaPlayerMedia Players Edit Scan

*The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument . Results have been estimated based on internal Intel analysis 15 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power System Idle vs. Browser Idle CPU Package Power Runtime graph for core package power Showing browser power consumption System Idle vs. Browser Idle total CPU Package Power

4.00 3.50 3.00 2.50 2.00 1.50

Power(W) 1.00 0.50 0.00 1 22 43 64 85 820 841 862 883 904 925 946 967 988 106 127 148 169 190 211 232 253 274 295 316 337 358 379 400 421 442 463 484 505 526 547 568 589 610 631 652 673 694 715 736 757 778 799 1051 1072 1009 1030

System Idle Power Browser Idle Power

Why there is an increase in Browser Idle power from System Idle?

Workload Platform Power CPU Power Browser Application 12.06 2.63 System Idle 10.12 1.46

The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument. Results have been estimated based on internal Intel analysis 16 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance Battery Life Analyzer Analysis

Average C State Residency Change - System idle vs. Browser Idle 100 Increase due to Browser Idle 80 I/O controller Operational State operations spends less 60 activity deep C state 40

Average(%) 20 0 Package0 C0 - C1 Package0 C2 Package0 C3 Package0 C6

Average System idle(%) Average Browser Idle

Few Things to Know : • C-states: Collection of Idle State. – The deeper the C-States allows to achieve the low power consumption, but time is required for the CPU to “wake up”. • Average C-State Residency is average residency in each C-State over period of time • Deeper C-state Residency(C6), more power savings (System Idle) • Periodic activity results in more time spent in C0-states (Browser Idle)

17 Windows* Powercfg

Browser setting Timer Tick to 1msec

Command line utility giving call stack of module setting timer tick to 1ms 18 Causes: Idle State Power Consumption

• Context Switches – Process of storing and restoring state of a CPU – Increase due to OS requires to take control of the CPU to do

storing and restoring task. Image Name Context Switches Context Switches – More details on cause of at system idle Browser high context switches on next Platform Activity 53 550 slide

System Idle Browser Image Name Calls/sec Calls/sec • System calls hal.dll 64.1 999.9 – Increase in periodic ataport.SYS 3.0 1.0

calls/sec due to ACPI. 0.4 0.4

clock interrupts USBPORT.SYS 3.0 2.9 hal.dll: Interrupt Servicing - much higher for application idle 19 Windows* Performance Toolkit - xPerf Analysis for Browser

xPerf shows frequent CPU activities for browser app due to many periodic activities

Process Timer Interval Remarks Browser.exe 150msec GetMessageW 21msec SendMessage 20msec Browser Service 4 msec FlushFileBuffers 20 msec WaitForSingleObject() Alternatives? -Optimized Sleep version to give better performance and power. -Use user land locks if possible instead of WaitForSingleObject -Use unbuffered I/O instead of calling FlushFileBuffers

Can periodic intervals prolonged and their activities coalesced ?

20 Effect Of Timer-Tick On Browser Application

Timer-Tick Value Platform Power CPU Package Power 1msec (Default app Idle) 12.06 2.63 10msec 11.04 1.95 System Idle 10.12 1.46

• Timer-Tick change saves 1.02 Watts of total power at platform level.

Out of Box, this browser uses 60 extra minutes battery life at “idle” on a standard 64Whr battery

The Power comparisons shown is based on the Intel Core i5- T6600 processor using NetDAQ® Fluke ® instrument. Results have been estimated based on internal Intel analysis and 21 are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Analysis

• Application appears to be setting a timer interval of 1ms • The total average CPU utilization < 0.2% • Many periodic activity with small intervals causing CPU wakeup by polling drivers

Recommendations:

• Don’t make the timer tick change request until it’s necessary • Use event driven code rather than polling CPU • Review the necessity of periodic activity and minimize • Use un-buffered I/O instead of calling FlushFileBuffers

22 Investigation #2 – A Playback Application

Other 5 Deep Dive #2 4.6 22% CPU 39% 4 Chipset 39% 3 2.7 2.6 2.4 2.4 2.3 2.1 2.2 2 1.6 1.4 1.4

1 0.8 Power Over Baseline (Watts) Baseline Over Power 0 Chat/VoiPMessaging PhotoEditPhoto VirusScanVirus ProductivityProductivity BrowserBrowser MediaPlayerMedia Players Edit Scan

*The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® . Results have been estimated based on internal Intel analysis and are 23 provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Battery Life Analyzer Analysis

C-State Package Residency- System Idle vs. Playback Idle 100 App preventing CPU to a 80 low power sleep state 60 40 20 0 Package0 C0 - C1 Package0 C2 Package0 C6

System Idle Playback Idle

• CPU can enter different idle power states • Lower power states use less power but the CPU will take longer to transition to a higher power state. – Example – If CPU is in C6 it will use less power than in C3 but it will take longer to come out of idle than from C3

Top Cause for CPU to wakeup can be analyzed using xPerf and Battery Life Analyzer

24 Windows* Powercfg

Playback Setting Timer Tick to 1.25msec

25 Battery Life Analyzer for Playback

Cause 1: Increase in Context switches Cause 2: Increase in periodic from idle due to Timer tick and calls/sec due to clock interrupts I/O Activity System Idle Playback Context Context Image Name Image Name Switches at Switches Calls/sec Calls/sec system idle Playback hal.dll 64.1 800 Platform dxgkrnl.sys 1 210 Activity 53 689 USBPORT.SYS 10 18

Causing graphics frame buffer ataport.SYS 3.0 4.2 update frequently which is called by playback application.

At idle reduce the periodic graphics activity such as animation

26 Windows* Performance Toolkit – xPerf Analysis

Process/ Driver Timer Interval Remarks Playback.exe 10msec Sleep1() 33msec Sleep2() 31msec Sleep3() xGUISystem 50msec Sleep() D3D9System 1msec Graphics driver call from Application

• Avoid calling SetThreadExecutionState(ES_DISPLAY_REQUIRED) when there is no playback activity, i.e. at idle Timer-Tick Value Platform Power CPU Package Power 1msec(App Default) 14.06 4.49 System Idle(15.6msec) 10.12 1.46

Out of Box, this playback uses 112 extra minutes battery life at “idle” on a standard battery

27 The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument. Results have been estimated based on internal Intel analysis and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Analysis

• Application appears to be setting a timer interval of 1.25ms • Application having frequent periodic activity by calling Sleep API • Multiple threads are looping at Sleep() independently with various interval. All combined, this process wakes up the processor very frequently • Application doing a lot of memory between CPU & GPU memory

Recommendations:

• Do not try to change timer tick from 15.6 ms default when application is at idle. • Use event driven API calls than Polling. • Instead of running multiple thread periodically (Sleep() API ) run one thread at the lowest frequency possible, and if necessary, signal to other thread. • Do not render to the display when it is off • The system display might be off for power savings. Your application should not perform unnecessary graphics rendering when the display is off because this wastes system resources and power.

28 Study Results Summary

5 Lower is Better Playback having low power consumption when Idle 4

Messenger having low power consumption when Idle 3

2 Browser having low power consumption when Idle

1 Power Over Baseline (Watts) Baseline Over Power

0 ChatMessaging PhotoPhoto VirusAnti-ProductivityProductivity PluginPlug-in BrowsersBrowsersMediaPlayersMedia Players Virus

Why can’t Application behave like good ones in their own categories?

*The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument. Results have been estimated based on internal Intel analysis 29 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Summary

• Battery Life is an important attribute of Laptop systems • Case Studies shows power impact at application idle on battery life. • Changes can be made that do not affect software performance and reduce the impact. E.g. – Avoid use of high-resolution periodic timer – Do not render to the display when it is off – Avoid polling and spinning in tight loops – Use timer coalescing • Reduce the background application services when idle.

30 Call to Action

• Evaluate the idle impact of your software applications – pay specific attention to timer-tick interrupts • Ask your suppliers/Vendors to do the same and aware them about power awareness. • Blog, Ask questions in forums, raise awareness about application that consume too much power • Promote Green Software • Join Extended Battery Life Working Group (www.eblwg.org)

31 Additional Resources • Creating Energy Efficient Software (Part 1-4) http://software.intel.com/en-us/articles/creating-energy- efficient-software-part-1/ • CPU Power Utilization on Intel® Architectures http://software.intel.com/en-us/articles/cpu-power- utilization-on-intel-architectures/ • C-states, C-states and even more C-states http://software.intel.com/en-us/blogs/2008/03/27/update-c- states-c-states-and-even-more-c-states/ • Battery Life Analyzer [email protected] • Mobile PC Extended Battery Life (EBL) http://www.eblwg.org/index.asp • Battery Life and Energy Efficiency http://www.microsoft.com/whdc/system/pnppwr/mobilepwr. mspx • Windows Performance Analysis Toolkit (xPerf) http://msdn.microsoft.com/en- us/performance/cc825801.aspx

32 IDF 2010 Extended Battery Life Sessions

Session # Time Room

Interconnect Bus Extensions for EBLS001 10:15 AM 2003 ü Energy-Efficient Platform

Impact of “Idle” Software on Battery EBLS002 11:15 AM 2003 ü Life Mobile Platform Idle Power EBLS003 Optimization – Methodologies and 1:05 PM 2003 Tools

Embedded Display Port: Next EBLP001 Generation of Digital Display 2:05 PM 2003 Interface for Embedded Application

33 Legal Disclaimer • INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPETY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL® PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. • Intel may make changes to specifications and product descriptions at any time, without notice. • All products, dates, and figures specified are preliminary based on current expectations, and are subject to change without notice. • Intel, processors, chipsets, and desktop boards may contain design defects or errors known as errata, which may cause the product to deviate from published specifications. Current characterized errata are available on request. • Performance tests and ratings are measured using specific computer systems and/or components and reflect the approximate performance of Intel products as measured by those tests. Any difference in system hardware or software design or configuration may affect actual performance. • Intel Core™ i5 Mobile Processor and the Intel logo are trademarks of Intel Corporation in the United States and other countries. • *Other names and brands may be claimed as the property of others. • Copyright ©2010 Intel Corporation.

34 Risk Factors

The above statements and any others in this document that refer to plans and expectations for the second quarter, the year and the future are forward-looking statements that involve a number of risks and uncertainties. Many factors could affect Intel’s actual results, and variances from Intel’s current expectations regarding such factors could cause actual results to differ materially from those expressed in these forward-looking statements. Intel presently considers the following to be the important factors that could cause actual results to differ materially from the corporation’s expectations. Demand could be different from Intel's expectations due to factors including changes in business and economic conditions; customer acceptance of Intel’s and competitors’ products; changes in customer order patterns including order cancellations; and changes in the level of inventory at customers. Intel operates in intensely competitive industries that are characterized by a high percentage of costs that are fixed or difficult to reduce in the short term and product demand that is highly variable and difficult to forecast. Additionally, Intel is in the process of transitioning to its next generation of products on 32nm process technology, and there could be execution issues associated with these changes, including product defects and errata along with lower than anticipated manufacturing yields. Revenue and the gross margin percentage are affected by the timing of new Intel product introductions and the demand for and market acceptance of Intel's products; actions taken by Intel's competitors, including product offerings and introductions, marketing programs and pricing pressures and Intel’s response to such actions; defects or disruptions in the supply of materials or resources; and Intel’s ability to respond quickly to technological developments and to incorporate new features into its products. The gross margin percentage could vary significantly from expectations based on changes in revenue levels; product mix and pricing; -up costs, including costs associated with the new 32nm process technology; variations in inventory valuation, including variations related to the timing of qualifying products for sale; excess or obsolete inventory; manufacturing yields; changes in unit costs; impairments of long-lived assets, including manufacturing, assembly/test and intangible assets; the timing and execution of the manufacturing ramp and associated costs; and capacity utilization. Expenses, particularly certain marketing and compensation expenses, as well as restructuring and asset impairment charges, vary depending on the level of demand for Intel's products and the level of revenue and profits. The majority of our non-marketable equity investment portfolio balance is concentrated in the flash memory market segment, and declines in this market segment or changes in management’s plans with respect to our investment in this market segment could result in significant impairment charges, impacting restructuring charges as well as gains/losses on equity investments and interest and other. Intel's results could be impacted by adverse economic, social, political and physical/infrastructure conditions in countries where Intel, its customers or its suppliers operate, including military conflict and other security risks, natural disasters, infrastructure disruptions, health concerns and fluctuations in currency exchange rates. Intel’s results could be affected by the timing of closing of acquisitions and divestitures. Intel's results could be affected by adverse effects associated with product defects and errata (deviations from published specifications), and by litigation or regulatory matters involving intellectual property, stockholder, consumer, antitrust and other issues, such as the litigation and regulatory matters described in Intel's SEC reports. An unfavorable ruling could include monetary damages or an injunction prohibiting us from manufacturing or selling one or more products, precluding particular business practices, impacting our ability to design our products, or requiring other remedies such as compulsory licensing of intellectual property. A detailed discussion of these and other factors that could affect Intel’s results is included in Intel’s SEC filings, including the report on Form 10-Q for the quarter ended March 27, 2010.

Rev. 5/7/10

35 Backup

36 Investigation #3 – A Messenger Application

5 4.6 Other 29% CPU 4 45% Deep Dive #3 Chipset 3 2.7 2.6 26% 2.4 2.4 2.3 2.1 2.2 2 1.6 1.4 1.4

1 0.8 Power Over Baseline (Watts) Baseline Over Power 0 Chat/VoiPMessaging PhotoEditPhoto VirusScanVirus ProductivityProductivity BrowserBrowser MediaPlayerMedia Players Edit Scan

*The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument. Results have been estimated based on internal Intel analysis 37 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance/Power Battery Life Analyzer Analysis

C-State Package Residency- System Idle vs. Messenger Idle 100.00 More time spent in deeper C-State 80.00 can result in better power 60.00 40.00

Average(%) 20.00 0.00 Package0 C0 - C1 Package0 C2 Package0 C6

Average System Idle (%) Average Messenger Idle (%)

Increase in C0-State Package Residency is same as in previous Case studies

Cause: Context switches Cause 2: Increase in periodic from idle due to Timer tick and calls/sec due to clock interrupts I/O Activity System Idle Messenger Image Name Context Context Calls/sec Calls/sec Image Name Switches at Switches hal.dll 64.1 1000 system idle Messenger USBPORT.SYS 10 12

Platform Activity 53 1138 ataport.SYS 3.0 4.2

A break event brings the idle CPU to C0 State 38 Windows* Powercfg

Messenger Setting Timer-Tick to 1msec

39 Windows* Performance Toolkit - xPerf Analysis for Messenger Process Timer Interval Remarks Messenger.exe 165msec GetMessage 2msec WaitForSingleObject 2msec timeSetEvent 20msec RegQueryValue

Alternative?: •Use Event Driven code - RegNotifyChangeKeyValue() instead of RegQueryValue •Use of coalescing timer API. Timer-Tick Value Change Effect Timer-Tick Value Platform Power CPU Package Power Memory

1msec(Application Default) 11.95 2.48 1.12 10msec 10.71 1.87 0.31 System Idle(15.6msec) 10.12 1.46 0.08 Out of Box, this Messenger uses 58 extra minutes battery life at “idle” on a standard battery

The Power comparisons shown is based on the Intel® Core™ i5 Mobile Processor using NetDAQ® Fluke ® instrument . Results have been estimated based on internal Intel analysis 40 and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance Analysis

• Application appears to be setting a timer interval of 1ms • Application having frequent periodic activity – WaitForSingleObject, GetMessageW, TimerSetEvent. • I/O Reads/Writes to the registry increases 2x time on average compared to system idle Recommendations:

• Do not change Time Tick value from system default. • Minimize the use of polling. If possible, use an interrupt instead. • If the driver must poll, consider implementing timers by using the new timer coalescing techniques which reduces the CPU wake frequency • Periodic registry activity must also be avoided • Registry activity eventually results in disk activity

41 Timer Coalescing

• Platform energy efficiency can be improved by extending idle periods – New timer coalescing API enables callers to specify a tolerance for due time – Enables the kernel to expire multiple timers at the same time • Extensions should integrate with Windows* 7 API/DDI