Performance issue on Block type admin page

Created on 19 May 2023, about 1 year ago

Problem/Motivation

There is a performance problem I spotted with Block type admin page (/admin/structure/block/block-content/types). Profiling this page shows that significant time is taken by the Entity operations links' access check and in particular the "Manage permissions" link for every block type. Internally it is calling the access() method of the EntityPermissionsForm, which calls permissionsByProvider(). The latter loops through all the dependent configurations and site permissions and compares them to see if there's a match and returns them. This takes a lot of time and resources, especially when you have many custom block types and permissions.

Testing with ~2000 permissions and 50 block types gives around 40 sec to load this page
Simply removing the call to permissionsByProvider() is reducing the page load to 1.5sec.

Steps to reproduce

You will need Drupal website with 50 custom block types and good amount of enabled modules (to have lot of permission options)

Proposed resolution

There are different ways to approach this. The simplest one seems to remove the "Manage permissions" at all from the Entity operations links on the Block types overview page, as accessing every block type's own page inside has this tab available.

Other options might be to implement some caching mechanism or refactor the business logic.

EDIT: I found that this is actually documented here https://www.drupal.org/node/3242827
So I assume in our case we have to just switch from EntityPermissionsRouteProviderWithCheck to EntityPermissionsRouteProvider route provider permission handler. But still I don't see why by default is not like that?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: duplicate

Version

9.5

Component
Block content 

Last updated 4 days ago

Created by

🇧🇬Bulgaria yivanov

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024