advanced-cms / advanced-reviews

This is an Open Source add-on that improves the reviewing process and lets external users to view & review content items or whole projects without the need to access the Edit Mode. Created and maintained by Bartosz Sekuła and Grzegorz Wiecheć
Apache License 2.0
17 stars 15 forks source link

Preview link performance #235

Closed elivnjak closed 1 year ago

elivnjak commented 1 year ago

Optimizely : 12.19 Advanced Reviews : 1.3.5

I am having issues with the performance of the preview links. When I try to open the page it seems to hang trying to load the page. There are no error messages. I have tried to debug by remove all the header and footer code. Having a simple page with just a text block on it. This does load the page but it takes over 10 seconds to load.

I have a feeling it has to do with the size of our website. Meaning we have a lot of pages, blocks and documents.

We copied the architecture of the Sample Alloy website so i dont think it's related to our code. Testing the sample Alloy site works fine for me, but then again that site is quite small.

barteksekula commented 1 year ago

Strange, it should not make a big difference between regular page load and page load inside unpublished preview. Can you run any kind of tracking and share the results?

elivnjak commented 1 year ago

So I've had more time to try to debug this issue. I have narrowed the bottle neck to two places within the code.

  1. Advanced.CMS.ExternalReviews\ReviewLinksRepository\ExternalReviewLinksRepository.cs return GetStore().Items<ExternalReviewLinkDds>().FirstOrDefault(x => x.Token == token);

  2. Advanced.CMS.ExternalReviews\ContentExtensions.cs var writable = page.CreateWritableClone();

Because it's hooking into the "LoadingContent" event, both these lines of code are called 349 times when loaded a single external preview link. It appears it's run for each link thats on the page, so that includes main nav and footer links. (Also seems to run twice for each link). Which means the more links on a page the slower the code is. Currently it takes about 4 minutes to load a page.

I was hoping you could provide some suggestions as to how we can resolve it?

samuelthomson62 commented 1 year ago

Having a similar issue on EPiServer.CMS v12.22.2. Takes around 30 seconds for an external reviews link to load a page .

barteksekula commented 1 year ago

It took a while but I finally found some time. @elivnjak I think the issue is with ExternalReviewLinksRepository.cs - if that is the actual problem then it should be much better if you upgrade to 1.3.6 Please let me know if you still have problems. The call to page.CreateWritableClone does not seem to be problematic because there is not i/o, at least it seems so. The first point you mentioned seems like an obvious easy fix, so let's try this first, if not I will profile a bit myself on our test sites.

Pinkesh-Jain commented 3 months ago

I upgraded to version 1.3.6, but the preview links still take about a minute to load. We typically have around 130 links per page. Do you have any suggestions or fixes to reduce the loading time?