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

[FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter #19485

Merged
merged 1 commit into from Sep 14, 2016

Conversation

tgalopin
Copy link
Member

@tgalopin tgalopin commented Jul 29, 2016

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.

@tgalopin tgalopin changed the title [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter [WIP][FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter Jul 29, 2016
@tgalopin tgalopin force-pushed the php-array-validator branch 5 times, most recently from 90616f5 to 3b05660 Compare July 30, 2016 14:32
@tgalopin tgalopin changed the title [WIP][FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter [FrameworkBundle] Introduce a cache warmer for Validator based on PhpArrayAdapter Jul 30, 2016
@tgalopin tgalopin force-pushed the php-array-validator branch 3 times, most recently from 2586e76 to 94543a9 Compare July 30, 2016 15:15
@tgalopin
Copy link
Member Author

I think this is ready for reviews.

@tgalopin tgalopin force-pushed the php-array-validator branch 6 times, most recently from 7e9ce05 to 41a9e8f Compare August 1, 2016 09:47
private $fallbackPool;

/**
* @param array $bundles The application bundles to find validation metadata in.
Copy link
Member

Choose a reason for hiding this comment

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

out of sync

@tgalopin
Copy link
Member Author

tgalopin commented Aug 1, 2016

Updated

@tgalopin tgalopin force-pushed the php-array-validator branch 5 times, most recently from 0d20399 to c84db06 Compare August 1, 2016 12:19
@tgalopin
Copy link
Member Author

tgalopin commented Aug 1, 2016

Added tests for the warmer.

@tgalopin tgalopin force-pushed the php-array-validator branch 2 times, most recently from 522a48a to 5568b27 Compare August 1, 2016 13:49
@nicolas-grekas
Copy link
Member

👍

@mickaelandrieu
Copy link
Contributor

mickaelandrieu commented Aug 2, 2016

@tgalopin only have a question about performances.
Nicolas said at SymfonyLive that for now doctrine is a little bit more performant than Symfony cache.
Is this PR intended to improve performance or/and to implement Cache component ?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Aug 2, 2016

@mickaelandrieu I also said that the difference in terms of performance was negligible and that we shouldn't care. In fact, PhpArrayAdapter is faster than Doctrine (for what it means :) ).

*
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ValidatorCacheWarmer implements CacheWarmerInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

This cache warmer is very similar to the one you proposed for the serializer, can't we create a new abstract class ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Even if it seems similar, there is only a few lines that can be shared. I don't think it's worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can be used in third party libraries and promote cache warmers by making them much easier to use.

Copy link
Member

Choose a reason for hiding this comment

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

Let's discuss about this in another PR: it's not directly related to this PR and would deserve a dedicated line in the changelog.

@tgalopin tgalopin force-pushed the php-array-validator branch 2 times, most recently from 290db2c to 4365d7c Compare August 3, 2016 13:09
fabpot added a commit that referenced this pull request Sep 14, 2016
…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
@fabpot
Copy link
Member

fabpot commented Sep 14, 2016

Thank you @tgalopin.

@fabpot fabpot merged commit 6bdaf0b into symfony:master Sep 14, 2016
fabpot added a commit that referenced this pull request Sep 14, 2016
…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
@fabpot fabpot mentioned this pull request Oct 27, 2016
sandergo90 pushed a commit to sandergo90/symfony that referenced this pull request Jul 4, 2019
…Serializer 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 (symfony#18533) and for the validator (symfony#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 symfony@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants