1 / 39

The Efficiency Imperative: The Importance of Making Your Applications “Energy Smart”

Required Slide. SESSION CODE: DPR308. The Efficiency Imperative: The Importance of Making Your Applications “Energy Smart”. Kim Shearer Senior Program Manager Microsoft Corporation. Agenda. The growing importance of IT efficiency initiatives The role of applications in IT efficiency

gyala
Download Presentation

The Efficiency Imperative: The Importance of Making Your Applications “Energy Smart”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Required Slide SESSION CODE: DPR308 The Efficiency Imperative: The Importance of Making Your Applications “Energy Smart” Kim Shearer Senior Program Manager Microsoft Corporation

  2. Agenda • The growing importance of IT efficiency initiatives • The role of applications in IT efficiency • First steps towards Energy Smart Applications

  3. IT, We Have a Problem Inefficient IT

  4. And, It Gets Worse • Stressed Power Systems

  5. And Worse Still… • Stressed Power Systems

  6. The Goal • Stressed Power Systems • Efficient IT

  7. The Evolution of IT Fundamentals

  8. IT Power Reduction Opportunities • Building • Management Infrastructure Improve Data Center PUE Increase Facility Utilization • Hardware Package Increase Server Utilization Centralized PC Power Management • Applications Rightsizing Efficient Power Supply Remove Unnecessary Components • Operating System Energy Efficient & Aware Applications Energy Efficient & Aware Applications • Silicon Platform Power Management Low-power components

  9. Impacts of software-related inefficiencies

  10. Platform Power Management

  11. Whose Job is this Anyway? Power Efficient System

  12. Welcome to the Party, Applications!

  13. The first steps

  14. System sleep & display power management • Sleep uses 1/10 or less power of active idle • Getting better each generation of hardware • Significant cost savings - http://www.energystar.gov/index.cfm?c=power_mgt.pr_power_mgt_low_carbon • So • Don’t cause insomnia • Do use availability requests intelligently • Behave well around sleep transitions

  15. Availability request APIs • Availability request API methods • These can be used to: • Prevent display power management dimming the screen • Prevent display power management turning off the screen • Prevent the system entering automatic sleep • Enable away mode (intended for media systems)

  16. Accidental insomnia • Look carefully at any availability requests you raise • Don’t prevent sleep unless it is critical • Don’t prevent sleep for a system on battery unless it is really critical • If a task will require preventing sleep, but was not user initiated, should you start it on battery? • Be aware of indirect PA requests you may cause • Open file shares? • Audio stack open? • Other libraries

  17. Debugging insomnia • Powercfg /requests • Additional energy efficiency information with Powercfg /energy C:\Windows\system32>powercfg /requests DISPLAY: None. SYSTEM: [SERVICE] \Device\HarddiskVolume2\Windows\System32\svchost.exe (RasMan) Active RAS connection AWAYMODE: None.

  18. Passive Interaction Scenarios • Do use an availability request in passive viewing or listening scenarios • If rendering user-initiated video in foreground keep screen awake • If not actively rendering to the screen or in the background, clear the availability request e.g. • Played to end of video • Paused • Hidden tab in browser • Inactive/hidden window

  19. Sleep/Resume Transition Behavior • Do return from sleep in a “reasonable” manner • Allow system to be responsive – don’t hog resources on wake • Make sure application is responsive • Forced sleep has no veto, make sure you handle this • PwrTest tool helps in testing these scenarios • http://msdn.microsoft.com/en-us/library/ff550682(VS.85).aspx • Many parameters including – cycles, duration, sleep state, critical… • PwrTest /sleep /c:10 /s:rnd /d:180 /p:600

  20. Timer resolution • Default resolution is 15.6ms • Maximum resolution is 1ms • 1ms can increase power consumption by 20%! • Which decreases battery run time by 20%! • Try to be event or interrupt driven • Use least resolution that is good enough • Set high resolution only when you need it • Aggressively reset resolution to default • Play back is paused • Tab is not active in browser • Screen is dimmed or sleeping…

  21. Application Design PrinciplesOptimize Resource Consumption • WaitForSingleObjectEx() or SleepEx() APIs • Allows you to wait for many different types of objects, I/O Completions, or APCs voidEatBatteryLife() { HANDLE sharedResource = NULL; //spawn multiple threads, one of which does this: while(sharedResource == NULL) { waitTime++; Sleep(1);//or just keep spinning on a lock or mutex } } DO NOT DO THIS

  22. Application Design PrinciplesEvent Driven Example //thread 1’s code voidUpdateSharedResource() { //set sharedResource sharedResource= UpdateResource(); //Set sharedResourceIsReadyEventto signaled SetEvent(sharedResourceIsReadyEvent); } /thread 2's code voidConsumeSharedResource() { DWORD dwWaitResult; dwWaitResult = WaitForSingleObject( sharedResourceIsReadyEvent, INFINITE); // indefinite wait switch (dwWaitResult) { case WAIT_OBJECT_0: // // TODO: use sharedResource // break; default: return 0; } }

  23. Timer Coalesce - Increasing idle periods • Allows grouping of scheduled timer events • Longer idle periods • Extending Idle periods will be more critical to energy efficiency on future platforms Timer tick 15.6 ms Vista Windows Vista Periodic Timer Events Windows 7 Windows 7

  24. Application Design PrinciplesCoalesce Activity • SetWaitableTimerEx() API • You should replace calls to SetWaitableTimer() with calls to this API • More efficient than a purely periodic timer • Has a tolerance parameter that should scale with the timer period BOOL WINAPI SetWaitableTimerEx( __in HANDLE hTimer, __in const LARGE_INTEGER *lpDueTime, __in LONG lPeriod, __in_opt PTIMERAPCROUTINE pfnCompletionRoutine, __in_opt LPVOID lpArgToCompletionRoutine, __in_opt PREASON_CONTEXT WakeContext, __in ULONG TolerableDelay );

  25. Application Design PrinciplesCoalesce Activity voidCreateAndSetPeriodicTimer() { myTimer= CreateWaitableTimerEx(NULL, TimerName, //string with chosen timer name NULL, TIMER_MODIFY_STATE); //required security attribute to call //SetWaitableTimerEx bError= SetWaitableTimerEx(myTimer, DueTime, //UTC due time 10000, //periodic timer duration is ten seconds CompletionRoutinePointer, //APC completion routine ArgsToCompletionRoutine, //completion routine arguments WakeContext, //only if waking the machine 1000); //tolerable delay is one second //DO WORK bError= CancelWaitableTimer(myTimer); //be sure to cancel periodic timers! }

  26. Measuring power consumption • Performance tests are usually about extreme load • Most opportunities for PPM energy savings are at low to medium load • How efficient is your product at low load levels? • Measure increase in idle power for install of your product • Measure at multiple load levels: idle, 25%, 50%, 100% back to idle • Trend these over time • Set a goal for increased efficiency

  27. Effect of Timer Resolution (end of 08)

  28. Register for Power Events • Use RegisterPowerSettingNotification to register for power events • Receive PBT_POWERSETTINGCHANGE notifications with • WM_POWERBROADCAST messages for interactive applications • Through the HandleEX callback registered with RegisterServiceCtrlHanderEx for service applications • PowerEvent monitoring tool provides example code

  29. Register for Power Events // // Register for Power Setting Notifications. // // The RegisterPowerSettingNotification API returns a handle to the // registration which we cache in a local variable so that we can // unregister when the window is closed. We also do the registration here // because it is explicitly obvious that the dialog is initialized and the // handle to the window is valid. // hPowerPersonality = RegisterPowerSettingNotification(m_hWnd, &GUID_POWERSCHEME_PERSONALITY, DEVICE_NOTIFY_WINDOW_HANDLE); hBatteryPercentage = RegisterPowerSettingNotification(m_hWnd, &GUID_BATTERY_PERCENTAGE_REMAINING, DEVICE_NOTIFY_WINDOW_HANDLE); hACDCSource = RegisterPowerSettingNotification(m_hWnd, &GUID_ACDC_POWER_SOURCE, DEVICE_NOTIFY_WINDOW_HANDLE);

  30. Listen and Take Action //Custom handler for processing WM_POWERBROADCAST messages LRESULT CPowerMonDlg::OnWMPowerBroadcast(WPARAM wParam, LPARAM lParam) { … switch(LOWORD(wParam)) { case PBT_POWERSETTINGCHANGE: // // This is the type of message sent by the power manager when a // power event such as a power plan personality or a system power source // change event occurs. We need to take the // POWERBROADCAST_SETTING struct pointed to by the lParam and // analyze it to determine what setting changed. // PowerMessageSetting= (PPOWERBROADCAST_SETTING)lParam; if (IsEqualGUID(PowerMessageSetting->PowerSetting, GUID_POWERSCHEME_PERSONALITY) && PowerMessageSetting->DataLength == sizeof(GUID)) { // // This is a powerscheme personality change. // Determine power scheme, then take appropriate actions // PowerMessageGUID= *(GUID*)PowerMessageSetting->Data; if (IsEqualGUID(PowerMessageGUID, GUID_TYPICAL_POWER_SAVINGS)){ // Balanced

  31. Success Stories

  32. Tools • Powercfg – detect many power efficiency issues and modify power plans • http://www.microsoft.com/whdc/system/pnppwr/mobile_bat_Win7.mspx • Pwrtest – test sleep and resume behavior • http://msdn.microsoft.com/en-us/library/ff550682(VS.85).aspx • PowerEvent monitoring tool – example app • http://www.microsoft.com/whdc/system/pnppwr/powermgmt/PM-apps_samp.mspx

  33. Future considerations • Be more aware of conserving power on battery • On Power Saver think about saving power at the cost of performance • Core parking – avoid core affinity • The better processors get at saving power at idle, the more you have to lose by not getting to and staying at idle

  34. Call to Action • Download and read the guidance • Explore the tools • Test your applications for appropriate use of: • Timer resolution changes (client and server apps) • Direct and Indirect Power availability requests (client apps) • For client apps, ensure: • Good behavior after sleep/resume transition • For client and server apps, plan for: • Mobile power source changes or server power capping • Increasing power savings at idle – get to idle and stay at idle • Working effectively with PPM

  35. Required Slide Resources Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn

  36. Required Slide Complete an evaluation on CommNet and enter to win!

  37. Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registrationJoin us in Atlanta next year

  38. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

  39. Required Slide

More Related