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
Comment | File | Size | Author |
---|---|---|---|
#4 | cache-bootstrap-2754003-4-interdiff.txt | 1.13 KB | Berdir |
#4 | cache-bootstrap-2754003-4.patch | 2.74 KB | Berdir |
#2 | cache-bootstrap-2754003-2.patch | 1.61 KB | Berdir |
Comments
Comment #2
BerdirSo far, so easy ;)
Comment #4
BerdirFixed the tests.
Comment #5
Wim LeersExcept 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).Comment #6
Berdir(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:
Comment #7
Wim LeersThen I'm tentatively +1.
Would like to hear thoughts from people like catch, Fabianx, dawehner, alexpott.
Comment #8
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedAm +1, cache_bootstrap was always the 'this-is-really-important' cache bin.
Comment #9
catchYeah 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?'
Comment #10
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedRTBC - concerns have been addressed.
Comment #11
BerdirThanks 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?
Comment #12
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedFollow-up please as the changes are unrelated.
Comment #14
catchCommitted/pushed to 8.2.x, thanks!
Agreed we can put the theme registry runtime in cache_bootstrap, but follow-up is good for that.
Comment #15
Wim LeersWould be good to document this.
Comment #16
BerdirCreated #2761403: Move runtime theme registry into bootstrap cache
@Wim: Happy to review a patch that extends https://api.drupal.org/api/drupal/core%21core.api.php/group/cache/8.2.x#... :)
Comment #17
Wim Leers#16: aye, sir! #2761451: Document bootstrap cache bin's purpose.