- Status changed to Needs work
almost 2 years ago 3:19pm 18 January 2023 - Status changed to Needs review
almost 2 years ago 3:58pm 19 January 2023 - Status changed to Needs work
almost 2 years ago 1:31pm 22 January 2023 - π¨πSwitzerland berdir Switzerland
Testing the patch on default umami installation frontend as admin with disabled render caching, I'm seeing 6 extra queries to the cachetags table (142 vs 148 in total). Time difference of that is too small is way too small to reliably profile, but it's still something to consider.
The specific tags are, in order of appearance:
* routes (non admin routes)
* entity_types (also entity_bundles and lots of entity_field_info later, but all of them would be needed anyway sooner or later, so doesn't really count)
* element_info_build
* theme_registry
* breakpoints
* local_tasks
* library_infoThat's 7 with entity_types. I think we had discussions before about whether or not we should use cache tags for some kind of plugins/caches. I'd suggest opening a follow-up that we remove cache tags for finite and known variations (langcodes, themes), that would remove library_info, element_info_build and theme_registry. breakpoints is a bit trickier areay, groups there are more dynamic, but we also have an API to fetch them (\Drupal\breakpoint\BreakpointManager::getGroups). Alternatively, we could merge these into one, it's rare that they are invalidated and invalidating a few extra thingss might be worth saving 2-3 queries on every request. Not sure how much cache tags are an API though.
That said, IMHO it's fine to move ahead with this, setting to needs work for the documentation updates.
- π¬π§United Kingdom catch
I couldn't find an existing issue for removing cache tags from plugin managers, although definitely remember talking about it somewhere, so opened a new one for that π Manually clear cache keys from plugin managers with finite variations instead of using cache tags Fixed .
- π¨πSwitzerland berdir Switzerland
I just found this old issue, where most of us had similar discussions 6+ years ago :)
π ChainedFastBackend should not invalidate the whole fastBackend when doing a Set() Needs work
- Status changed to Needs review
almost 2 years ago 12:26pm 26 February 2023 - π¨πSwitzerland berdir Switzerland
I seem to have derailed this with the request for documentation, here's a proposed sentence for that. I also created https://www.drupal.org/node/3344524 β .
- π«π·France andypost
I think it should throw deprecation if no interface support for backend implemented
- π¨πSwitzerland berdir Switzerland
There is no interface that we could check, there is no explicit API or anything, we always pass in cache tags, it's up to the implementation to decide how to handle that. We discussed that above, introducing something would IMHO just cause existing implementations to break, I'm not aware of a single cache implementation that would be affected by this. This is only about the fast backend, I'm not sure if there even is an alternative to APCu out there, I've certainly never used something else.
Redis module now supports Relay and that comes with a built-in APCu-like cache, but then you want to replace ChainedFastBackend completely, not just the fast backend.
- π¬π§United Kingdom longwave UK
+++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -244,7 +237,9 @@ public function invalidateTags(array $tags) { - $this->markAsOutdated(); + if ($this->fastBackend instanceof CacheTagsInvalidatorInterface) { + $this->fastBackend->invalidateTags($tags); + }
If we are concerned about (hypothetical) fast backends that don't implement tags can't we just say
if ($this->fastBackend instanceof CacheTagsInvalidatorInterface) { $this->fastBackend->invalidateTags($tags); } else { $this->markAsOutdated(); }
- π¬π§United Kingdom longwave UK
This whole discussion made me wonder if we were reinventing the wheel, and we do seem to be: Symfony supports database, APCu, filesystem, memory, Redis, Memcache and other backends, and allows chaining too: https://symfony.com/doc/current/components/cache/adapters/chain_adapter....
Symfony also supports cache tags in an apparently cleverer way than we do; you store tags in another cache adapter, but it can be a different storage backend to the one that the actual items are in: https://symfony.com/doc/current/components/cache/cache_invalidation.html
I couldn't find an issue for this, worth opening one to explore?
- π¨πSwitzerland berdir Switzerland
I think their chain adapter is our more generic BackendChain, I don't see anything there that specifically supports the sync feature of the ChainedFastBackend, but I only had a quick look at it.
The cache tag implementation seems somewhat comparable with cache tag versions that seem similar our checksums. I guess if you use the same tag pool for different adapters, you should get the same behavior as we have, but it will fetch cache tags from the adapter for every bin/pool. For the record, I'm fairly certain we invented that particular wheel quite some time before Symfony did, but that doesn't really matter.
I'm open to exploring to use their cache system, but that seems a like a _big_ issue and I'm sure we'll hit a fair share of roadblocks on the way there. (Like the database transaction topic) And even if we do that, we'd either need to contribute this back or re-implement it as an Adapter, so this is an improvement we want to do either way.
- π¬π§United Kingdom catch
This whole discussion made me wonder if we were reinventing the wheel
I feel it's necessary to point out that it's Symfony that re-invented the wheel, we've had cache tags support since 2012, theirs was added in about 2016. We tried to get cache tag support into the PSR cache spec when it was in progress, and that was rejected at the time - looks like they've figured out a way around that though.
- πΊπΈUnited States smustgrave
Question before reviewing (attempting) will this require tests?
- π¨πSwitzerland berdir Switzerland
We didn't have tests before about the explicit internal behavior of ChainedFastBackend, or we would have needed to adapt them. We could add them, but I'm not sure if there is a benefit to that.
We have plenty of test coverage that test that ChainedFastBackend overall works as expected (blackbox testing) as basically every functional/browser test is using it. As evident by the 100 fails in the first inconsistent patch.
- Status changed to RTBC
over 1 year ago 1:58pm 12 April 2023 - π¬π§United Kingdom catch
I think this is ready - should be 10.1-only with a change notice, but shouldn't be disruptive and should be a good performance improvement on real sites.
- last update
over 1 year ago 29,202 pass - last update
over 1 year ago 29,283 pass - last update
over 1 year ago 29,300 pass - last update
over 1 year ago 29,302 pass - last update
over 1 year ago 29,304 pass - last update
over 1 year ago 29,343 pass - last update
over 1 year ago 29,366 pass - last update
over 1 year ago 29,366 pass - last update
over 1 year ago 29,371 pass - last update
over 1 year ago 29,378 pass - last update
over 1 year ago 29,356 pass, 2 fail The last submitted patch, 23: 3334489-22.patch, failed testing. View results β
- last update
over 1 year ago 29,379 pass - Status changed to Needs work
over 1 year ago 8:54pm 7 May 2023 - π©πͺGermany geek-merlin Freiburg, Germany
> Various plugin manager related cache tags removed
Why was this mixed in here?With all due honor for the work done here, setting NW for the reasons elaborated in #2241377-124: [meta] Profile/rationalise cache tags β
- Status changed to RTBC
over 1 year ago 6:33am 8 May 2023 - π¨πSwitzerland berdir Switzerland
That is not mixed in here, that is a related draft change record that just mentions this issue as related, as it is the reason for doing it.
- last update
over 1 year ago 29,380 pass - last update
over 1 year ago 29,383 pass - last update
over 1 year ago 29,388 pass 31:43 44:13 Running1:43 57:57 Running- last update
over 1 year ago 29,388 pass - last update
over 1 year ago 29,387 pass, 2 fail The last submitted patch, 23: 3334489-22.patch, failed testing. View results β
- Open on Drupal.org βEnvironment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass 31:44 25:57 RunningThe last submitted patch, 23: 3334489-22.patch, failed testing. View results β
- π¨πSwitzerland berdir Switzerland
Another random test fail I assume, in 1) Drupal\FunctionalJavascriptTests\Ajax\ThrobberTest::testProgressThrobberPosition.
- last update
over 1 year ago 29,399 pass - last update
over 1 year ago 29,399 pass - last update
over 1 year ago 29,400 pass - last update
over 1 year ago 29,409 pass - last update
over 1 year ago 29,409 pass 16:43 12:33 Running- last update
over 1 year ago 29,420 pass - last update
over 1 year ago 29,397 pass, 2 fail The last submitted patch, 23: 3334489-22.patch, failed testing. View results β
- last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,420 pass - last update
over 1 year ago 29,420 pass 1:43 58:06 Running- last update
over 1 year ago 29,429 pass - π¬π§United Kingdom longwave UK
Technically as a bug fix this is eligible for 10.1.x but I'm kinda wary about doing this now we are past rc just in case we are breaking something subtle; I still find it hard to understand all layers of the cache subsystem. So let's get this into 10.2.x and it can have six months of testing before it gets into real sites.
Committed and pushed 0448b4bcc77 to 11.x (10.2.x). Thanks!
- Status changed to Fixed
over 1 year ago 3:50pm 15 June 2023 -
longwave β
committed 0448b4bc on 11.x
Issue #3334489 by catch, Berdir, longwave, andypost: ChainedFastBackend...
-
longwave β
committed 0448b4bc on 11.x
- π¨πSwitzerland berdir Switzerland
Yeah, makes perfect sense to not backport this. This will also become a clearer improvement if we do π Manually clear cache keys from plugin managers with finite variations instead of using cache tags Fixed as well and that definitely won't go into 10.1.
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 4:29am 9 September 2023