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
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | layout-builder-check-enabled-3054042-13.patch | 732 bytes | berdir |
| Screen Shot 2019-05-10 at 1.05.17 PM.png | 286.71 KB | andyg5000 | |
| Screen Shot 2019-05-10 at 1.20.38 PM.png | 119.25 KB | andyg5000 | |
| Screen Shot 2019-05-10 at 1.49.00 PM.png | 88.01 KB | andyg5000 |
Comments
Comment #2
andyg5000Comment #3
andyg5000Adding Drupal 8.6.x performance metrics.
Comment #4
lendudeAny 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.
Comment #5
andyg5000Hey @lendude,
I'll try to replicate this in core and provide before/after profiles from blackfire. Thanks!
Comment #6
berdirI'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.
Comment #7
andyg5000Hey @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!
Comment #8
berdirYes, 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.
Comment #9
andyg5000Comment #10
andyg5000Sorry, 8.7.0 update is probably related to update failures.
Comment #11
catchTwo extra seconds makes this critical.
Comment #12
aaronmchaleTagging 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.
Comment #13
berdirOk, 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 :)
Comment #14
tim.plunkettPossibly a dupe of #3023220: Performance: Prevent extra Layout Builder code from running when rendering fields in isolation (Views results, FieldBlock, etc)?
Comment #15
berdirThat 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.
Comment #16
tim.plunkettDefault 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
Comment #18
tim.plunkettClosing as a dupe of #3023220: Performance: Prevent extra Layout Builder code from running when rendering fields in isolation (Views results, FieldBlock, etc), bumped that to critical
Comment #19
tim.plunkett