SymfonyContainerResultCacheMetaExtension optimization#488
Open
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
Open
SymfonyContainerResultCacheMetaExtension optimization#488xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
Conversation
Add simple filesytem cache for the DI container hash to avoid expensive parsing, normalizing and hashing of the whole DI container on each call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Contributor
Author
|
Measured on top of #487 (comment) In combination with the lazy maps, this PR eliminates the initialization of ServiceMap and ParameterMap in the main process as well, leading to further improvement (10 run median) 8.77s -> 8.18s on the same simple test |
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.
The cache busting strategy implemented by the extension attempts to avoid unnecessary invalidations by calculating the hash from the parsed parameters and services used within phpstan-symfony logic. This addresses the case when the container XML have been regenerated and changed, but not in an significant way impacting the result cache (originally discussed in #255).
The problem is that on large DI containers this parsing, normalizing and hashing is not exactly cheap:
This PR adds a simple filesytem cache for the calculated hash to avoid this cost - the hash is recalculated from the parsed services/parameters only when the underlying XML changes.