Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The TaggedHandlersPass loops around all the service definitions many times. We call \Symfony\Component\DependencyInjection\ContainerBuilder::findTaggedServiceIds 370 odd times when installing minimal.
Proposed resolution
Build a map of all the services and tags first and use it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#5 | 3185917-5.patch | 2.99 KB | alexpott |
#5 | 2-5-interdiff.txt | 1.22 KB | alexpott |
#2 | 3185917-2.patch | 2.91 KB | alexpott |
Comments
Comment #2
alexpottComment #3
alexpottOn standard install this saves +1000 calls to ContainerBuilder::findTaggedServiceIds()
During a regular module install on standard it saves: 90 calls. And this will increase if an installed module uses the tagged service pattern.
It's not huge gains in terms of performance but it is certainly doing less.
Comment #4
longwaveThis looks like a neat optimisation - as you say it's small but it does remove a lot of method calls. We already had a comment hinting at the optimisation, even:
Let's move this comment above the first loop and fix the grammar while we are here.
Comment #5
alexpott@longwave good point re comment - moved and fixed.
Yep this does save many function calls - it's just that they are not particularly expensive - but every little helps.
Comment #6
longwaveLooks good.
Comment #9
catchLooks great to me too.
Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!
Comment #10
Wim LeersNice, this further optimizes what #2472337: Provide a lazy alternative to service collectors which just detects service IDs introduced! 👍
Comment #11
Wim Leers