Follow-up from #2244447: Translation of low-level info/annotations leads to circular dependencies

This should allow us to do three things:

1. Improve cache hit rate on multilingual sites.

2. Remove several cache tags.

3. Remove the translation manager dependency from plugin discovery.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Title: Stop caching plugin discovery by language » Stop caching plugin discovery/info hooks by language
Berdir’s picture

Status: Active » Needs review
FileSize
1.21 KB

Just trying to see what happens...

Status: Needs review » Needs work

The last submitted patch, 2: stop-caching-by-language-2281905-1.patch, failed testing.

Berdir’s picture

So this worked, the only test fails are broken unit tests that expect calls to the language manager...

Berdir’s picture

Status: Needs work » Needs review
FileSize
79.87 KB

So. many. plugin. managers.

We still need a by-language cache for yaml and I also kept it for the config mapper stuff, which only uses an info hook.

Status: Needs review » Needs work

The last submitted patch, 5: so-many-plugin-managers-2281905-5.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
80.79 KB
878 bytes

Re-roll and fixing the test fail.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Nice job, looks great.

Berdir’s picture

Thanks, but...

Also not sure if there's something else we can clean up based on @catch statements...

Berdir’s picture

Status: Reviewed & tested by the community » Needs review
catch’s picture

I was wrong on the cache tags, forgot we're explicitly avoiding those, so ignore that at least :)

Berdir’s picture

Yes, that I know, except the ones that now still need them because they manually add the langcode to the cache key, but most of them already had one, with the exception of the contextual links manager.

Gábor Hojtsy’s picture

So what is left here? Not clear to me. Looks like catch's steps from the issue summary are done then? :)

Berdir’s picture

A change record :)

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Added draft change notice at https://drupal.org/node/2284277. While doing that, found the following:

+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -41,16 +40,15 @@ class ConstraintManager extends DefaultPluginManager {
+    // @todo static discovery still uses t(), change to TranslationWrapper?
+    $this->setCacheBackend($cache_backend, 'validation_constraint_plugins');

So this will be a bug then when this is committed? It will not cache by language but will be language specific? Not sure we want to do this?! At least we need to add an issue URL in the @todo.

Wrote this for the change notice but not sure if this can be considered a bug as well, sounds like it will make plugin cache clearing for the few plugin managers that cache by language (see my list on the change notice if I identified them right):

Finally, DefaultPluginManager::clearCachedDefinitions() does not remove all cached variants for all languages but only the one cached for the specific language being used at the time.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record
FileSize
82.08 KB
2.29 KB

Fixed the @todo, updated the change record a bit and made it reference this issue.

Updated the last sentence there, not clearing all languages anymore is by design because the default plugin manager has no understanding anymore of languages. If you add that manually, the easiest way to ensure the caches are cleared is to use a cache tag which all the relevant core plugin managers are doing now.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

That last interdiff looks good, sorry for the premature RTBC the first time :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit bc7e413 on 8.x by catch:
    Issue #2281905 by Berdir: Stop caching plugin discovery/info hooks by...
Gábor Hojtsy’s picture

Published the change record. :)

Status: Fixed » Closed (fixed)

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

effulgentsia’s picture