Problem/Motivation

As long as the module is installed, \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildMultiple() will run for every entity displayed on the site.
The concept of Layout Builder "being enabled" for a given view mode is actually determined by any number of plugins, only 2 of which are provided by core.

This presents a performance hit for cases where the entity is rendered multiple times, or when it is possible to know that no SectionStorage plugin is active.

Proposed resolution

Allow SectionStorage plugins to indicate that they are not relevant for a given entity display (entity type, bundle, and view mode).

Remaining tasks

Final review

User interface changes

N/A

API changes

New SupportAwareSectionStorageManagerInterface for section storage plugin managers with a notSupported method to determine if any section storage plugins support layout builder. SectionStorageManager implements this.
New SupportAwareSectionStorageInterface for section storage plugins with a isSupported method to determine if the section storage plugin supports layout builder. DefaultsSectionStorageInterface and SupportAwareSectionStorageInterface extend this.

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3060985

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Status: Active » Needs review
StatusFileSize
new794 bytes

Note, this is potentially also a performance issue. I did not benchmark it, but the site feels faster (again) after applying this patch.

I figured this is already handled in #3023220: Performance: Prevent extra Layout Builder code from running when rendering fields in isolation (Views results, FieldBlock, etc). Anyway, I'd agree with #3023220-15: Performance: Prevent extra Layout Builder code from running when rendering fields in isolation (Views results, FieldBlock, etc) - I do not see why this code should run when layout builder is not enabled for a certain view mode. I also fail to see how pluggable section storage relates to that, when it's disabled, why bother?

tim.plunkett’s picture

Because the checkbox that corresponds to that method is only for defaults. (And technically overrides, but only because of how they are tied to defaults).

Layout Library is an example of a module that ties into this pipeline regardless of that checkbox, and this change will break the test in place confirming its support.

This issue is a dupe of #2981889: Performance Degradation in Layout Builder and other places likely . But that one hasn't been rescoped since 3023220 has landed...

I think we need a hook or event or something in this pipeline here to allow custom/contrib code to more directly affect this without going down the context path (which leads to typed data, which is the performance culprit)

Also, CustomElementsLayoutBuilderEntityViewDisplay, wow that's interesting

Status: Needs review » Needs work

The last submitted patch, 2: 3060985.patch, failed testing. View results

fago’s picture

Thanks for the quick reply and clarifications!

>Also, CustomElementsLayoutBuilderEntityViewDisplay, wow that's interesting
:-) oh, yeah yet another module I forgot: https://www.drupal.org/project/custom_elements - however, this is not interfering with this code here, it just overrides the class used.

>Because the checkbox that corresponds to that method is only for defaults. (And technically overrides, but only because of how they are tied to defaults).
I see - but since the checkbox and method "isLayoutBuilderEnabled()" is there, it'S very confusing when this is not used for checking whethere it's enabled.

>Layout Library is an example of a module that ties into this pipeline regardless of that checkbox, and this change will break the test in place confirming its support.
I see, but couldn't it just be the contrib's job to cleanly enable the layout builder, without performance issue? e.g. it coudl just implement hook_entity_display_build_alter() and enable it when needed?

tedbow’s picture

StatusFileSize
new9.32 KB

Here is try at basically allow section storage to determine if a view mode for bundle is supported.

  1. \Drupal\layout_builder\SupportAwareSectionStorageInterface::isSupported() for section storage that implements this then they can tell if the bundle/view mode would be supported, not in use but supported. So defaults it would just check if the display is enabled.
  2. \Drupal\layout_builder\SectionStorage\SupportAwareSectionStorageManagerInterface::notSupported() choose instead of isSupported() on the manger level because we can't always know that.

    Basically it checks to make sure all storage type implement SupportAwareSectionStorageInterface if not return false because we can't know. Then it loops throw all storage types to find $type:isSupported() === TRUE if now support it then we know it is not supported.

    This allows us to not check contexts if we know it won't be supported

    foreach ($entities as $id => $entity) {
          if (($this->sectionStorageManager() instanceof SupportAwareSectionStorageManagerInterface && $this->sectionStorageManager()->notSupported($entity->getEntityTypeId(), $entity->bundle(), $this->mode))) {
            continue;
          }
          $build_list[$id]['_layout_builder'] = $this->buildSections($entity);
    
tedbow’s picture

Status: Needs work » Needs review
matt_paz’s picture

Just took a quick look through patch in #6. Not sure if it is worth cross-linking to #3008924 or not, but on the chance it might, I thought I'd cross link it just in case it helps think forward in cases like these.

fago’s picture

The approach in #6 looks good to me. However, I had troubles with using the patch due to LayoutBuilderEntityViewDisplay::load() calls in there. Since custom elements overrides teh entity class, it could not be found any more. Anyway, this should use dependency injected services - thus updated the patch accordingly. It seems to work good now.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim.plunkett’s picture

Version: 8.8.x-dev » 8.9.x-dev
Status: Needs review » Needs work
Issue tags: +Blocks-Layouts

Not currently passing tests.

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new9.39 KB

Here I have added a patch, lets wait for testbot response.

tim.plunkett’s picture

Status: Needs review » Needs work

Still not passing tests
@ravi.shankar next time please include an interdiff to show what changes you made

neslee canil pinto’s picture

StatusFileSize
new9.39 KB
new1.38 KB
tim.plunkett’s picture

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
@@ -99,13 +99,13 @@
-    $assert_session->waitForElementVisible('css', '.go', 9494949494949494);
...
+    $assert_session->waitForElementVisible('css', '.go', 9494949494949494);

Moving this won't help. Someone added that for local debugging and it needs to be removed. It timed out the bot.

neslee canil pinto’s picture

Status: Needs work » Needs review
StatusFileSize
new8.63 KB
new538 bytes

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim.plunkett’s picture

Title: Layout builder builds section even if disabled » Layout Builder attempts to builds section to determine if it is disabled
Priority: Major » Normal
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Performance

I've rewritten the issue summary.
I think the original bug report is similar to #3008943: Clean up todo in InlineBlockEntityOperations::handleEntityDelete()
Downgrading this because it should always be possible to run the code that is in HEAD, this would only be a performance improvement, not a true bug fix.
If benchmarking shows a significant improvement, this can go back to major.

  1. +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
    @@ -272,7 +273,12 @@ public function buildMultiple(array $entities) {
    +    /** @var  \Drupal\Core\Entity\EntityInterface $entity
    +     */
    

    Unnecessary

  2. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
    @@ -445,4 +447,31 @@ public function setContext($name, ComponentContextInterface $context) {
    +    $storage = $this->entityTypeManager->getStorage('entity_view_display');
    +    $display = $storage->load($id);
    +    if (empty($display)) {
    +      $display = $storage->load("$entity_type_id.$bundle.default");
    +      if (!$display) {
    +        return FALSE;
    +      }
    +    }
    +    $supported[$id] = $display->isLayoutBuilderEnabled();
    

    This should be replaced with $this->isLayoutBuilderEnabled() (which already exists on the class)

  3. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php
    @@ -438,4 +439,22 @@ public function isOverridden() {
    +    if ($view_mode !== 'default') {
    +      return FALSE;
    +    }
    

    Needs docs

  4. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php
    @@ -438,4 +439,22 @@ public function isOverridden() {
    +    $storage = $this->entityTypeManager->getStorage('entity_view_display');
    +    $display = $storage->load("$entity_type_id.$bundle.$view_mode");
    +    $supported[$id] = $display->isLayoutBuilderEnabled() && $display->isOverridable();
    

    This feels very wrong to include logic about the Defaults within the Overrides.

    This should instead use getDefaultSectionStorage() (which will require context be set up)

  5. +++ b/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php
    @@ -129,4 +130,26 @@ public function loadFromRoute($type, $value, $definition, $name, array $defaults
    +  public function notSupported($entity_type_id, $bundle, $view_mode) {
    ...
    +        return FALSE;
    ...
    +        return FALSE;
    ...
    +    return TRUE;
    

    False is good here and true is bad, which is odd. But I get why the choice was made. But each of these return values should be documented

  6. +++ b/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php
    @@ -129,4 +130,26 @@ public function loadFromRoute($type, $value, $definition, $name, array $defaults
    +    $storages = [];
    

    Elsewhere in this class, $plugin is used, to help differentiate between definitions and plugins

  7. +++ b/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php
    @@ -129,4 +130,26 @@ public function loadFromRoute($type, $value, $definition, $name, array $defaults
    +    foreach ($storage_types  as $storage_type) {
    

    Extra space

  8. +++ b/core/modules/layout_builder/src/SectionStorage/SupportAwareSectionStorageManagerInterface.php
    @@ -0,0 +1,21 @@
    + * Interface for section manager that knows whether it supports view modes.
    + */
    +interface SupportAwareSectionStorageManagerInterface extends SectionStorageManagerInterface {
    
    +++ b/core/modules/layout_builder/src/SupportAwareSectionStorageInterface.php
    @@ -0,0 +1,11 @@
    + * Interface for section storage that knows whether it supports a view mode.
    + */
    +interface SupportAwareSectionStorageInterface extends SectionStorageInterface {
    

    I have to read the implementation to understand what these interfaces are for.

  9. +++ b/core/modules/layout_builder/src/SectionStorage/SupportAwareSectionStorageManagerInterface.php
    @@ -0,0 +1,21 @@
    +   * Whether a view mode is not support by any storage.
    +   *
    +   * @param $entity_type_id
    +   * @param $bundle
    +   * @param $view_mode
    +   *
    +   * @return bool
    +   */
    

    Incomplete docblock

acbramley’s picture

Found this issue while investigating performance issues with Diff module's visual_inline diff. After profiling with Blackfire it showed 23,400 calls to Drupal\Core\Plugin\Context\ContextDefinition::isSatisfiedBy via buildSections.

This patch dropped the page load time of a particularly large revision diff (Node with ~100 paragraphs) from roughly 21 seconds uncached to 16 seconds uncached.

Unfortunately Blackfire's profiling time seems to be off locally as it's reporting the exact same time pre and post patch (and even with caches warmed).

There is certainly a huge performance benefit with this patch though, even just by looking at the page load time via Chrome dev tools.

I will work on the review above and post a new patch soon.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new9.1 KB
new5.48 KB
  1. Removed
  2. Fixed
  3. Added
  4. Still TODO - unsure what this change would look like
  5. Added
  6. Changed to $plugins
  7. Fixed
  8. Not sure what needs to change here. I agree the naming of classes and functions could be clearer.
  9. Fixed

Over to NR to see if the docs and what not are OK and get feedback on 4.

acbramley’s picture

+++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
@@ -462,15 +462,7 @@
-    $storage = $this->entityTypeManager->getStorage('entity_view_display');
-    $display = $storage->load($id);
-    if (empty($display)) {
-      $display = $storage->load("$entity_type_id.$bundle.default");
-      if (!$display) {
-        return FALSE;
-      }
-    }
-    $supported[$id] = $display->isLayoutBuilderEnabled();
+    $supported[$id] = $this->isLayoutBuilderEnabled();

This change breaks things with the following exception:

Drupal\Component\Plugin\Exception\ContextException: The 'entity:entity_view_display' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue() (line 73 of core/lib/Drupal/Core/Plugin/Context/Context.php).
tim.plunkett’s picture

$this->isLayoutBuilderEnabled() is being called on a bare plugin (one created via SectionStorageManagerInterface::loadEmpty(). It doesn't have the context applied, so it can't introspect that. Which is the whole point, as this is when contexts are being determined.

Perhaps there's a middle ground here. Instead of adding static caching AND a whole new paradigm to checking these plugins before instantiating them, why not start with some static caching?

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

arakwar’s picture

Just adding some info about this issue :

We'in investiguating performance issues on our side, and seeing that the buildSections() is called for every entity in a menu or a view seems to slows down our site by a lot.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kim.pepper’s picture

Issue tags: +#pnx-sprint

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

StatusFileSize
new9.35 KB

Re-rolled #21 but reverted #19.2 for now until I have time to re-visit.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

StatusFileSize
new9.58 KB
new1.12 KB

Reroll #29 against 9.5.x and added some defense for OverridesSectionStorage::isSupported.

kim.pepper’s picture

+++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
@@ -407,4 +409,31 @@ public function setContext($name, ComponentContextInterface $context) {
+    if ($bundle) {
...
+    }

I feel like this could be its own function, e.g. getSectionId()?

akram khan’s picture

StatusFileSize
new11.44 KB
new3.77 KB

Added patch fixed CCf #33

akram khan’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

As a bug this will need a test case showing the issue.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Rerolled onto an MR and fixed up a few typing/code style things.

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Rebased, fixed some minor issues, and added test coverage.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems already been reviewed and feedback has been addressed. Didn't see anything additional.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Agreed with @kimpepper's feedback on the MR. Didn't do an in-depth review of everything.

acbramley’s picture

Status: Needs work » Needs review

Much nicer solution, thanks for the links. I didn't see any decisions on #3047289: Standardize how we implement in-memory caches with how these memory cache services should be setup wrt. service id names or how specific/generic they should be but I've loosely tried to follow what other things are doing in core already with cache.asset_memory and system.module_admin_links_memory_cache

acbramley’s picture

I've tried passing the display's cache tags into the set() call so, in theory, it should be invalidated automatically when the display is saved but that doesn't seem to be the case. Must be missing something?

EDIT: I guess this is why, ConfigEntityBase only invalidates list cache tags on save

  protected function invalidateTagsOnSave($update) {
    Cache::invalidateTags($this->getListCacheTagsToInvalidate());
  }

Whereas EntityBase invalidates both list tags and the entity's specific tag.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

dcam made their first commit to this issue’s fork.

dcam’s picture

Status: Needs work » Needs review

Rebased MR 7340

danielveza’s picture

Status: Needs review » Reviewed & tested by the community

This has gone through multiple rounds of review, all threads have been resolved. I think it's ready to be RTBC.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

oily made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Reviewed & tested by the community

@oily thank you for rebasing many of my issues, it would be great if you could also ensure tests pass and follow up any failures in the future.

ironnuts’s picture

@acbramley I am sure it would.

acbramley’s picture

@oily I don't appreciate the snark mate. I'm just trying to give some advice.

I've seen you rebasing issues a lot over the past few days, some of which didn't need rebasing. If you're trying to help move an issue along and gain credit, doing unnecessary rebases is listed under Examples of what will usually not receive credit on https://www.drupal.org/about/core/policies/maintainers/how-credit-is-gra....

This one did have a conflict in OpenTelemetryNodePagePerformanceTest, which it seems like you fixed, but then the fix failed tests.

ironnuts’s picture

You were dressing up with a thin veneer of politeness impudent and unwelcome advice. Now that the veneer is removed. And you try to discredit my contributions and my professional image in front of a potentially wide audience. I have no problem with the rules.

tim.plunkett’s picture

@oily except that @acbramley's advice here is appreciated and welcomed, and correct.

ironnuts’s picture

@tim.plunkett Not interested in your opinion on working relations between @acbramley and myself.

ironnuts’s picture

RE: #54 'This one did have a conflict in OpenTelemetryNodePagePerformanceTest, which it seems like you fixed, but then the fix failed tests.'

I do not know how to fix the tests. Anything wrong with that?

I tried to resolve a merge conflict in this issue. Anything wrong with that?

If people want to build a list of black marks against my contributions please do review my Rebases over the last 24 hours. I believe they were nearly all 90+ commits behind 11.x when I merged. A few slipped through which were < 90 but of those one or two had merge conflicts which I tried to fix. The reason why I tried to rebase 90+'s is because I saw @smustgrave do it recently and assumed without consulting the rules that that would be a safe figure, since I regard him as a stickler for the rules.

In any case I imagine core maintainers are aware of the rules and they will award credit accordingly.

volkswagenchick’s picture

It seems that emotions in this discussion may be escalating, which can lead to misunderstandings and unproductive exchanges. To ensure that all participants are heard and respected, we encourage a brief pause from the conversation to gain perspective. It's essential that every member of the community feels valued and respected during collaboration.

In our community, we strive to be constructively honest and relentlessly optimistic. This means taking the time to understand decisions and the reasoning behind them before expressing disagreement. We ask that you suspend judgment and actively listen, asking questions and engaging with openness. Please be mindful of the tone and impact of your comments, as even well-intended messages can be misinterpreted.

If you need support navigating this discussion, the Drupal community offers resources for conflict resolution. We encourage you to take advantage of these tools to maintain a positive and productive dialogue.

For more information, please refer to Drupal’s Values and Principles of be constructively honest, and relentlessly optimistic and Drupal’s Values and Principles of seeking first to understand, then to be understood. Additionally, there are resources offered by the Drupal community to aid conflict resolution should those be needed.

This reminder is provided by the Drupal Community Health Team as part of an initiative to foster positive discourse. For more information, please visit https://www.drupal.org/project/drupal_cwg/issues/3129687.

acbramley’s picture

@oily I think you've misunderstood where I'm coming from here.

I do not know how to fix the tests. Anything wrong with that?

No there's not, I'm happy to help if you would like to understand that more.

I tried to resolve a merge conflict in this issue. Anything wrong with that?

Of course not, I was referring to the issues that did not have conflicts.

If people want to build a list of black marks against my contributions

Nobody is doing that.

I believe they were nearly all 90+ commits behind 11.x when I merged.

This is what I was trying to explain, there is no need to rebase random issues that are X commits behind HEAD. As I understand it, you are looking for issues to work on to gain credits, that's fine, but rebasing issues will not achieve a credit. I rebase issues that I am working on myself when I come back to them and they are behind, there is no reason for me to go searching for issues to click the rebase button on, that is just wasted effort.

I would really recommend you find something that you are interested in working on, either specific issues or a specific subsystem, and try to contribute in other, more valuable ways. If you give me an idea on what you are interested in then I can try to find some issues that may suit. For example you've mentioned a few times that you don't know how to write tests, we could look for some issues with the Needs tests tag and go through how to write a test for them.

ironnuts’s picture

#59 "..To ensure that all participants are heard and respected, we encourage a brief pause from the conversation to gain perspective.."

So why #60?

Which states, among other things, "For example you've mentioned a few times that you don't know how to write tests."

That is untrue. I have never said that. The fact is, I have created a number of tests and been credited for them. Nor have I ever said I can fix any test whatever test it be. I DID say I was unable to fix a particular test/ set of tests, the 'opentelemetry' or opentelemetry-related tests.

#60 makes other incorrect assumptions and is not welcome in any case because it followed #59.

I am following #59, which I regard as good advice. I hope the others involved do the same.

ironnuts’s picture

Changing to needs work after creating a review of the code. A couple of perhaps nitty suggestions on code comments. I have given alternative wordings so the 'work' required is to accept my alternative wordings of the comments, to ignore them or to vary them as seen fit. I did review all the code itself in most of the MR files but did not see anything even to be nitty about though my local env is not well set up yet and without being able to apply xdebug etc deep analysis is harder.

Regarding my comment suggestions, PHP.net speaks about 'objects' 'implementing' interfaces. We know that classes implement interfaces but on PHP.net it is cool to say objects do it too..

ironnuts’s picture

Status: Reviewed & tested by the community » Needs work
acbramley’s picture

Status: Needs work » Reviewed & tested by the community

I don't agree with the suggestion on the added interface, the other one is for existing documentation so needs a separate issue.

ironnuts’s picture

Re: #64 and "I don't agree with the suggestion on the added interface.." Can you please explain why. Please reference the comments I have made. A reasoned response is much appreciated.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Left some comments on the MR
I realise both @kim.pepper and @catch agreed that using memory cache over static cache was preferred, but given we already have a memory cache for entities and the isLayoutBuilderEnabled call is fairly light weight, I'm not sure whether we're doing premature optimisation here at the cost of added complexity.

It would be good to see what impact just using the existing memory cache has

larowlan’s picture

@acbramley pointed out that the choice of notSupported vs isSupported was mentioned in #6, so feel to disregard that feedback - I don't feel that strongly about it

acbramley’s picture

Status: Needs work » Needs review

All feedback has been addressed, thanks for the review @larowlan

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

dcam’s picture

Status: Needs work » Needs review

Rebased

ironnuts’s picture

Title: Layout Builder attempts to builds section to determine if it is disabled » Layout Builder performs redundant operations on disabled section plugins that only need to be performed on enabled sections
ironnuts’s picture

Title: Layout Builder performs redundant operations on disabled section plugins that only need to be performed on enabled sections » Layout Builder performs redundant operations on disabled section plugins only needed for enabled section plugins
ironnuts’s picture

Attempt to simplify the title after reading through the comments.

ironnuts’s picture

Although the IS mentions sort of 'knock-on' effects of the main issue, might help to distinguish which of those 'knock-on's' getting 'knocked on the head' by this issue. Are there any follow-ups required or is this a 'catch-all'?

ironnuts’s picture

Title: Layout Builder performs redundant operations on disabled section plugins only needed for enabled section plugins » Layout Builder performs redundant operations due to failure to receive accurate report of status of view modes and section plugins
ironnuts’s picture

Title: Layout Builder performs redundant operations due to failure to receive accurate report of status of view modes and section plugins » Layout Builder performs redundant operations due to failure of communication between LB, view modes and section plugins
acbramley’s picture

Title: Layout Builder performs redundant operations due to failure of communication between LB, view modes and section plugins » Layout Builder attempts to builds sections to determine if it is disabled
Issue summary: View changes

I think the previous title was a bit more succinct in what we're fixing here.

The "knock on" effects are exactly what we're fixing here, the performance benefits of simply not attempting to build any sections if layout builder is not enabled are the fix.

I've updated the IS a bit.

ironnuts’s picture

@acbramley Okay. I should have said 'knock-on' effects described in comments #1 - #7 involving 'contrib' modules and various hooks. Perhaps those comments are not relevant now? They date from 2019. Or are they addressed in the MR? Also, is a CR required? e.g. for creators of new contrib modules of a kind that might cause the performance hit described in the IS?

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

Status: Needs work » Needs review
ironnuts’s picture

Fix merge conflict in MR !7340.

godotislate’s picture

Have a couple of questions on the MR.

I was also wondering that since the notSupported()/isSupported() are only called from LayoutBuilderEntiyViewDisplay::buildMultiple(), that the arguments to those methods should be notSupported(EntityViewDisplayInterface $display) and isSupported(EntityViewDisplayInterface $display) instead, since we already have the display entity loaded (as $this). This would save loading the display entity again, since entity view display entities are not statically cached.

If the expectation is that these methods might be called other places (in contrib/custom code) where the display has not been loaded, then it's fine.

danielveza’s picture

Status: Needs review » Reviewed & tested by the community

This has gone through multiple rounds of reviews, we have passing tests.

I've given it one last sweep and it looks good, lets try get this in to save @acbramleys sanity from needing to reroll this one every couple of days when the performance metrics cause a merge conflict.

  • catch committed 519f9a10 on 11.3.x
    fix: #3060985 Layout Builder attempts to builds sections to determine if...

  • catch committed cc44d665 on 11.x
    fix: #3060985 Layout Builder attempts to builds sections to determine if...
catch’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Had similar questions to @larowlan about the ::isNotSupported() but then also went back all the way to #6 and didn't really have better ideas. This is all pretty internal to layout builder and doubt much other code will be interacting with it.

Committed/pushed to 11.x and cherry-picked to 11.3.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

ironnuts’s picture

No credit despite at least #87. Seems I upset the drupal.org 'mafia' on this issue? : )

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.