ActiveTheme objects and cache contain way too much information

Created on 12 December 2018, almost 6 years ago
Updated 12 September 2023, about 1 year ago

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

📌 Task
Status

Fixed

Version

8.7 ⚰️

Component
Theme 

Last updated about 11 hours ago

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024