Skip to content

[Performance] Ensure call $reflector->reflectAllClasses() once on Worker take 3#5878

Merged
samsonasik merged 6 commits intomainfrom
cache-class-names
May 14, 2024
Merged

[Performance] Ensure call $reflector->reflectAllClasses() once on Worker take 3#5878
samsonasik merged 6 commits intomainfrom
cache-class-names

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@mfn @dorrogeray here another effort to improve performance of DynamicSourceLocatorProvider, make it on Cache object and save collection of classnames into cache, so $reflector->reflectAllClasses(), later, only calls the $this->reflectionProvider->getClass() from cache class names.

Closes rectorphp/rector#8637
Closes rectorphp/rector#8638

Before

➜  rector-src git:(main) time bin/rector     
 2180/2180 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

bin/rector  387.45s user 14.97s system 690% cpu 58.319 total

After

➜  rector-src git:(cache-class-names) time bin/rector process --clear-cache
 2180/2180 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

bin/rector process --clear-cache  303.96s user 12.57s system 641% cpu 49.342 total

@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it to have faster feedback to test ;)

@samsonasik samsonasik merged commit 50407e2 into main May 14, 2024
@samsonasik samsonasik deleted the cache-class-names branch May 14, 2024 19:22
@samsonasik
Copy link
Copy Markdown
Member Author

@mfn @dorrogeray please try latest dev-main, it should be better now :), I will keep on if there is a better way to improve it. Current latest on rector-src code base itself:

Before 58.689 seconds

time bin/rector process --clear-cache
 2180/2180 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

bin/rector process --clear-cache  377.52s user 16.85s system 671% cpu 58.689 total

After 48.629 seconds

time bin/rector process --clear-cache
 2180/2180 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

bin/rector process --clear-cache  302.21s user 12.61s system 647% cpu 48.629 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance regression when using rector 1.05 with phpstan 1.11.0 Performance regression since 1.0.5

1 participant