Performance: Improve node name resolver performance#3506
Merged
samsonasik merged 4 commits intorectorphp:mainfrom Mar 23, 2023
Merged
Performance: Improve node name resolver performance#3506samsonasik merged 4 commits intorectorphp:mainfrom
samsonasik merged 4 commits intorectorphp:mainfrom
Conversation
Contributor
Author
|
Will work on the phpstan errors later today ✌️ |
760bf73 to
5915483
Compare
samsonasik
reviewed
Mar 23, 2023
samsonasik
reviewed
Mar 23, 2023
samsonasik
reviewed
Mar 23, 2023
samsonasik
reviewed
Mar 23, 2023
samsonasik
approved these changes
Mar 23, 2023
Member
samsonasik
left a comment
There was a problem hiding this comment.
Looks good 👍 , let's give it a try
Member
|
Thank you @keulinho |
samsonasik
pushed a commit
that referenced
this pull request
May 8, 2023
* Performance: Improve node name resolver performance * Fix phpstan * Add regex example link * Fix CR comments
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.
In #3502 we changed a lot of rectors to use
isNameoverisObject, becauseisNameis a lot faster.But we can make it even faster. This contains two performance fixes:
Don't loop every time through all node name resolvers:
This code may be executed millions of times always looping to find the one name resolver can be improved by caching the used resolver per node class
Checking if a string contains regex or fnmatch special chars before really analyzing if it is a regex pattern is much faster, as in most cases the desired name does not contain a special char
This brings another 10% performance increase in our test scenario: https://blackfire.io/profiles/compare/33d481dc-2a9d-439f-bed6-636f6eaaa8fa/graph
