Performance improvements in the PropertyDataCollection

February 12, 2015

When we took a look at what performance improvements that we could make to the EPiServer CMS platform there was one thing that stood out like a sore thumb, namely the PropertyDataCollection.

The main problem was how it’s base class, NameObjectCollectionBase, was handling retrieval of items in the collection in a multi-threaded scenario. As it happens to be, this scenario is one of the most commonly used on an EPiServer CMS site, since this is performed every time a content property is accessed. When profiling sites this often ended up as one of the code paths where most of the time was spent, in the case of some of the pages on the Alloy example site it turned out to be almost 20% of the total time spent rendering the page.

Changing the base

Our solution to this issue was to refactor the PropertyDataCollection to no longer inherit from NameObjectCollectionBase but instead implement IList<PropertyData> and IList explicitly using a combined List<PropertyData> and Dictionary<string,PropertyData> internally to store the values. This change provided us with the best results without causing too much disruption in a part of the code with relatively high usage.

The outcome

So what performance improvements can we expect from this change? Well, in our test scenarios we managed to make property retrieval 4 times faster on average, with improvements spanning from twice as fast to 10 times as fast depending on how many properties the collection contained and how many threads that was trying to access the collection at once. A new profiling session also revealed that the PropertyDataCollection no longer featured in any of the hottest paths when rendering pages in the Alloy site.

As it happens, another positive side effect came with this change as well. When testing the memory usage of a site, we observed roughly a 10% decrease in the total memory footprint used by a site that was directly relative to the number of pages on that site.

As always your mileage might vary when it comes to performance improvements, so please run your own tests to learn what improvements you can expect in your particular solution. Please feel free to share your individual results in the comments section.

When can we expect this improvement?

As we needed to replace the base class to get around this problem, it meant that this change could only be done as a part of a new major version update. This means that the refactored version of the PropertyDataCollection is only available in version 8 or later of the EPiServer.CmsCore package and that it unfortunately cannot be backported to any older versions. A pre-release version of CMS 8 is currently available in the EPiServer Nuget feed for those of you who want to give it a try.

Other breaking changes

Please note that we beside the change of base class also took the opportunity to correct a few other quirks in the previous implementation. We don’t expect these to cause any issues, but please consult the breaking changes document on EPiServer World if you are experience any issues.

One Response to “Performance improvements in the PropertyDataCollection”

  1. Erik Henningson Says:

    Nice! We just upgraded a small, low-traffic site, and memory consumption went down 9 percent.

Comments are closed.

%d bloggers like this: