Problem/Motivation

I noticed that on some pages which had a lot of entities using domain access, my site was taking a huge performance hit. As a result, the site was slowed to a crawl. I investigated this using blackfire, and determined that among other issues, the call to the database were slowing the site down. One case was checking the router_rebuild lock on every call to domain_entity_query_alter() creates a database query. Instead of checking this every time it makes sense to only check the lock when we are actually checking access for an entity type which is enabled for domain access, since that data is complied on the first run, and cached statically.

TBH I'm slightly unsure if the lock check is entirely necessary, but from the code, its not entirely clear what the motivation was for adding it, so I don't think removing it makes sense.

Steps to reproduce

Enable domain access for menu items (menu_link_content), and reload the page as an admin. The site should slow down significantly. (In order to actually enable domain access on menu items, special work is required to inject the field into the edit ui. But this isn't required for this module.)

Proposed resolution

Move the call to the lock check so its made only when necessary (once we know the query is for a domain access controlled entity type) in order to not waste time with the query.

Remaining tasks

Merge the fix.

User interface changes

None.

API changes

None.

Data model changes

None.

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

richgerdes created an issue. See original summary.

richgerdes’s picture

Status: Active » Needs review

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

  • delta committed d9dddf5 on 8.x-1.x authored by richgerdes
    Issue #3249712 by richgerdes: Checking the route_rebuild lock has a huge...
delta’s picture

Status: Needs review » Fixed
delta’s picture

Status: Fixed » Closed (fixed)

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