umbraco-multi-url-picker icon indicating copy to clipboard operation
umbraco-multi-url-picker copied to clipboard

Performance issues

Open drpeck opened this issue 7 years ago • 4 comments

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?

drpeck avatar Mar 06 '18 10:03 drpeck

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 avatar Apr 10 '18 22:04 ronaldbarendse

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

ronaldbarendse avatar Apr 10 '18 22:04 ronaldbarendse

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

alindgren avatar Jul 01 '18 05:07 alindgren

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).

ronaldbarendse avatar Jul 02 '18 22:07 ronaldbarendse