Drupal\Core\Theme\ComponentNegotiator::negotiate uses a lot of memory

Created on 13 December 2024, about 2 months ago

Problem/Motivation

Drupal\Core\Theme\ComponentNegotiator::negotiate

Doing some profiling of Drupal CMS and I see a lot of memory usage from this method.

Seems to all be due to Drupal\Core\Extension\ExtensionList::getList which is called by Drupal\Core\Theme\ComponentNegotiator::maybeNegotiateByModule

I think the component negotiator probably needs its own cache so it doesn't need to load the full info for every module into memory on every request - but didn't read code yet.

This is also called by Drupal\Core\Extension\ThemeHandler::listInfo

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

single-directory components

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

Merge Requests

Comments & Activities

  • Issue created by @catch
  • First commit to issue fork.
  • Merge request !10987Sort components by module at discovery time → (Open) created by berdir
  • Pipeline finished with Canceled
    5 days ago
    Total: 154s
    #404170
  • 🇨🇭Switzerland berdir Switzerland

    Stumbled over this as well, thanks to 📌 Aggregate cache operations per bin to allow for more specific asserts Active

    The module weight is stable, unlike the active theme, it doesn't change at runtime. We can sort the whole component list once by module weight and then negotiate doesn't actually need to do any negotiation, it can just return the first. We might need a cache tag on config:core.extension in case a module weight changes.

    Also didn't check tests yet nor did I properly inject the module extension list.

  • Pipeline finished with Failed
    5 days ago
    Total: 109s
    #404173
  • Pipeline finished with Failed
    5 days ago
    Total: 330s
    #404176
  • Pipeline finished with Failed
    5 days ago
    Total: 339s
    #404187
  • Pipeline finished with Failed
    5 days ago
    Total: 592s
    #404245
  • 🇬🇧United Kingdom oily Greater London

    Added a review comment to the MR.

  • 🇬🇧United Kingdom oily Greater London
Production build 0.71.5 2024