Repository navigation
[perf] Cache realpath() of skip patterns in FileInfoMatcher - #8699
Merged
TomasVotruba merged 1 commit intoOct 18, 2026
Merged
Conversation
PHP does not cache a failed realpath() lookup. A wildcard skip pattern like "**/vendor/*" fails that lookup once for every file. The matcher now resolves each pattern once per run, and keeps a false result too.
Member
|
LGTM, thanks 👍 |
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.
FileInfoMatcher::matchRealpath()callsrealpath()on the skip pattern for every file the pattern did not match by string. PHP caches a successfulrealpath()lookup, but not a failed one. A wildcard pattern such as**/vendor/*never resolves, so every file pays one filesystem lookup per wildcard pattern.The matcher now keeps the
realpath()result of each pattern for the rest of the run,falseincluded. Each pattern is still resolved, so a literal skip path that contains*still matches throughrealpath(). That case is why #5830 was reverted in #5831. #6783 namedPathSkipperas a next step for the same kind of work.I measured on Shopware v6.7.6.2 with its own
rector.php, which leaves 1 file path and 3 wildcard patterns. The machine is an M4 Pro with PHP 8.5:process --dry-run: CPU median 4.1 s before, 3.5 s after, over 10 interleaved runs per side. The machine was busy, so wall times were too noisy to use. Three cold runs per side showed no difference within their noise.The new test resolves two plain patterns against file paths that contain
.., so only therealpath()comparison can match them. It fails when the cache is keyed by the file or by a constant.