Problem/Motivation
Found via #3537863: Optimize field module's hook_entity_bundle_info() implementation and roughly a similar problem.
When building bundle field definitions, we look for base field overrides for every bundle of every entity type. Some sites have several hundred bundles (custom blocks, paragraphs, webforms etc) and most sites have dozens.
However most sites only have a handful of base field overrides for one or two entity bundles.
This means we issue somewhere between dozens and several hundred entity queries during cache rebuilds, where 90-99% of them will return no results.
Instead, we can load all the base field overrides in one go, and static cache them on the class, then when we build the bundle field definitions, check that instead.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3538006
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
Comment #3
catchComment #4
catchIt looks like there might be some variation in performance tests after this change, will probably need some debugging, but even with the variation there's an obvious measurable improvement.
Comment #5
catchRebased and fixed a couple of tests.
Comment #6
berdirNeeds a rebase on the performance tests.
Comment #7
catchRebased.
Comment #8
catchWe should also be using memory cache in this class, but I didn't want to add it just for this property, but also didn't want to convert the 5+ static caches in here to it either, so hoping that can be a follow-up - would be a good one to do in general.
Comment #9
nicxvan commentedLet's do that as a follow up! Created here #3554131: Add memory cache for EntityFieldManager I might try to backport this to a site that having some performance issues likely due to the number of fields and paragraphs.
Comment #10
alexpottCommitted and pushed d33c15d9f59 to 11.x and 43005e8159a to 11.3.x. Thanks!