Performance: Memoize sipped file paths#3495
Merged
samsonasik merged 2 commits intorectorphp:mainfrom Mar 20, 2023
Merged
Conversation
Member
|
New phpunit release https://github.com/sebastianbergmann/phpunit/releases/tag/10.0.17 seems cause error: You can pin to "phpunit/phpunit": "10.0.16" for now while wait for next paratest compatibility for it. |
Member
|
Thank you @keulinho |
samsonasik
pushed a commit
that referenced
this pull request
May 8, 2023
* Performance: Memoize sipped file paths * Pin phpunit version
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.
Every
AbstractRectorchecks if it should be skipped and executes all skippers, this leads to a lot of calls to theSkipVoters.The
PathSkipVoteronly skips based on the file path, but will be called for each configured rector and file in combination. Each call executed thedoesFileInfoMatchPatternswhich internally does a pcre match costing a lot of memory.By memoizing the skipped file path we can greatly reduce the needed memory. See this blackfire screenshot to see the impact:

You can see the full blackfire comparison here: https://blackfire.io/profiles/compare/d05668b7-6aea-4f8e-a9ef-88185948bfb7/graph
The used memory is decreased by ~50% in a test run with ~250 files. Also note that this method is called >75 000 times for this small test run.
This is related to rectorphp/rector#7806 and improves the situation for larger code bases quite a lot.