Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter#19507
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9f42021 to8f29578Comparef336e86 to578d101Compare| $values = $arrayPool->getValues(); | ||
| $adapter->warmUp($values); | ||
| foreach ($values as $k => $v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I guess this is only there in case we are not on a php7 env ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Exactly :) .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think you should add a note specifiing that this should be removed once symfony will only supportphp >= 7.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is not planned and not done anywhere else, and I think when this will happen we will have a lot of work to adapt the whole codebase anyway. I don't think it has much added value, don't you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It should make the transition easier but your argument is true as well so let's not do anything it is just a fallback anyway :)
GuilhemN commentedAug 2, 2016
This looks very promising ☺ thanks ! |
140ef34 to3dd2989Comparetgalopin commentedAug 3, 2016
This is green and ready for intensive review :) . |
3dd2989 tocb0f550Compare| $cache =newReference('serializer.mapping.cache.symfony'); | ||
| } | ||
| if ($cache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
null !== $cache?
1a318f0 toe9bd2d8Comparetgalopin commentedAug 16, 2016
I updated this PR to fix the potential BC break. |
1a6a85d to38ab487Comparetgalopin commentedAug 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I fixed the compatibility with older versions of the Serializer. I disabled the cache warmer for old versions of the serializer to avoid problems in cache generation. I think this PR is reaydy for review :) . |
| */ | ||
| public function warmUp($cacheDir) | ||
| { | ||
| if (!class_exists('Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You can use the::class constant for all those checks.
38ab487 to37fbb30Compare| publicfunctiontestSerializerCacheActivated() | ||
| { | ||
| if (!class_exists('Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can use::class too (same in all tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Missed this one, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I updated this
dunglas commentedAug 17, 2016
👍, good work! |
37fbb30 toa83ff96Compare| { | ||
| if (!class_exists(CacheClassMetadataFactory::class) | ||
| || !method_exists(XmlFileLoader::class, 'getMappedClasses') | ||
| || !method_exists(YamlFileLoader::class, 'getMappedClasses')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be on one line
a83ff96 to810f469Comparetgalopin commentedAug 18, 2016
Updated |
nicolas-grekas commentedSep 6, 2016
ping @symfony/deciders |
fabpot commentedSep 14, 2016
Thank you@tgalopin. |
…zer based on PhpArrayAdapter (tgalopin)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -Following the cache warmer for annotations (#18533) and for the validator (#19485), this PR introduces a cache warmer for the Serializer YAML and XML metadata configuration (mainly groups).Based on the PhpArrayAdapter, it uses the naming conventions (Resources/config/serialization) to find the files and compile them into a single PHP file stored in the cache directory. This file uses shared memory on PHP 7.The benefit of this PR are the same than the ones of the previous PR:- serialization metadata cache can be warmed up offline- on PHP 7, there is no need for user extension to get maximum performances (ie. if you use this PR and the other one, you probably won't need to enable APCu to have great performances)- on PHP 7 again, we are not sensitive to APCu memory fragmentationlast but not least, global performance is slightly better (I get 30us per class gain in Blackfire)As previous work on the Serializer cache system introduced issues (see96e418a), it would be interesting to pay careful attention to the backward compatibility during the review (ping @Ener-Getick).Commits-------810f469 [FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter
Uh oh!
There was an error while loading.Please reload this page.
Following the cache warmer for annotations (#18533) and for the validator (#19485), this PR introduces a cache warmer for the Serializer YAML and XML metadata configuration (mainly groups).
Based on the PhpArrayAdapter, it uses the naming conventions (Resources/config/serialization) to find the files and compile them into a single PHP file stored in the cache directory. This file uses shared memory on PHP 7.
The benefit of this PR are the same than the ones of the previous PR:
last but not least, global performance is slightly better (I get 30us per class gain in Blackfire)
As previous work on the Serializer cache system introduced issues (see96e418a), it would be interesting to pay careful attention to the backward compatibility during the review (ping @Ener-Getick).