32

Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Embed Size (px)

Citation preview

Page 1: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305
Page 2: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Focus on Fundamentals in Windows Applications (Graphics, Power, Services, Profiling) Kyle Marsh

Principal Program ManagerMicrosoft CorporationWCL305

Page 3: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Agenda

Background ActivityServicesTasks

PowerGraphicsIntuitive UIWindows Performance Toolkit

Page 4: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Fundamentals

MemoryReference set, Graphics

Disk I/ORegistry Reads, Indexer

PowerDVD Playback, Panel, Timers

SpeedFaster Boot, Device Ready

ResponsivenessStart menu, Taskbar

Scale256 cores

IncreaseDecrease

Page 5: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

What Is Background Activity?

System activity that is not directly initiated by user

Services, Scheduled tasks, some COM processes such as a COM service, WMI providers, etc.

Part of nearly every usage scenario:Search indexingSystem security and maintenanceNetwork managementDevice managementSystem configuration

Page 6: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Impact Of Background Activity

Performance• Responsiveness to the user• Consumes resources from

foreground applications• Boot, Shutdown, Logoff, etc.

Reliability• Memory leaks• System crashes, hangs• Dependent application

crashes

Security• Activity may require

system privileges• Successful attack may

compromise entire system

Power Consumption• Extra disk, CPU utilization• Decrease in battery life• Prevents idle efficiencies

Page 7: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Background Activity Performance ImpactCompared IT image to clean Windows Vista installation:

10 additional 3rd-party services

Clean IT0

20

40

24.746.1

Boot Timeseconds

Clean IT0

153045

25.6 30

Shutdown Timeseconds

Clean IT0%

4%

8%

1.01%6.04%

Idle CPU Utilization15 second trace

Clean IT0

20,000

40,000

10,19231,401

Disk Read Count15 second trace

Page 8: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Windows 7 Trigger-Start Services

Trigger-Start centralizes environmental detection logic

SCM registers for system events via interesting providers:

Device arrivalIP addressDomain join and leaveGroup policy updatesCustom ETW (Event Tracing for Windows) events

SCM starts or stops registered services

Page 9: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Some Trigger-Start Services In Windows 7

Service Name Description Trigger Type

AELookupSvc Processes application compatibility cache requests for applications as they are launched

Custom ETW

BDESVC Provides BitLocker client services for user interface and auto-unlocking of data volumes

Custom ETW

BTHSERV The Bluetooth service supports discovery and association of remote Bluetooth devices.

Device

SensorsMTPMonitor Monitors MTP (Media Transfer Protocol) sensors (such as a cell phone with a GPS receiver) to communicate sensor data to programs

Device

TabletInputService Enables Tablet PC pen and ink functionality Device

WinDefend Protection against spyware and potentially unwanted software

Group Policy

Page 10: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

demo

Page 11: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Consider Scheduled TasksTask Triggers Task Conditions

CalendarBootLogonIdleEvent log based entryWorkstation lockWorkstation unlock

Idle conditionStop when not idleAC power onlyStop on batteryWake computer from sleepSpecific or any network connection

Page 12: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Scheduled Task ExamplePower Efficiency Diagnostics

Windows 7 power problem analysisExecutes every 2 weeks when the system is idleRequires SYSTEM privilege to access NT Kernel Logger Saves report data for userUploads CEIP data to Microsoft

Task Scheduler(schedule)

Power Efficiency Diagnostics

(powercfg.exe)

Kernel

Detects Idle Condition

Launches Task

Page 13: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Performance and PowerPerformance is critical for background activity

Adds to the base footprint of the systemInterferes with foreground user activityResource utilization directly tied to Power Consumption

Target:Less than 2% CPU activity when the system is idleNo disk activity when the system is idle

Evaluate and Measure:Use XPerf (Windows Performance Tools Kit)

Page 14: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Battery Life

Time

Watt

s

0W - Off

Idle Power

Trade quality or performance for power savings

ExamplesIndex only high-priority itemsDisable animationsDVD playback at 30fps instead of 60fps

“Race to Sleep”Execute rapidly at high powerQuickly re-enter low-power stateExtend average idle duration

ExamplesTimer coalescing

Idle

Page 15: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Techniques

Consume Less CPUAvoid polling at all costs!

Poll no more often than once per secondUse Timer Coalescing

Page 16: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Timer Coalescing API

Specify a tolerance for expiration of the timerE.g., 1 second timer with 45 ms of toleranceTolerance should be at least 16ms, preferably 33msPeriod is not guaranteed

Timer will always expire within Period +/- Tolerance from the previous expiration

BOOLWINAPISetWaitableTimerEx( __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 );

DllImport("kernel32.dll")]static extern bool SetWaitableTimerEx( IntPtr hTimer, ref long lpDueTime, int lPeriod, TimerCompletionDelegate pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, IntPtr WakeContext, ulong TolerableDelay );

Page 17: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Energy Efficiency Best PracticesInvest in performance optimizations Reduce disk and CPU usage when the system is on battery powerDo not render to the display when it is offAvoid polling and spinning in tight loops Do not prevent the system from turning off the display or idling to sleepRespond to common power-management events such as system power source changesAvoid use of high-resolution periodic timers (< 10ms) as this reduces the efficiency of processor power-management technologies

Page 18: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Windows 7's Usage of the GPUContinues from Windows Vista…

Media Center UIVideo Playback Desktop Window Manager (DWM)

Windows 7 DWM uses Direct3D10.1 APIScales in performance all the way from low end integrated to high end GPUsShaders are used for blurs in the GlassWindows 7 memory consumption is cut by 50% per windowMore and richer animations of the thumbnails

Page 19: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Windows 7 DWM Memory Usage

Page 20: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Direct2D: New in Windows 7

Rendering Focused Immediate Mode API: 2D Vectors & Geometry, Bitmaps and TextHardware and Software Pipelines

Built for Performance on Direct3D 10.1Interoperable with Direct3D and GDIHigh Quality Rendering:

Per Primitive Anti-Aliasing and MSAA via Direct3D

Remoted via Direct3D 10.1Printing support via XPS

Page 21: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Direct2D Performancedemo

Page 22: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

DirectWrite: New in Windows 7

Modern typographyEnables world-wide applicationsClearType advancesWorks with any rendering technologyHardware accelerated via Direct2D

Page 23: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Gabriola

Page 24: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

DirectWritedemo

Page 25: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Windows Performance ToolkitEnables analysis for a broad range of issues including:

responsiveness issueslong delays in applicationsresource utilization issuesslow On/Off transitionspoor battery life

Wide support range cross platform: Vista, Server 2008, Windows 7cross architecture: x86, x64, and ia64

Based on the Windows ETW Infrastructureenables extensions which use ETW instrumentation to leverage tool setintrinsic support for Windows kernel eventsalso support for Windows Events

Publicly available for download todayStrategic ongoing investment to enable performance analysis on Windows

Page 26: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

XPerfdemo

Page 27: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Performance Best PracticesGeneral

Use the Windows Performance Toolkit to measure system performance during all scenarios (steady state and on/off transitions)Optimize application resource consumption (CPU and Disk) in both active and Idle statesPerform testing in a controlled way and make comparisons against a valid baseline

Obtain a baseline measurement on a system with as few system extensions as possibleAdd devices, applications, and services one at a time and test for any performance regressions

BootReduce application resource consumption post-bootAvoid using load order groups to express service dependenciesEnsure that all services report as running as soon as possible during boot to avoid blocking the Service Control Manager (SCM)Ensure that all non-essential services are converted to Demand or Trigger start in order to free up system resources during bootAvoid using managed code for services and applications on the startup path

Page 28: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Performance Best PracticesSleep/Hibernate

Avoid delays in processing the suspend notification (WM_POWERBROADCAST message)Verify that services do not opt in to receive suspend notifications unless absolutely requiredEnsure that all services respond quickly to resume events and minimize post resume CPU, disk and network usage

ShutdownEnsure that all services do not opt in to receive preshutdown and shutdown notifications unless absolutely requiredEnsure that all services that have opted to receive shutdown notifications respond quickly to the SCMEnsure that all applications respond quickly to shutdown notifications (WM_QUERYENDSESSION and WM_ENDSESSION messages)Reduce delays in the shutdown path of services and applications by minimizing CPU, disk and network activity in response to shutdown notifications

Page 29: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

ResourcesWindows Software Development Kit (SDK)

http://msdn.microsoft.com/en-us/windows/bb980924.aspx

Windows Performance Analysis Developer Center: http://msdn.microsoft.com/en-us/performance/default.aspx

Windows Performance Analysis forum: http://social.msdn.microsoft.com/Forums/en-US/wptk_v4/threads/

Event Tracing for Windows MSDN docs: http://msdn2.microsoft.com/en-us/library/aa363787.aspx

On/Off Transition Performance Analysis of Windows Vista: http://www.microsoft.com/whdc/system/sysperf/On-Off_Transition.mspx

Windows On/Off Transitions Solutions Guide: https://connect.microsoft.com/PartnerBeta/Downloads/DownloadDetails.aspx?DownloadID=17037

Battery Life Solutions Guide: http://www.microsoft.com/whdc/system/pnppwr/mobile_bat.mspx#

Windows Internals: “Windows Internals 4th edition” by Mark Russinovich and David Solomon

Page 30: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Track Resources→Want to find out which Windows Client sessions are best suited to help you in your deployment lifecycle? →Want to talk face-to-face with folks from the Windows Product Team?

Meet us today at the

Springboard Series Lounge, or visit us at www.microsoft.com/springboard

Springboard SeriesThe Springboard Series empowers you to select the right resources, at the right technical

level, at the right point in your Windows® Client adoption and management process. Come see why Springboard Series is your destination for Windows 7.

Page 31: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

Complete an evaluation on CommNet and enter to win!

Page 32: Kyle Marsh Principal Program Manager Microsoft Corporation WCL305

© 2009 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.