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

[Serializer] Need to clear cache when updating Annotation Groups on Entities#41961

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:5.3frommonteiro:fix-serializer-groups-cache
Jul 4, 2021

Conversation

@monteiro
Copy link
Contributor

@monteiromonteiro commentedJul 3, 2021
edited
Loading

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#40034
LicenseMIT

Sample project that mimics this behavior:https://github.com/monteiro/PR-40856

The solution was suggested by@nicolas-grekashere.

@carsonbotcarsonbot added this to the5.3 milestoneJul 3, 2021
@monteiromonteiro changed the title[Serializer] Need to clear cache when updating Annotation Groups on E…[Serializer] Need to clear cache when updating Annotation Groups on EntitiesJul 3, 2021
@fabpotfabpotforce-pushed thefix-serializer-groups-cache branch froma79719b toa6829beCompareJuly 4, 2021 08:59
@fabpot
Copy link
Member

Thank you@monteiro.

monteiro and jc-oclock reacted with thumbs up emoji

@fabpotfabpot merged commit018b109 intosymfony:5.3Jul 4, 2021
@monteiromonteiro deleted the fix-serializer-groups-cache branchJuly 5, 2021 08:47
@fabpotfabpot mentioned this pull requestJul 26, 2021
nicolas-grekas added a commit that referenced this pull requestMar 31, 2023
… disabled (bastnic)This PR was merged into the 5.4 branch.Discussion----------[FrameworkBundle] enable metadata cache when annotation is disabled| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->When using Annotations, annotations are cached at `AnnotationLoader` level.Which is cleared when entities are changed. So the dev experience is optimal.```[ClassMetadataFactory.php](vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php") on line 51:[Symfony\Component\Serializer\Mapping\Loader\LoaderChain](vendor/symfony/serializer/Mapping/Loader/LoaderChain.php&line=28#line28) {#543 ▼  -loaders: array:1 [▼    0 => [Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader](vendor/symfony/serializer/Mapping/Loader/AnnotationLoader.php&line=33#line33) {#544 ▼      -reader: [Doctrine\Common\Annotations\PsrCachedReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PsrCachedReader.php&line=22#line22) {#262 ▼        -delegate: [Doctrine\Common\Annotations\AnnotationReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php&line=20#line20) {#263 ▶}        -cache: [Symfony\Component\Cache\Adapter\PhpArrayAdapter](vendor/symfony/cache/Adapter/PhpArrayAdapter.php&line=32#line32) {#277 ▶}        -debug: true        -loadedAnnotations: array:14 [▶]        -loadedFilemtimes: array:4 [▶]      }    }  ]}```When using yaml files, there is no cache at the loader level so I added in the past the same cache as for the prod env, as the metadata are effectively cleared when using only yaml config files.#35109The regression introduced by my patch is for people that do not use mapping files but use annotations.#41961But now, we are in the opposite situation: no cache for people using mapping files but not annotations.On a current project it means loading 83 yaml files for each dev requests. It's not good at all.A simple local fix is to add that in a dev services files.```yamlserializer.mapping.cache_class_metadata_factory:    class: 'Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory'    decorates: 'serializer.mapping.class_metadata_factory'    arguments: ['`@serializer`.mapping.cache_class_metadata_factory.inner', '`@serializer`.mapping.cache.symfony']```![image](https://user-images.githubusercontent.com/84887/224833940-b8e7ad72-e7f6-44e7-a924-0b20f2f0cdae.png)A solution in Symfony could be:1/ only yaml/xml mapping files (`enable_annotations: false`) : cache like prod => that what I did in this PR, as it fixes the current perf regressions on my different projects. There is no cache on yaml/xml file as soon as annotation is enabled (which is the default)2/ add a cache at reader level for yaml/xml loader3/ add a cache cleaner at metadata level when annotation are enabledCommits-------1773dff [FrameworkBundle] enable metadata cache when annotation is disabled
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestMar 31, 2023
… disabled (bastnic)This PR was merged into the 5.4 branch.Discussion----------[FrameworkBundle] enable metadata cache when annotation is disabled| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->When using Annotations, annotations are cached at `AnnotationLoader` level.Which is cleared when entities are changed. So the dev experience is optimal.```[ClassMetadataFactory.php](vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php") on line 51:[Symfony\Component\Serializer\Mapping\Loader\LoaderChain](vendor/symfony/serializer/Mapping/Loader/LoaderChain.php&line=28#line28) {#543 ▼  -loaders: array:1 [▼    0 => [Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader](vendor/symfony/serializer/Mapping/Loader/AnnotationLoader.php&line=33#line33) {#544 ▼      -reader: [Doctrine\Common\Annotations\PsrCachedReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PsrCachedReader.php&line=22#line22) {#262 ▼        -delegate: [Doctrine\Common\Annotations\AnnotationReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php&line=20#line20) {#263 ▶}        -cache: [Symfony\Component\Cache\Adapter\PhpArrayAdapter](vendor/symfony/cache/Adapter/PhpArrayAdapter.php&line=32#line32) {#277 ▶}        -debug: true        -loadedAnnotations: array:14 [▶]        -loadedFilemtimes: array:4 [▶]      }    }  ]}```When using yaml files, there is no cache at the loader level so I added in the past the same cache as for the prod env, as the metadata are effectively cleared when using only yaml config files.symfony/symfony#35109The regression introduced by my patch is for people that do not use mapping files but use annotations.symfony/symfony#41961But now, we are in the opposite situation: no cache for people using mapping files but not annotations.On a current project it means loading 83 yaml files for each dev requests. It's not good at all.A simple local fix is to add that in a dev services files.```yamlserializer.mapping.cache_class_metadata_factory:    class: 'Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory'    decorates: 'serializer.mapping.class_metadata_factory'    arguments: ['`@serializer`.mapping.cache_class_metadata_factory.inner', '`@serializer`.mapping.cache.symfony']```![image](https://user-images.githubusercontent.com/84887/224833940-b8e7ad72-e7f6-44e7-a924-0b20f2f0cdae.png)A solution in Symfony could be:1/ only yaml/xml mapping files (`enable_annotations: false`) : cache like prod => that what I did in this PR, as it fixes the current perf regressions on my different projects. There is no cache on yaml/xml file as soon as annotation is enabled (which is the default)2/ add a cache at reader level for yaml/xml loader3/ add a cache cleaner at metadata level when annotation are enabledCommits-------1773dff5ce [FrameworkBundle] enable metadata cache when annotation is disabled
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestJul 28, 2023
… disabled (bastnic)This PR was merged into the 5.4 branch.Discussion----------[FrameworkBundle] enable metadata cache when annotation is disabled| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->When using Annotations, annotations are cached at `AnnotationLoader` level.Which is cleared when entities are changed. So the dev experience is optimal.```[ClassMetadataFactory.php](vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php") on line 51:[Symfony\Component\Serializer\Mapping\Loader\LoaderChain](vendor/symfony/serializer/Mapping/Loader/LoaderChain.php&line=28#line28) {#543 ▼  -loaders: array:1 [▼    0 => [Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader](vendor/symfony/serializer/Mapping/Loader/AnnotationLoader.php&line=33#line33) {#544 ▼      -reader: [Doctrine\Common\Annotations\PsrCachedReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PsrCachedReader.php&line=22#line22) {#262 ▼        -delegate: [Doctrine\Common\Annotations\AnnotationReader](vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php&line=20#line20) {#263 ▶}        -cache: [Symfony\Component\Cache\Adapter\PhpArrayAdapter](vendor/symfony/cache/Adapter/PhpArrayAdapter.php&line=32#line32) {#277 ▶}        -debug: true        -loadedAnnotations: array:14 [▶]        -loadedFilemtimes: array:4 [▶]      }    }  ]}```When using yaml files, there is no cache at the loader level so I added in the past the same cache as for the prod env, as the metadata are effectively cleared when using only yaml config files.symfony/symfony#35109The regression introduced by my patch is for people that do not use mapping files but use annotations.symfony/symfony#41961But now, we are in the opposite situation: no cache for people using mapping files but not annotations.On a current project it means loading 83 yaml files for each dev requests. It's not good at all.A simple local fix is to add that in a dev services files.```yamlserializer.mapping.cache_class_metadata_factory:    class: 'Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory'    decorates: 'serializer.mapping.class_metadata_factory'    arguments: ['`@serializer`.mapping.cache_class_metadata_factory.inner', '`@serializer`.mapping.cache.symfony']```![image](https://user-images.githubusercontent.com/84887/224833940-b8e7ad72-e7f6-44e7-a924-0b20f2f0cdae.png)A solution in Symfony could be:1/ only yaml/xml mapping files (`enable_annotations: false`) : cache like prod => that what I did in this PR, as it fixes the current perf regressions on my different projects. There is no cache on yaml/xml file as soon as annotation is enabled (which is the default)2/ add a cache at reader level for yaml/xml loader3/ add a cache cleaner at metadata level when annotation are enabledCommits-------1773dff5ce [FrameworkBundle] enable metadata cache when annotation is disabled
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

4 participants

@monteiro@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp