MIX11 - Session Review - Silverlight Performance Tips
Michael Cook ( Developer on Silverlight Performance )
- Ideology
- Develop a performance culture in your group
- Test throughout your product cycle
- Automate your performance Tests
- Use your customer’s target hardware
- Performance is a feature, treat it like one!
- Spec
- Schedule
- Sign-off
- Develop a performance culture in your group
- Profiling with Visual Studio 2010
- Sampled profiling (Available for Silverlight in the SP1 of VS2010)
- Collects statistics about program execution
- Identifies execution bottlenecks
- Low overhead
- Available on VS2010 Premium and Professional
- If you don’t have it just use the WIndows Performance Toolkit (XPerf) – Free
- Collects statistics about program execution
- Sampled profiling (Available for Silverlight in the SP1 of VS2010)
- Using the “EnableRedrawRegions” flag
- How?
- SilverlightHost host= Application.Current.Host;
- host.Settings.EnableRedrawRegions = true;
- How?
- Analyzing memory usage
- What is memory profiling?
- Analysis of the working set of an application
- Careful, the terminology is confusing
- VMMap.chm is a good authority for defining memory related terms
- What is working set?
- represents the amount of committed virtual memory that is physical memory and owned by the process
- Most developers only look at “private”
- Getting Started
- VMMap
- Great tool for getting 30.000 ft view of what’s going on in your app memory footprint
- VMMap
- Managed Memory
- WinDbg + Son of Strike (SOS) extension
- Debugger extension for WinDbg
- Allow you to inspect the live managed heap in an application
- Some commands for quick reference
- !loadby sos coreclr
- !dumpheap –stat
- !dumpheap –type <typename>
- !dumpheap –mt <metertag>
- !gcroot <address>
- !do <address>
- Third-party Memory Profilers are also interesting
- WinDbg + Son of Strike (SOS) extension
- Native Memory
- XPerf native heap analysis
- HeapMonitor.cmd makes it easier (Silverlight Performance Blog)
- HeapMonitor.cmd –p %pid%
- XPerf native heap analysis
- What is memory profiling?
- General Tips & Tricks
- Improve Startup
- The cardinal rule
- Do the absolute minimum required to display your main screen
- Methods
- Simplify your XAML
- Load less data and/or load data asynchronously
- Reduce your XAP download size
- Time Heuer’s “Loading Dynamic XAPs and Assemblies”
- Use a splash screen if needed
- The cardinal rule
- Improve runtime performance
- Reduce the complexity of the visual tree
- Update only what is necessary on the screen
- Use “EnableRedrawRegions”
- Avoid updating elements with effects applied (eg. Shader Effects)
- Leverage GPU acceleration and cached composition
- Use BackgroundWorker for long running operations
- Improve Startup
References
- Silverlight Performance Blog: http://blogs.msdn.com/b/slperf
- Visual Studio Profiler Blog: http://blogs.msdn.com/b/profiler
- VMMap: http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx
- WinDbg + SOS (Debugging Tools for Windows):
- XPerf (Windows Performance Toolkit)
- Silverlight Performance Spy (Silverlight Spy)