-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Wire PhpArrayAdapter with a new cache warmer for annotations #18533
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
Conversation
edf1bf7
to
a13e408
Compare
*/ | ||
protected function doFetch(array $ids) | ||
{ | ||
$this->loadFile(); |
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.
Given calling a method is an heavy process, you can save CPU by calling loadFile
only when needed
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.
@nicolas-grekas just told me that :)
06c84df
to
ed52528
Compare
// Validates that the dumped code is valid (ie. no __set_state()) | ||
$this->values = eval($dump); | ||
|
||
$dump = "<?php\n\n" . $dump; |
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.
missing \n
at the end
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should move this condition block after the mkdir
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.
That's a good point, I'll do that tomorrow
d8de715
to
088afb1
Compare
088afb1
to
9768dfe
Compare
4f2d5c2
to
91d992d
Compare
91d992d
to
86a9938
Compare
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. |
…tated classes to compile using patterns (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [HttpKernel] Allow bundles to declare classes and annotated classes to compile using patterns | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR introduces a simple system of patterns based on wildcards for classes to cache in the HttpKernel dependency injections extensions. This system started to be implemented in #18533 but I split it up here to use it also in the classes to compile. Commits ------- 1be7424 [HttpKernel] Allow usage of patterns in classes and annotations to cache
…nd annotated classes to compile using patterns (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [HttpKernel] Allow bundles to declare classes and annotated classes to compile using patterns | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR introduces a simple system of patterns based on wildcards for classes to cache in the HttpKernel dependency injections extensions. This system started to be implemented in symfony#18533 but I split it up here to use it also in the classes to compile. Commits ------- 1be7424 [HttpKernel] Allow usage of patterns in classes and annotations to cache
…nd annotated classes to compile using patterns (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [HttpKernel] Allow bundles to declare classes and annotated classes to compile using patterns | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR introduces a simple system of patterns based on wildcards for classes to cache in the HttpKernel dependency injections extensions. This system started to be implemented in symfony#18533 but I split it up here to use it also in the classes to compile. Commits ------- 1be7424 [HttpKernel] Allow usage of patterns in classes and annotations to cache
…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 fragmentation 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 (see 96e418a), 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
…or based on PhpArrayAdapter (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | - | Fixed tickets | - | License | MIT | Doc PR | - Following the cache warmer for annotations PR (#18533), this PR introduces a cache warmer for YAML and XML Validator configuration. Based on the PhpArrayAdapter, it uses the naming conventions (`Resources/config/validation`) 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 annotations PR: - validation configuration 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 fragmentation - last but not least, global performance is slightly better (I get 30us per class gain in Blackfire) This PR also deprecates the framework.validator.cache key in favor of the cache pool introduced in #18544. Commits ------- 6bdaf0b [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter
…or based on PhpArrayAdapter (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | - | Fixed tickets | - | License | MIT | Doc PR | - Following the cache warmer for annotations PR (symfony/symfony#18533), this PR introduces a cache warmer for YAML and XML Validator configuration. Based on the PhpArrayAdapter, it uses the naming conventions (`Resources/config/validation`) 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 annotations PR: - validation configuration 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 fragmentation - last but not least, global performance is slightly better (I get 30us per class gain in Blackfire) This PR also deprecates the framework.validator.cache key in favor of the cache pool introduced in symfony/symfony#18544. Commits ------- 6bdaf0b [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter
…or based on PhpArrayAdapter (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | - | Fixed tickets | - | License | MIT | Doc PR | - Following the cache warmer for annotations PR (symfony/symfony#18533), this PR introduces a cache warmer for YAML and XML Validator configuration. Based on the PhpArrayAdapter, it uses the naming conventions (`Resources/config/validation`) 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 annotations PR: - validation configuration 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 fragmentation - last but not least, global performance is slightly better (I get 30us per class gain in Blackfire) This PR also deprecates the framework.validator.cache key in favor of the cache pool introduced in symfony/symfony#18544. Commits ------- 6bdaf0b [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter
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.