Problem/Motivation

Drupal stores compiler-generated hook metadata in the hook_data key-value collection:

  • hook_list
  • packed_order_operations
  • theme_hook_list
  • preprocess_for_suggestions

The three consumers own overlapping loading and caching logic:

- ModuleHandler loads and caches hook_list plus packed_order_operations.
- ThemeManager loads and caches theme_hook_list.
- Registry separately reads theme_hook_list and preprocess_for_suggestions directly from key-value storage.

On a cold cache, both Registry and ThemeManager independently load theme_hook_list.

Steps to reproduce

Proposed resolution

Introduce a HookData service that owns the compiler-generated hook_data reads and the bootstrap cache entries.

Use two logical cache groups:

1. Module hook data: hook_list and packed_order_operations

2. Theme hook data: theme_hook_list and preprocess_for_suggestions.

ModuleHandler, ThemeManager, and Registry would use this shared service. The service keeps request-local copies, reads from cache.bootstrap first, and falls back to the key-value collection on a cache miss.

This should remove two database queries from the cold cache performance tests.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3618707

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

longwave created an issue. See original summary.

longwave-bot made their first commit to this issue’s fork.

longwave’s picture

Status: Active » Needs review
nicxvan’s picture

Component: base system » extension system

We might also be able to better handle race conditions is we move to a container cache key for the hook data.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

longwave’s picture

Status: Needs work » Needs review
nicxvan’s picture

Status: Needs review » Needs work

We need to regenerate the performance tests, this looks great.

We probably need a CR too since we're breaking BC on these classes again.

longwave’s picture

Issue tags: +Needs change record
nicxvan’s picture

Issue tags: -Needs change record

Added the CR!

Needs a reroll and review of the change record though.

longwave’s picture

I added a BC layer and pointed to the CR, but I think the CR needs a bit more detail about what to do if you were overriding the services before - contrib does extend some of these, such as Bootstrap reusing Registry.

nicxvan’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record updates

Looks great now!

I updated the CR to mention the new constructor changes, @longwave approved in slack: https://drupal.slack.com/archives/C079NQPQUEN/p1791809011440739

I reviewed everything again and we tidied up the tests a bit.