After updating the Drupal 8.7.1, I'm seeing a significant increase in page responses related to 1 views block on a page. The view is a list of commerce products that just load the title. However, it looks like every entity is being loaded, rendered, and then the title is pulled out.

Blackfire profile (see timeline):
https://blackfire.io/profiles/6003723c-795b-4ce1-893c-1efb28e154b3/graph

It also seems like the view is not getting cached (or using it) as every refresh produces the same result.

Views execution times:

Query build time 8.33 ms
Query execute time 7.63 ms
View render time 2719.56 ms

Views execution times in Drupal 8.6.7 (older environment with same view config)
Query build time 4.53 ms
Query execute time 10.71 ms
View render time 66.23 ms

Comments

andyg5000 created an issue. See original summary.

andyg5000’s picture

Issue summary: View changes
andyg5000’s picture

Issue summary: View changes

Adding Drupal 8.6.x performance metrics.

lendude’s picture

Any clear differences in Blackfire profiles between the two versions that you see? Have you seen any way to reproduce this with just Drupal core? The symptoms are pretty clear but its hard to start looking for a culprit with only the symptoms.

andyg5000’s picture

Hey @lendude,

I'll try to replicate this in core and provide before/after profiles from blackfire. Thanks!

berdir’s picture

Priority: Normal » Major

I'm pretty sure this is caused by layout builder, you either weren't using that in 8.6 or it changed things and is now much slower.

90% of the execution time is in Validator::validate(), which is called by Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay.

Maybe the view was already uncacheable before (which you should investigate and try to fix), or maybe that validation is causing it to be uncacheable, which is why it happens on every request.

The thing is that you/views is just displaying a single field with viewField(), so all that complicated logic and context matching that it is doing is pointless and should IMHO not run there. So for a field-based view, it might be a relatively easy fix, but I'm pretty sure that this is also a massive overhead for a regular layout-based entity rendering. validate() is an *extremely* slow thing (to the point that we might need to re-evaluate if the symfony validator is the right thing for us, I'm not sure) and it should not have to run on view, not a full validation anyway. I think I've seen a similar issue somewhere already.

andyg5000’s picture

Hey @berdir,

I was using it in 8.6, funny thing is... The page that was being profiled was not built with layout builder (others on the site are). I'll try to provide some more information asap. Thanks for taking a look!

berdir’s picture

Yes, the current page doesn't matter, the entities that are being displayed in the view matter. So if it's also not enabled for those products, then that might be the specific reason for the regression, that 8.7 is doing that preparation also when it is not enabled.

andyg5000’s picture

Issue tags: +8.7.0 update
andyg5000’s picture

Issue tags: -8.7.0 update

Sorry, 8.7.0 update is probably related to update failures.

catch’s picture

Priority: Major » Critical

Two extra seconds makes this critical.

aaronmchale’s picture

Tagging as related, I opened it earlier today after spending a some time doing some intensive debugging, @Berdir believes these two issues are related and I agree, it looks like they both might lead to the same root problem.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new732 bytes

Ok, this should help with calls coming through viewField() and \Drupal\views\Entity\Render\EntityFieldRenderer::buildFields(), looks like LayoutBuilderEntityViewDisplay doesn't itself check in buildMultiple() if it is enabled or not, the custom mode check already does existing in the method doing the check.

This will not address the bigger issue, but at least it will be limited to use cases that actually do use layer builder and not just having the module enabled :)

berdir’s picture

That does look very related yes, why are you only doing the custom check there though? Not sure if that would cover what \Drupal\views\Entity\Render\EntityFieldRenderer::buildFields is doing as it creates its own view display and doesn't specifiy a view mode. Not sure what the default value is then.

tim.plunkett’s picture

Default value is static::CUSTOM_MODE, so that should work just fine.
The above patch will fail tests, the one in the linked issue does not

Status: Needs review » Needs work

The last submitted patch, 13: layout-builder-check-enabled-3054042-13.patch, failed testing. View results

tim.plunkett’s picture

tim.plunkett’s picture

Status: Needs work » Closed (duplicate)