Avoid having default values in XAML to do less during Load.
I worked with a part of the VS2010 team recently to improve XamlReader.Load performance for an important scenario. It was taking 120ms to load a XAML file and create the objects that it specified. It seemed like the XAML was a bit verbose, so I wrote a quick tool to analyze the types, properties and values used. Digging in, I was able to see that many properties were set on every instance of that type, and usually to that same value. That was a clue that the DefaultValueAttribute of many of the properties was not set appropriately.
A few days later, I heard of 2 improvements that helped perf of this scenario (measured in warm start scenarios, I believe):
- moving to the System.Xaml.dll engine improved this scenario from 120ms to 72ms
- fixing the default values, and thus loading a smaller XAML file, took it down from 72ms to 38ms
We will still try to help them reduce the time more, but we’re really happy with the progress so far. It is also exciting to see VS adopting XAML in their UI and for several other scenarios as well.
We’re really happy of our current XAML to Object performance of the new XAML stack…we continue to profile many scenarios and figure out other ways to get more speed. Our BAML to Object performance right now isn’t where we need it, so we are actually investing more optimization/profiling time there right now…
Getting the XAML Analysis Tool
The tool I wrote uses System.Xaml.dll, so I won’t ship it yet…but I’ll provide my little utility as it may help others understand how their XAML Vocabulary can be improved.