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] enable metadata cache when annotation is disabled#49679

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
nicolas-grekas merged 1 commit intosymfony:5.4frombastnic:feature/metadata-cache
Mar 31, 2023

Conversation

@bastnic
Copy link
Contributor

@bastnicbastnic commentedMar 13, 2023
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

When using Annotations, annotations are cached atAnnotationLoader 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.

#35109

The regression introduced by my patch is for people that do not use mapping files but use annotations.

#41961

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

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

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 loader
3/ add a cache cleaner at metadata level when annotation are enabled

tucksaun, kissifrot, welcoMattic, and xavismeh reacted with heart emoji
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

Choose a reason for hiding this comment

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

This patch works for me as a fix for the regression in 5.4

This means the serializer cache is not auto-invalidated when using yaml/xml. That was the case before, and is an acceptable tradeoff given the perf drop of parsing all files in every requests (in dev).

For 6.3 or up, we could add some auto-invalidation mechanism based on resource checkers, like we do for the container. That'd mean allowing loaders to declare their resources and the cache metadata factory to use those resources to trigger a prune on the pool when needed.

If you're OK with that, can you please open an issue so that we keep track of the need?

@bastnic
Copy link
ContributorAuthor

This means the serializer cache is not auto-invalidated when using yaml/xml. That was the case before, and is an acceptable tradeoff given the perf drop of parsing all files in every requests (in dev).

No no, it is!

nicolas-grekas reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

(please check test failures, they look related)

@bastnicbastnicforce-pushed thefeature/metadata-cache branch 2 times, most recently from090ea0b tof1bf23dCompareMarch 25, 2023 21:17
@bastnic
Copy link
ContributorAuthor

@nicolas-grekas tests are fixed now.

@nicolas-grekas
Copy link
Member

In standalone mode, tests still fail, can you have a look? (aka when running them from inside the FWB directory.)

@nicolas-grekas
Copy link
Member

Thank you@bastnic.

bastnic reacted with heart emoji

@nicolas-grekasnicolas-grekas merged commit9d6fdbf intosymfony:5.4Mar 31, 2023
This was referencedMar 31, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@bastnic@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp