Feat/reset interface metadata resolvers#7920
Open
KevinMartinsDev wants to merge 2 commits intoapi-platform:mainfrom
Open
Feat/reset interface metadata resolvers#7920KevinMartinsDev wants to merge 2 commits intoapi-platform:mainfrom
KevinMartinsDev wants to merge 2 commits intoapi-platform:mainfrom
Conversation
Member
|
Same here. Ressources must be user/request independant. Clearing this cache between request will have bad performance impact for no benefits. |
Author
|
I understand the performance concern, but the 'private array' approach has two major drawbacks in a Worker context: unbounded memory growth (leak) and state isolation (duplicated RAM usage). A PSR-16 (Simple Cache) implementation would be the ideal compromise. It is actually more performant in a multi-worker setup. Shared Warm-up: Only the first worker computes the metadata, others benefit immediately. Reduced CPU & RAM: No redundant computations or N copies of the same data in memory. Stateless: The service becomes strictly 'Worker-ready' while keeping metadata persistent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is the second part of the worker mode compatibility audit (see #7918). It implements the
Symfony\Contracts\Service\ResetInterfacefor metadata resolvers and extractors that maintain internal state.The Issue
Several singleton services in the Metadata component use private arrays as local caches (e.g.,
$localIsResourceClassCache,$properties). In persistent memory runtimes like FrankenPHP or Swoole, these arrays:The Solution
By implementing
ResetInterface, we allow the Symfony kernel to automatically call thereset()method after each request (when running in worker mode).$localMostSpecificResourceClassCacheand$localIsResourceClassCache.$propertiescache.This ensures a "clean slate" for every request, preventing slow memory leaks and ensuring long-term stability for high-traffic APIs.
Context
This fix is part of a global audit performed with Igor-PHP.