[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations#18533
[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations#18533tgalopin wants to merge 2 commits into
Conversation
edf1bf7 to
a13e408
Compare
| */ | ||
| protected function doFetch(array $ids) | ||
| { | ||
| $this->loadFile(); |
There was a problem hiding this comment.
Given calling a method is an heavy process, you can save CPU by calling loadFile only when needed
06c84df to
ed52528
Compare
| // Validates that the dumped code is valid (ie. no __set_state()) | ||
| $this->values = eval($dump); | ||
|
|
||
| $dump = "<?php\n\n" . $dump; |
As your adapter is read-only, this cannot work unless you rewrite most logic. There is nothing ensuring that all the cache is of these services is warmed up by the cache warmer, and services using them are not writing all their cache in a single batch (the ORM does not for instance) |
We already have a single annotation cache. I'm quite sure you are confusing the annotation cache and the cache for metadata of each of these services (which must be separate as they store unrelated data, and which can be built from other sources that annotations) |
| @mkdir($directory, 0777, true); | ||
| } | ||
|
|
||
| if (!file_exists($directory)) { |
There was a problem hiding this comment.
you should move this condition block after the mkdir
There was a problem hiding this comment.
That's a good point, I'll do that tomorrow
fe237f0 to
b732ff6
Compare
|
Given than keys validation is slow (from my benchmarks), I suggest we remove all keys validation from OpCache and Null adapters (and skip any related failing tests):
|
|
I did the changes |
| <argument /> <!-- default lifetime --> | ||
| </service> | ||
|
|
||
| <service id="cache.adapter.redis" class="Symfony\Component\Cache\Adapter\RedisAdapter" abstract="true"> |
|
👍 Hurray |
| ->addDefaultsIfNotSet() | ||
| ->children() | ||
| ->scalarNode('cache')->defaultValue('file')->end() | ||
| ->scalarNode('cache')->defaultValue('opcache')->end() |
There was a problem hiding this comment.
How should we name this? opcache is misleading IMO as we won't use the OpCacheAdapter.
|
Any performance profiles? |
| <service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider" public="false"> | ||
| <argument type="service"> | ||
| <service class="Symfony\Component\Cache\Adapter\PhpArrayAdapter"> | ||
| <factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="createOnPhp7" /> |
|
With Blackfire it's really hard to highlight the performance gain because it's small. With To sum up, the benefit provided by this PR are:
|
|
Status: reviewed |
|
Thank you @tgalopin. |
Depends on #18825 and #18823
This PR implements the usage of the new OpCacheAdapter in the annotations caching system. The idea to use this adapter as much as possible in Symfony (validator, serializer, ...). These other implementations will be the object of different PRs.