Problem/Motivation

The ActiveTheme objects contain an ActiveTheme object for each base theme - although this is never really used. This makes the theme.active_theme.seven cache entry much larger than necessary.

Proposed resolution

Reduce the amount of stuff stored in the ActiveTheme class by deprecating the ability to store ActiveTheme objects for base themes and store the extension object instead.

Also this is likely to be a perfomance boost because

Before

select length(data) from cache_bootstrap where cid = 'theme.active_theme.seven';
+--------------+
| length(data) |
+--------------+
|        90370 |
+--------------+

After

mysql> select length(data) from cache_bootstrap where cid = 'theme.active_theme.seven';
+--------------+
| length(data) |
+--------------+
|        43590 |
+--------------+

Here's a profile of cold caches showing the improvement from storing less stuff and doing less stuff - https://blackfire.io/profiles/compare/e21a0d28-9f1e-4488-b094-f78bec83b8...
Here's a profile of warm caches showing the improved memory usage - https://blackfire.io/profiles/compare/a4045574-796a-421b-a518-a49369d63c...

Remaining tasks

User interface changes

None

API changes

\Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated. There is no direct replacement. Base theme extension objects can be retrieved from the active theme using the new \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() method. In order to get active theme representations of any theme you can use \Drupal::service('theme.initialization')->getActiveThemeByName($theme_name);

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3020157-2.patch14.27 KBalexpott

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new14.27 KB
alexpott’s picture

jibran’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Performance
alexpott’s picture

Issue summary: View changes
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 63556cd and pushed to 8.7.x. Thanks!

  • catch committed 63556cd on 8.7.x
    Issue #3020157 by alexpott: ActiveTheme objects and cache contain way...

Status: Fixed » Closed (fixed)

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

mglaman’s picture

The CR is still a draft: https://www.drupal.org/node/3019948

It took me a bit to grok that CR to understand that this has nothing to do with base_theme and was for the internal tracking of a theme's base themes. Probably because I discovered this in code first versus the CR.

quietone’s picture

published the change record