Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cache] optimize Pimcore cache with doctrine entities #1843

Merged
merged 7 commits into from
Jan 21, 2022

Conversation

dpfaffenbauer
Copy link
Member

@dpfaffenbauer dpfaffenbauer commented Jan 19, 2022

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no

Related to #1841

@jdreesen
Copy link
Contributor

You mean: related to #1841

@dpfaffenbauer
Copy link
Member Author

You mean: related to #1841

obviously :D

@dpfaffenbauer
Copy link
Member Author

@jdreesen what do you think of the solution? actually that should be somehting pimcore does, but they need to refactor serialization in general and this is something we cannot wait for.

Copy link
Contributor

@jdreesen jdreesen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think of the solution?

I'm not really experienced in Pimcore's/Symfony's cache implementation, but at first glance it looks good to me.

actually that should be somehting pimcore does, but they need to refactor serialization in general

💯 👍

@dpfaffenbauer dpfaffenbauer marked this pull request as ready for review January 19, 2022 15:28
@BlackbitDevs
Copy link
Contributor

Can this solution be adjusted to make it compatible with Pimcore 6.9 / Coreshop 2.2?

@dpfaffenbauer
Copy link
Member Author

@BlackbitNeueMedien not sure really... Pimcore 6.9 still uses it's own cache implementation and I don't think that there are extensions points in there.

@dpfaffenbauer dpfaffenbauer merged commit 2c51349 into coreshop:master Jan 21, 2022
@dpfaffenbauer dpfaffenbauer deleted the issue/cache branch January 21, 2022 10:29
@BlackbitDevs
Copy link
Contributor

BlackbitDevs commented Mar 21, 2022

Still struggling with performance issues when creating version entries. In Blackfire I see that DeepCopy does a lot of things with Doctrine collections (to be read from bottom up):

Doctrine\ORM\PersistentCollection::map@1
DeepCopy\Filter\Doctrine\DoctrineCollectionFilter::apply@1
DeepCopy\DeepCopy::copyObjectProperty@4
DeepCopy\DeepCopy::copyObject@4
DeepCopy\DeepCopy::recursiveCopy@4
DeepCopy\DeepCopy::copyObjectProperty@3
DeepCopy\DeepCopy::copyObject@3
DeepCopy\DeepCopy::recursiveCopy@3
DeepCopy\DeepCopy::copyObjectProperty@2
DeepCopy\DeepCopy::copyObject@2
DeepCopy\DeepCopy::recursiveCopy@2
{closure}::DeepCopy/DeepCopy.php/232-234
{closure}::Doctrine/DoctrineCollectionFilter.php/26-28
Doctrine\Common\Collections\ArrayCollection::map
Doctrine\ORM\PersistentCollection::map
DeepCopy\Filter\Doctrine\DoctrineCollectionFilter::apply
DeepCopy\DeepCopy::copyObjectProperty@1
DeepCopy\DeepCopy::copyObject@1
DeepCopy\DeepCopy::recursiveCopy@1
DeepCopy\DeepCopy::copyObjectProperty
DeepCopy\DeepCopy::copyObject
DeepCopy\DeepCopy::recursiveCopy
DeepCopy\DeepCopy::copy
Pimcore\Model\Version::marshalData

Is it correct that for example in

public function marshalVersion($object, $data)
{
if (!is_array($data)) {
return null;
}
$serialized = [];
foreach ($data as $datum) {
$context = SerializationContext::create();
$context->setSerializeNull(true);
$context->setGroups(['Version']);
$serialized[] = $this->getSerializer()->toArray($datum, $context);
}
return $serialized;
the object gets saved with JMS serializer? If yes, is it correct that in https://github.com/coreshop/CoreShop/tree/master/src/CoreShop/Bundle/CoreBundle/Resources/config/serializer there is no serialization rule for productSpecificPriceRules?

Actually I have the impression that the jms serializer config files do not get loaded at all as I see thousands of requests for Country.stores, Country.translations, Country.states in DoctrineCollectionFilter when saving an object.

@dpfaffenbauer
Copy link
Member Author

@BlackbitNeueMedien you get this issues with 2.2 right?

@BlackbitDevs
Copy link
Contributor

BlackbitDevs commented Mar 21, 2022

@dpfaffenbauer Yes. This time it is about versioning (this PR was originally about caching).

Performance problems when creating cache entry I have now solved by replacing

$copier->addFilter(
new DoctrineCollectionFilter(),
new PropertyTypeMatcher('Doctrine\Common\Collections\Collection')
);
with

$copier->addFilter(new SetNullFilter(), new PropertyTypeMatcher(Collection::class));

Do not know if this works but at least the site is usable at all with this...

To be clear, I do not speak about problems that it needs 1 second or something similar to save an object but it now takes 30 seconds. As soon as I disable versioning, it gets saved in 0.3s. There are ca. 100 items in specificPriceRules and quantityPriceRules (not very complex: each item has 1 condition and 1 action).

@dpfaffenbauer
Copy link
Member Author

Marshalling Data for Caching works similar as for Versioning. Both is not done wright. But it is how it is... You can try doing the same for Versioning. But: Reverting Versions might result in unexpected behaviour....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants