Optimize EntityFieldManager::buildBundleFielDefinitions()

Created on 25 July 2025, 5 days ago

Problem/Motivation

Found via 📌 Optimize field module's hook_entity_bundle_info() implementation Active 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

📌 Task
Status

Active

Version

11.0 🔥

Component

entity system

Created by

🇬🇧United Kingdom catch

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

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

Sign in to follow issues

Comments & Activities

  • Issue created by @catch
  • @catch opened merge request.
  • 🇬🇧United Kingdom catch
  • 🇬🇧United Kingdom catch

    It 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.

Production build 0.71.5 2024