Problem/Motivation

Quite a few default cache entries in the default bin are quite small and used on many if not all requests. They're a good fit for the bootstrap or discovery cache bin, so that we can benefit from the fast chained backend.

This is how cache_default and cache_bootstrap look like for me on a site with a bunch of modules installed:

mysql> select cid, length(data) from cache_default where cid not like 'twig:%' order by length(data);
+------------------------------------+--------------+
| cid                                | length(data) |
+------------------------------------+--------------+
| user_permissions_hash:anonymous    |           64 |
| path_alias_whitelist               |          733 |
| config_translation_info_plugins:en |        10841 |
| theme_registry:runtime:bartik      |        16621 |
| theme_registry:runtime:seven       |        22053 |
| system.module.info                 |        29992 |
| theme_registry:build:modules       |        66926 |
| theme_registry:seven               |        74417 |
| theme_registry:bartik              |        75546 |
+------------------------------------+--------------+
10 rows in set (0.00 sec)

mysql> select cid, length(data) from cache_bootstrap order by length(data);
+--------------------------------------+--------------+
| cid                                  | length(data) |
+--------------------------------------+--------------+
| last_write_timestamp_cache_bootstrap |           17 |
| hook_info                            |         3422 |
| routing.non_admin_routes             |         6106 |
| module_implements                    |        13229 |
| system_list                          |        22644 |
| theme.active_theme.bartik            |        68212 |
| theme.active_theme.seven             |        68471 |
+--------------------------------------+--------------+

( I ignored twig entries because they're only around on dev (or should be) anyway.

Proposed resolution

Based on that list, the user permissions hashes, the path alias whitelist seem to be good matches for bootstrap. config_translation_info_plugins:en are plugin definitions, so should be in discovery. flag I suppose too but that's contrib.

Not sure about the theme registry runtimes, maybe? It's quite likely that one of them is requested but I suppose they could get a bit bigger.

system.module.info is not requested on a normal request, so I guess not.

Note: While the bootstrap cache bin is named like that, and introducing a different cache bin might make more sense semantically, it already is the "cache_tiny_and_99percent" bin, it contains things like hook list and implementations, active theme.. those are not really related to bootstrap already.

Remaining tasks

Check if there are more things to move.

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
1.61 KB

So far, so easy ;)

Status: Needs review » Needs work

The last submitted patch, 2: cache-bootstrap-2754003-2.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
2.74 KB
1.13 KB

Fixed the tests.

Wim Leers’s picture

Based on that list, the user permissions hashes, the path alias whitelist seem to be good matches for bootstrap.

Except they're completely unrelated to bootstrapping.

I think it'd be better to then introduce a new cache bin called something like … cache_tiny_and_99percent (better name TBD).

Berdir’s picture

Issue summary: View changes


(11:17:49) berdir: WimLeers: bootstrap imho *is* the "cache_tiny_and_99percent". if you look at the list of entries there, it has module_implements, active theme, hook_info. that's not bootstrap, it's small-things-used-on-most-requests

Added a note about that to the issue summary:

Wim Leers’s picture

Then I'm tentatively +1.

Would like to hear thoughts from people like catch, Fabianx, dawehner, alexpott.

Fabianx’s picture

Am +1, cache_bootstrap was always the 'this-is-really-important' cache bin.

catch’s picture

Yeah cache_bootstrap is 7.x naming, and wasn't perfect then. The rule should be 'is it needed to get from the beginning to the end of most requests?', 'is there a very strict limit on variations? and 'does it get invalidated infrequently?'

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC - concerns have been addressed.

Berdir’s picture

Thanks for the RTBC.

FYI, with this patch, there is only one cache get for the default cache bin remaining: theme_registry:runtime:bartik. (Edit: On an empty default frontpage with warm caches)

Considering that this is supposed to be a more or less small cache entry, I think it would also be interesting to move that to bootstrap as well. That's a bit more complicated than this patch however, since we need to update \Drupal\Core\Theme\Registry to pass in a second cache bin for the runtime theme registry, we don't want to use it for the full registry.

I can open a follow-up to do that or I can work on that here, or we can keep it as it is. Thoughts?

Fabianx’s picture

Follow-up please as the changes are unrelated.

  • catch committed fdb0db8 on 8.2.x
    Issue #2754003 by Berdir, Wim Leers: Move more cache items from the...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x, thanks!

Agreed we can put the theme registry runtime in cache_bootstrap, but follow-up is good for that.

Wim Leers’s picture

The rule should be 'is it needed to get from the beginning to the end of most requests?', 'is there a very strict limit on variations? and 'does it get invalidated infrequently?'

Would be good to document this.

Berdir’s picture

Wim Leers’s picture

Status: Fixed » Closed (fixed)

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