Skip to content

perf(symfony): warm metadata for API resources - #8847

Open
nicolas-grekas wants to merge 5 commits into
api-platform:mainfrom
nicolas-grekas:perf/warm-property-info-cache
Open

nicolas-grekas wants to merge 5 commits into
api-platform:mainfrom
nicolas-grekas:perf/warm-property-info-cache

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor
Q A
Branch? main
Tickets -
License MIT
Doc PR n/a

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.

@nicolas-grekas nicolas-grekas changed the title perf(symfony): warm property info for API resources perf(symfony): warm metadata for API resources Nov 13, 2026
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Nov 13, 2026
…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

@soyuka soyuka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice io improvement

])
->tag('kernel.cache_warmer', ['priority' => -10]);

$services->set('api_platform.cache.metadata.property.php_array', PhpArrayAdapter::class)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants