Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projections for content types with Taxonomy Field (performance issue) #8601

Open
mwentz opened this issue Jul 13, 2022 · 6 comments
Open

Projections for content types with Taxonomy Field (performance issue) #8601

mwentz opened this issue Jul 13, 2022 · 6 comments

Comments

@mwentz
Copy link

mwentz commented Jul 13, 2022

I have a content type with an attached shared part that consists of two Taxonomy fields (each taxonomy has 30-40 items). I created a query of all the items in this content type and added it as a projection element in a layout on a page. I'm seeing three specific places where it's causing slow loads:

  • When the projection element is saved it takes a number of seconds for the element dialog to close.
  • When the content item with the projection is saved/published it takes a very long time to publish and refresh.
  • The page loads very slowly. Even adding a number of the Orchard caching best practices, it's still significantly slower than the other pages on the site.

I have tried this with ~50 and ~140 content items in the projections, the more items I add the longer it takes (7-10 seconds for 50 and 28-34 seconds for 140) for the page to load.

I tried to use mini profiler to confirm exactly where the slowness is happening, but it's acting up on me and I can't get a good read. I tried removing the shared part with the two Taxonomy fields from the content type and I saw a large immediate improvement in performance that brought it back in line with other projections with more simple content types.

@mwentz
Copy link
Author

mwentz commented Jul 13, 2022

I came across this issue #8370 and tested out the related pull request #8371. This change resulted in a large performance improvement (down to 7-10 seconds for 140 content items). It looks like there might still be a performance problem with taxonomy fields on a content item in a projection and that it was being compounded by that other issue.

EDIT: On further testing I am not seeing these performance improvements. I must have been seeing some sort of caching, because further testing is back to 30+ second load times.

@MatteoPiovanelli-Laser
Copy link
Contributor

What version of Orchard are you running?

Just to make sure the problem is with how the projection is handled with the TaxonomyFields, did you test whether a contentItem that has a projection of those is just as slow as the one with the projection element? Just making sure the issue isn't somewhere with how layouts are interacting with the thing, because I don't use layouts much (or at all really).

If you were running 1.10.x, it would be useful, I think, if you could export the contents and their definition (as long as there is nothing sensitive or proprietary) to have a minimal case to test.

@MatteoPiovanelli-Laser
Copy link
Contributor

On the TaxonomyField side oth things, I recommend looking at how many times these lines are fired

var terms = _contentManager.GetMany<TermPart>(fieldTermRecordIds, VersionOptions.Published, queryHint);

var terms = _contentManager.GetMany<TermPart>(ids, VersionOptions.Published, queryHint)

Those may be ripe for optimization, but not trivial.

@mwentz
Copy link
Author

mwentz commented Jul 14, 2022

Thank you for looking at this, and my apologies for not including version number. The site is running Orchard 1.10.3.

I tested this projection as a Projection content type as well as a page with a projection widget and I am still seeing very large load times. Also note that in my first comment I said I saw a reduced load time with the change from another ticket. Since a couple first tests, I have not seen these improvements - I am seeing 30+ second load times in all cases.

Adding break points on those lines you mentioned I see the second point being hit about 200 times when loading about 80 content items.

@MatteoPiovanelli-Laser
Copy link
Contributor

foreach (var termContentItem in termsPart.TermParts) {

could you check whether it's going through there next?

I don't have a chance to recreate your conditions and test this, but from a quick browse through the code that stands out as a likely place where the Loader() method I highlighted earlier might be invoked.
If it's going there, you may wish to try and comment out the whole method that loop is in to see how that affects your performances. (getting rid of the method would really be the fix, but if we see a big improvement, if would point us in the right direction)

@mwentz
Copy link
Author

mwentz commented Jul 15, 2022

@MatteoPiovanelli-Laser I sanitized and simplified an export which I'm attaching (I changed the extension from .xml to .txt so that it could be uploaded). Steps to reproduce:

  • Import the recipe
  • Create a query for Content Types: BlogHowTo,BlogOurInsights,BlogYourStory
  • Create a Projection Page with the query

I'm seeing a page load of 10+ seconds in localhost.

blog-export.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants