Repository navigation
Perf: stop searching inside directories a ** entry already matched (config load 60 to 85 % faster with **/vendor-style entries) - #14624
Merged
Conversation
A <directory> entry such as **/vendor walked every directory under the base, including the matched vendor directories themselves, only to find the vendor directories nested in them. Those lie inside a match, so they don't change which files the filter accepts. A directory matching the next part of the pattern is now searched only for the rest of it. This also fixes a <file> entry with two ** levels listing a file twice when it was reached through two nested matches of the middle part. getDirectories() no longer lists a match nested in another match of the same entry.
alies-dev
marked this pull request as ready for review
November 22, 2026 02:34
Contributor
✅ Performance: unchanged · Types: unchanged
How to read this table
head 55142ff · base 9028ade (merge-base) · workflow run |
** entry already matched** entry already matched (config load 60 to 85 % faster with **/vendor-style entries)
One data-provider test (5 cases) plus the symlink test, instead of ten methods. Drops the CLI test: the UnusedIssueHandlerSuppression message is implode(', ', [...getFiles(), ...getDirectories()]), which the getFiles/getDirectories assertions already pin.
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.
For a
<directory>entry with**, such as<directory name="**/vendor"/>inignoreFiles, Psalm walked every directory below the config's directory. It also walked inside eachvendordirectory it had already matched, looking for more matches. Psalm loads the config twice per run (before and after its restart), so a bigvendorwas walked twice. Psalm now stops at a matched directory, because the match already covers everything inside it.Which project files Psalm analyses or ignores doesn't change, apart from the symlink case below. What does change:
UnusedIssueHandlerSuppressionlists each matched path once. It no longer lists a match nested inside another match of the same entry (/vendor/instead of/vendor/a/vendor/, /vendor/; a<file name="pk/**/vendor/**/*.php"/>file reached through two nested matches was listed twice).vendor/acme/pkglinking to a directory outside the project that has its ownvendor). Entries ending in a file pattern (**/vendor/**/*.php) still find such files.#14559 (a symlink cycle in a
**walk) touches the same function. The two PRs merge cleanly. Both are needed: with this PR alone, a symlink cycle outside any match still hangs.Measurements
Apple M1 Pro (10 cores, 32 GB), PHP 8.5.12,
zend.assertions=1, master 9028ade against this branch (measured at 90f88539c, the same source). drupal's config has itsvendorentry inignoreFileswritten as**/vendor; the big Laravel app (a large private application) uses its own config, which ignorespackages/**/vendor.Config::loadFromXMLFile(), 6 loads in one process, two blocks per version alternating (master, branch, branch, master), warm file system cache. The project file set (every PHP fileisInProjectDirs()accepts) is identical on both versions.Full runs,
--no-cache, runs of the two versions alternating (ABAB, then BABA). "outside phases" is the wall time minus the scan, analysis and merge phases: start-up (where the config is loaded, twice because of the restart) and shutdown. A change is marked only where the means differ by more than 2 % (wall 3 %) and by more than the spread of the runs in the cell; single runs are not marked.Issues: the full issue lists (type, file, line, column, message, taint trace) are identical in every run, at one and at eight threads.