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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acrollet created an issue. See original summary.

acrollet’s picture

Status: Active » Needs review
FileSize
727 bytes

patch 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)

acrollet’s picture

Version: 8.x-4.x-dev » 8.x-3.x-dev
acrollet’s picture

Issue tags: +Performance
acrollet’s picture

updated patch attached - performance improvement should be even better without the testing log line writing to the DB 🙄

sylus’s picture

FileSize
298.27 KB

This 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.

acrollet’s picture

awesome, thanks for the nice reports - hopefully the maintainer can have a look :-)

markhalliwell’s picture

Priority: Major » Normal
Status: Needs review » Postponed

I 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.

markhalliwell’s picture

@sylus, could you get on slack or IRC so we can chat about some things?

markhalliwell’s picture

Assigned: Unassigned » markhalliwell
Status: Postponed » Needs work

The 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.

markhalliwell’s picture

Assigned: markhalliwell » Unassigned
Status: Needs work » Fixed
FileSize
3.39 KB

  • markcarver committed 1531283 on 8.x-3.x
    Issue #2905729 by markcarver, acrollet, sylus: Performance issues with...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.