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.
In the alter method in Bootstrap.php, a new AlterManager is instantiated each time it is called. In alter manager, the Drupal cache is used. The problem comes with the fact that alter() is called once for each template that is in use, which can be rather a lot, with a cache (Database) read each time. On a view with some different facets, I'm seeing 600+ unnecessary DB queries.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2905729-11.patch | 3.39 KB | markhalliwell |
Comments
Comment #2
acrollet CreditAttribution: acrollet at roomify - online and open source reservation solutions commentedpatch attached - this patch uses a static cache and only instantiates AlterManager once. Not seeing any issues locally but it could use a review. This knocks average page generation time down from 2.8271s to 2.4627s on my local. (10 trials each)
Comment #3
acrollet CreditAttribution: acrollet at roomify - online and open source reservation solutions commentedComment #4
acrollet CreditAttribution: acrollet at roomify - online and open source reservation solutions commentedComment #5
acrollet CreditAttribution: acrollet at roomify - online and open source reservation solutions commentedupdated patch attached - performance improvement should be even better without the testing log line writing to the DB 🙄
Comment #6
sylus CreditAttribution: sylus commentedThis looks great ^_^, I also gave the patch a go and attached a profile comparison before and after the patch with a drush cr before each page load.
Comment #7
acrollet CreditAttribution: acrollet at roomify - online and open source reservation solutions commentedawesome, thanks for the nice reports - hopefully the maintainer can have a look :-)
Comment #8
markhalliwellI have looked at this and it's been on my list for a while (before this was ever posted).
I'm postponing this issue though because the [bigger] solution involves a complete abstraction/rewrite into a separate project (that isn't bootstrap specific). For now, those who care about this marginal performance bump can apply the above patch.
I have been working on this very topic for months and hopefully will have something tangible (project) to show soon.
Comment #9
markhalliwell@sylus, could you get on slack or IRC so we can chat about some things?
Comment #10
markhalliwellThe bigger solution is still too far off, in a separate project and will likely be a completely different implementation anyway.
The patch in #5 though doesn't really take into account the active theme.
I'll commit a fix shortly.
Comment #11
markhalliwell