rasmusjp / umbraco-multi-url-picker

Multi Url Picker for Umbraco 7
MIT License
31 stars 29 forks source link

Performance issues #74

Open drpeck opened 6 years ago

drpeck commented 6 years ago

I've narrowed down a performance issue we're having with the url picker. When we request a Link, it's taking about 7ms to return the data. content.Link.FirstOrDefault(l => l.Url != null)

I presume the delay is either the result of the internal call to Link.InitPublishedContent or the deserialisation. 7ms in isolation might not seem much, but in our footer this code is called 30 times. In our header it's called 20 times. That's 350ms delay just from accessing content cached data. Can anything be done to speed this up?

ronaldbarendse commented 6 years ago

When accessing the Url property of a Link, it indeed first tries to get the IPublishedContent, but that should not be an expansive lookup if the Id and Udi are empty. It does however initialize a new UmbracoHelper for every lookup, even if it doesn't need it:

https://github.com/rasmusjp/umbraco-multi-url-picker/blob/7b139d4f47c365e18582c31a3910694bd1c0ddf0/src/RJP.MultiUrlPicker/Models/Link.cs#L162-L201

Moving this within the if (_id.HasValue) statement should be a big improvement, especially if you're using mostly external URLs.

ronaldbarendse commented 6 years ago

The _udi.ToPublishedContent(); has the same flaw BTW and is depreciated (probably because of this performance issue): https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Extensions/UdiExtensions.cs

alindgren commented 6 years ago

I see a fix was merged into master recently -- will this be in a release soon?

ronaldbarendse commented 6 years ago

I've added some more performance improvements in PR #81. Those could also be merged in before creating a new release (although some additional testing should be done first, just to be sure).