Problem/Motivation
As a result of #3281020: referencedEntities: Use loadMultipleRevisions instead of loadRevision and #2620980: Add static and persistent caching to ContentEntityStorageBase::loadRevision(), we observe a negative performance side effect. Nested paragraphs cause additionally loads of their parent paragraph due to \Drupal\paragraphs\Entity\Paragraph::getParentEntity() because it is now loaded by revision first.
The final implementation in that in initial revision caching issue dropped setting the regular static cache from loading the revision if that happens to the default revision. That was done due to complications around entity preloading/workspaces. And in core, it did not have a visible peformance regression as regular entities are typically loaded by ID first anyway. Paragraphs is reversed now with the ERR change.
The proper change for getParentEntity() would be to track and load by revision too, but we don't have that yet. I believe the complications around entity preload don't apply to paragraphs as they are not tracked in a workspace.
Steps to reproduce
Proposed resolution
Add paragraphs also to the static cache.
The question is how/where exactly. I made the mistake of not making setting the revision static cache a method, so we can't override that easily in \Drupal\Core\Entity\ContentEntityStorageBase::loadMultipleRevisions.
I can possibly do it from Paragraph::postLoad(), it will run also for load by ID though. And we can't respect the \Drupal\Core\Entity\ContentEntityStorageBase::$ignoreStaticRevisionCache flag.
The only other option is overriding the storage class and overriding \Drupal\Core\Entity\ContentEntityStorageBase::loadMultipleRevisions() and then adding them on every call to that, which is a bit of an overhead, but it's likely faster to just set them again instead of trying to check which aren't already there, it's the memory cache and that's pretty cheap.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork paragraphs-3559239
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
berdirComment #5
berdirMerged.