Repository navigation
perf(symfony): warm metadata for API resources - #8847
nicolas-grekas wants to merge 5 commits into
Conversation
…m tagged providers (nicolas-grekas) This PR was squashed before being merged into the 8.2 branch. Discussion ---------- [PropertyInfo][Serializer][Validator] Warm classes from tagged providers | Q | A | ------------- | --- | Branch? | 8.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT Completes #66386. Bundles can tag iterable services to provide classes for PropertyInfo, Serializer, and Validator warmup. The Serializer warmer removes duplicate fallback entries after writing its PHP array. With api-platform/core#8847 on Symfony 8.2, the test app's system pool has 992 files after warmup, down from 14,389 before these warmers. Commits ------- 4f81090 [PropertyInfo][Serializer][Validator] Warm classes from tagged providers
| ]) | ||
| ->tag('kernel.cache_warmer', ['priority' => -10]); | ||
|
|
||
| $services->set('api_platform.cache.metadata.property.php_array', PhpArrayAdapter::class) |
There was a problem hiding this comment.
in debug this goes stale no? the warmer is optional so it only runs on cache:warmup, when I edit an #[ApiProperty] the container rebuilds and cache.system gets a new namespace but api_platform_property_metadata.php stays the old file and the PhpArrayAdapter never asks the fallback. FrameworkBundle only wires its php array caches when !kernel.debug, can we do the same here?
| service('api_platform.property_info.cache.adapter'), | ||
| ]); | ||
|
|
||
| $services->set('api_platform.property_info.cache.adapter', PhpArrayAdapter::class) |
There was a problem hiding this comment.
same here for api_platform_property_info.php
| ->args([ | ||
| service('api_platform.metadata.resource.name_collection_factory'), | ||
| service('api_platform.metadata.property.name_collection_factory'), | ||
| service('api_platform.metadata.property.metadata_factory'), |
There was a problem hiding this comment.
this is the decorated factory so warming goes through the php_array pool, writes into cache.system and then needs the deleteItems() cleanup, can we inject api_platform.metadata.property.metadata_factory.cached.inner (and the name collection one) like you did with api_platform.property_info.cache.inner?
Instead of #8846.
API Platform warms PropertyInfo and default property metadata into PHP arrays. It also supplies resource classes to Symfony's PropertyInfo, Serializer, and Validator warmers. With symfony/symfony#68155 on Symfony 8.2, the test app's system pool falls from 14,389 to 992 files after
cache:warmup. The property warmer saves 2,333 inodes; OpenAPI export still creates 19,996 files for additional metadata keys.