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
N/A
Proposed resolution
Move sorting of module components to the discovery phase and cache the result, then only themes need to be sorted at runtime.
Remaining tasks
None
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
None
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3493813-nr-bot.txt | 91 bytes | needs-review-queue-bot |
Issue fork drupal-3493813
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 #4
berdirStumbled over this as well, thanks to #3500739: Aggregate cache operations per bin in performance tests to allow for more specific asserts
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.
Comment #5
ironnuts commentedAdded a review comment to the MR.
Comment #6
ironnuts commentedFilled out the issue summary template.
Comment #7
berdirImproved the comment and updated the cache assertions.
Comment #8
needs-review-queue-bot commentedThe 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.
Comment #9
e0ipsoIt's been a while since I was in this code, but everything checks out. Bear in mind that I reviewed this on my phone without access to the full codebase.
It'd be nice to have @pdureau's confirmation.
Comment #12
pdureau commentedReviewed by @e0ipso.
Also reviewed by @grimreaper on behalf of @pdureau . It looks OK to us because the new logic seems better performance wise, but can we check a last thing before merging?
Comment #13
berdirThe updated performance tests show that we no longer request that cache on that page, yes. We also have performance graphs that should show the memory savings over time once committed, but we do not assert on time/memory explicitly as it's too fragile.
Comment #15
catchThanks this looks great, and really nice that we have a way to test for it now, if not the memory improvement directly.
Committed/pushed to 11.x thanks!