Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293752

Performance regression caused by using the last installed entity definitions

$
0
0

Problem/Motivation

#2554235: Make the content entity storage and entity query use the last installed definitions instead of the ones living in code has resulted in a performance regression in 8.7.x and above. And it gets worse with the path alias move to entities.

For example if you have the history module enabled the post to history/NODE_ID/read is now doing 4 additional queries to the key_value table because we're retrieving the entity definitions for user and node. On 8.6.x we didn't retrieve these definitions at all. These same 4 queries are seen on the post to quickedit/metadata when viewing a node whilst logged in. And there are an additional 2 queries caused by the entity definition change during a user login.

Another thing that's seems problematic about #2554235: Make the content entity storage and entity query use the last installed definitions instead of the ones living in code is that we pass the EntityType object from code into \Drupal\Core\Entity\Sql\SqlContentEntityStorage::__construct() and then do...
parent::__construct($entity_type, $entity_field_manager, $cache, $memory_cache, $entity_type_bundle_info); which uses the passed in entity type to set some defaults. We then later do:

    $this->entityType = $this->entityTypeManager->getActiveDefinition($entity_type->id());
    $this->fieldStorageDefinitions = $this->entityFieldManager->getActiveFieldStorageDefinitions($entity_type->id());

It's these two calls that a responsible for an additional 2 queries to the key_value table (and this happens per entity type). For me there are two problems here... the additional queries but also the use of the potentially different info in the call to the parent constructor.

Proposed resolution

TBD. I created https://github.com/alexpott/prefetch_key_value to see if we could prefetch things. It makes some improvement but there we still be 1 additional query on all the above mentioned requests. And potentially if you have non-optimised entity definitions then it could be more.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>