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
  • 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
  • Using the “EnableRedrawRegions” flag
    • How?
      • SilverlightHost host= Application.Current.Host;
      • host.Settings.EnableRedrawRegions = true;
  • 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
    • 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
    • Native Memory
      • XPerf native heap analysis
        • HeapMonitor.cmd makes it easier (Silverlight Performance Blog)
        • HeapMonitor.cmd –p %pid%
  • 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
    • 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

References

No Comments