advanced windows presentation foundation application performance tuning and analysis

23
Advanced Windows Presentation Foundation Application Performance Tuning and Analysis Bart J.F. De Smet and Eric Harding Software Development Engineers Microsoft Corporation { bartde,erichar }@microsoft.com blogs.bartdesmet.net/ bart CL11

Upload: imala

Post on 23-Feb-2016

48 views

Category:

Documents


0 download

DESCRIPTION

CL11. Advanced Windows Presentation Foundation Application Performance Tuning and Analysis. Bart J.F. De Smet and Eric Harding Software Development Engineers Microsoft Corporation { bartde,erichar }@microsoft.com blogs.bartdesmet.net/ bart. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Advanced Windows Presentation Foundation Application Performance Tuning and AnalysisBart J.F. De Smet and Eric HardingSoftware Development EngineersMicrosoft Corporation

{bartde,erichar}@microsoft.comblogs.bartdesmet.net/bart

CL11

Page 2: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

> Unified presentation model for Windows applications, web applications, graphics/media/animation

> Integrated, vector-based compositing engine> Native support for advanced input> Support for declarative programming

Page 3: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

> Markup for Windows> Build applications in simple declarative statements> Easy to learn, write, and read

> Code and content are separate> Streamline collaboration between designers and

developers > Easy for tools to consume and generate

Button b1 = new Button();b1.Content = "OK";b1.Background = new SolidColorBrush(Colors.LightBlue);b1.Width = 100;

<Button Width="100px"> OK <Button.Background> LightBlue </Button.Background></Button>

Dim b1 As New Buttonb1.Content = "OK"b1.Background = New SolidColorBrush(Colors.LightBlue)b1.Width = 100

Page 4: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

WPF = Designer + Developer> Resource constraints> Drowning in effects> Excessive use of

images> “Rich” templates

> Loaded modules> Startup time> Memory leaks> Large element count

Composition = Power

Page 5: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Performance General TruthMeasure, measure, measure• Identify key scenarios and set clear goals• Start measuring early on representative hardware

Low hanging fruit• Let measurements be your guide• “Premature optimization is the root of all evil”

Perceived performance• Make it feel fast• “An art, not a science”

Trade-offs• CPU versus memory, etc• “To ship is to choose”

Page 6: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Fishb wlA sample by uxlabs@Microsoft> Dive into Facebook!

Fishbowl bringsFacebook to your desktop.> Stay Connected> View and Share Photos> Explore and Organize> Ready for Windows 7

> WPF 3.5 SP1 Application> www.fishbowlclient.com> www.codeplex.com/fishbowl

Page 7: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Fishbowl

Bart J.F. De SmetCasual Application Developer (CAD)Windows Presentation Foundation

demo

Page 8: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Taming Memory Usage

Eric HardingPerformance Guru (PG)Windows Presentation Foundation

demo

Page 9: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Performance Checklist

> Image size> Size in memory!

> Managed leaks> Allocation stack> (GC) root path

> Element count> Virtualization

Cold start

Warm start

Runtime

Memory

• Image size• Memory leaks• Element count

Page 10: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Cold Start

Eric HardingPerformance Guru (PG)Windows Presentation Foundation

demo

Page 11: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Performance Checklist

> All about disk I/O> Modules

> Need dependencies?

> Loaded at JIT time> Beware of inlining

> NGen> I/O versus CPU (JIT)> Better for warm

start

Cold start

Warm start

Runtime

Memory

• Disk I/O• Module loads• NGen

Page 12: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Warm Start

Eric HardingPerformance Guru (PG)Windows Presentation Foundation

demo

Page 13: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Performance Checklist

> All about CPU time> Avoid blocking

> Delay work if possible> Incremental loading

> Perception = key> Splash screen> Transition effects

Cold start

Warm start

Runtime

Memory

• Avoid blocking• Delay work• Perceived perf

Page 14: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Runtime

Eric HardingPerformance Guru (PG)Windows Presentation Foundation

demo

Page 15: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Performance Checklist

> IRTs> Effects, clips, opacity,

opacity mask> Bitmap effects (v3.x)

> Element count> Input and routed events

> In .NET 4.0> Cache composition

Cold start

Warm start

Runtime

Memory

• Excessive *.*• Beware of IRTs• Eventing

Page 16: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Runtime Best Practices> Don’t block the UI thread> Virtualize when needed

> UI virtualization> Data virtualization

> Freeze your freezables!> No change notification callbacks

> Hardware versus software> RDP, virtual machines, old hardware> RenderCapability.Tier> Reduce frame rate, animations, 3D

Page 17: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Lessons Learned• Excessive *.*• Beware of IRTs• Eventing

• Avoid blocking• Delay work• Perceived perf

• Disk I/O• Module loads• NGen

• Image size• Memory leaks• Element count

Composition + Measurement = PowerMemory Cold start Warm start Runtime

Page 18: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Resources> Windows SDK Perf Tools

> bing.com/search?q=windows+sdk> SysInternals tools

> www.sysinternals.com> SciTech .NET Memory Profiler

> www.memprofiler.com> WPF performance @ MSDN

> bing.com/search?q=wpf+performance+msdn> Performance Blogs

> WPF – blogs.msdn.com/jgoldb> .NET – blogs.msdn.com/ricom

Page 19: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Stay in Touch

> Come and see us @ Ask The Experts

> Mail us

Q & A

Page 20: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation

forms online atMicrosoftPDC.com

Page 21: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

Learn More On Channel 9> Expand your PDC experience through

Channel 9.

> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses.

channel9.msdn.com/learnBuilt by Developers for Developers….

Page 22: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis

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

Page 23: Advanced Windows Presentation Foundation Application Performance Tuning and Analysis