-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Improve node name resolver performance #3506
Merged
samsonasik
merged 4 commits into
rectorphp:main
from
keulinho:improve-node-name-resolver
Mar 23, 2023
Merged
Performance: Improve node name resolver performance #3506
samsonasik
merged 4 commits into
rectorphp:main
from
keulinho:improve-node-name-resolver
Mar 23, 2023
Conversation
This file contains 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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 , let's give it a try
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
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
isName
overisObject
, becauseisName
is 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
