Upload
roberta-cobb
View
227
Download
0
Tags:
Embed Size (px)
Citation preview
Focus on Fundamentals in Windows Applications (Graphics, Power, Services, Profiling) Kyle Marsh
Principal Program ManagerMicrosoft CorporationWCL305
Agenda
Background ActivityServicesTasks
PowerGraphicsIntuitive UIWindows Performance Toolkit
Fundamentals
MemoryReference set, Graphics
Disk I/ORegistry Reads, Indexer
PowerDVD Playback, Panel, Timers
SpeedFaster Boot, Device Ready
ResponsivenessStart menu, Taskbar
Scale256 cores
IncreaseDecrease
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
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
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
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
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
demo
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
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
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)
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
Techniques
Consume Less CPUAvoid polling at all costs!
Poll no more often than once per secondUse Timer Coalescing
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 );
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
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
Windows 7 DWM Memory Usage
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
Direct2D Performancedemo
DirectWrite: New in Windows 7
Modern typographyEnables world-wide applicationsClearType advancesWorks with any rendering technologyHardware accelerated via Direct2D
Gabriola
DirectWritedemo
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
XPerfdemo
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
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
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
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.
Complete an evaluation on CommNet and enter to win!
© 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.