Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:masterfromtgalopin:php-array-serializer
Sep 14, 2016

Conversation

@tgalopin
Copy link
Contributor

@tgalopintgalopin commentedAug 2, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
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 (see96e418a), it would be interesting to pay careful attention to the backward compatibility during the review (ping @Ener-Getick).

@tgalopintgalopin changed the title[FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter[WIP][FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapterAug 2, 2016
@nicolas-grekasnicolas-grekas changed the title[WIP][FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapter[FrameworkBundle] Introduce a cache warmer for Serializer based on PhpArrayAdapterAug 2, 2016
@tgalopintgalopinforce-pushed thephp-array-serializer branch 3 times, most recently fromf336e86 to578d101CompareAugust 2, 2016 10:54
$values = $arrayPool->getValues();
$adapter->warmUp($values);

foreach ($values as $k => $v) {
Copy link
Contributor

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 ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Exactly :) .

GuilhemN reacted with thumbs up emoji
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 you should add a note specifiing that this should be removed once symfony will only supportphp >= 7.0

Copy link
ContributorAuthor

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?

Copy link
Contributor

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
Copy link
Contributor

This looks very promising ☺ thanks !

@tgalopintgalopinforce-pushed thephp-array-serializer branch 7 times, most recently from140ef34 to3dd2989CompareAugust 3, 2016 09:24
@tgalopin
Copy link
ContributorAuthor

This is green and ready for intensive review :) .

$cache =newReference('serializer.mapping.cache.symfony');
}

if ($cache) {
Copy link
Member

Choose a reason for hiding this comment

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

null !== $cache?

@tgalopintgalopinforce-pushed thephp-array-serializer branch 4 times, most recently from1a318f0 toe9bd2d8CompareAugust 16, 2016 17:10
@tgalopin
Copy link
ContributorAuthor

I updated this PR to fix the potential BC break.

@tgalopintgalopinforce-pushed thephp-array-serializer branch 4 times, most recently from1a6a85d to38ab487CompareAugust 17, 2016 12:54
@tgalopin
Copy link
ContributorAuthor

tgalopin commentedAug 17, 2016
edited
Loading

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')
Copy link
Member

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.


publicfunctiontestSerializerCacheActivated()
{
if (!class_exists('Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory')
Copy link
Member

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).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, thanks :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I updated this

@dunglas
Copy link
Member

👍, good work!

{
if (!class_exists(CacheClassMetadataFactory::class)
|| !method_exists(XmlFileLoader::class, 'getMappedClasses')
|| !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
Copy link
Member

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

@tgalopin
Copy link
ContributorAuthor

Updated

@nicolas-grekas
Copy link
Member

ping @symfony/deciders

@fabpot
Copy link
Member

Thank you@tgalopin.

@fabpotfabpot merged commit810f469 intosymfony:masterSep 14, 2016
fabpot added a commit that referenced this pull requestSep 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 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
@tgalopintgalopin deleted the php-array-serializer branchSeptember 15, 2016 13:06
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@tgalopin@GuilhemN@nicolas-grekas@dunglas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp