Skip to content

SymfonyContainerResultCacheMetaExtension optimization#488

Open
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk:result-cache-hash-cache
Open

SymfonyContainerResultCacheMetaExtension optimization#488
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk:result-cache-hash-cache

Conversation

@xificurk
Copy link
Copy Markdown
Contributor

@xificurk xificurk commented May 9, 2026

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:

Scrn_20260509_103902

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.

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>
@staabm
Copy link
Copy Markdown
Contributor

staabm commented May 9, 2026

@Wirone @ruudk you both contributed into the discussion of this feature. could you have a look at this proposal?

@xificurk how much does this change/improve your real world project? could you send some before/after 'hyperfine' numbers (measured without profiler-extension overhead)?

@xificurk
Copy link
Copy Markdown
Contributor Author

xificurk commented May 9, 2026

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 bin/phpstan analyse bin/console.php

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