Performance issues
Opened this issue · 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?
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:
umbraco-multi-url-picker/src/RJP.MultiUrlPicker/Models/Link.cs
Lines 162 to 201 in 7b139d4
Moving this within the if (_id.HasValue)
statement should be a big improvement, especially if you're using mostly external URLs.
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
I see a fix was merged into master recently -- will this be in a release soon?
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).